class turicreate.logistic_classifier.LogisticClassifier(model_proxy)

Logistic regression models a discrete target variable as a function of several feature variables.

The logisticClassifier uses a discrete target variable \(y\) instead of a scalar. For each observation, the probability that \(y=1\) (instead of 0) is modeled as the logistic function of a linear combination of the feature values.

Given a set of features \(x_i\), and a label \(y_i \in \{0,1\}\), logistic regression interprets the probability that the label is in one class as a logistic function of a linear combination of the features.

\[f_i(\theta) = p(y_i = 1 | x) = \frac{1}{1 + \exp(-\theta^T x)}\]

An intercept term is added by appending a column of 1’s to the features. Regularization is often required to prevent over fitting by penalizing models with extreme parameter values. The logistic regression module supports l1 and l2 regularization, which are added to the loss function.

The composite objective being optimized for is the following;

\[\min_{\theta} \sum_{i = 1}^{n} f_i(\theta) + \lambda_1 ||\theta||_1 + \lambda_2 ||\theta||^{2}_{2}\]

where \(\lambda_1\) is the l1_penalty and \(\lambda_2\) is the l2_penalty.

For multi-class models, we perform multinomial logistic regression, which is an extension of the binary logistic regression model discussed above.

This model cannot be constructed directly. Instead, use turicreate.logistic_classifier.create() to create an instance of this model. A detailed list of parameter options and code samples are available in the documentation for the create function.

See also



# Load the data (From an S3 bucket)
>>> data =  turicreate.SFrame('https://static.turi.com/datasets/regression/houses.csv')

# Make sure the target is discrete
>>> data['is_expensive'] = data['price'] > 30000

# Make a logistic regression model
>>> model = turicreate.logistic_classifier.create(data, target='is_expensive', features=['bath', 'bedroom', 'size'])

# Extract the coefficients
>>> coefficients = model.coefficients

# Make predictions (as margins, probability, or class)
>>> predictions = model.predict(data)
>>> predictions = model.predict(data, output_type='probability')
>>> predictions = model.predict(data, output_type='margin')

# Evaluate the model
>>> results = model.evaluate(data)


LogisticClassifier.classify(dataset[, …]) Return a classification, for each example in the dataset, using the trained logistic regression model.
LogisticClassifier.evaluate(dataset[, …]) Evaluate the model by making predictions of target values and comparing these to actual values.
LogisticClassifier.export_coreml(filename) Export the model in Core ML format.
LogisticClassifier.predict(dataset[, …]) Return predictions for dataset, using the trained logistic regression model.
LogisticClassifier.predict_topk(dataset[, …]) Return top-k predictions for the dataset, using the trained model.
LogisticClassifier.save(location) Save the model.
LogisticClassifier.summary([output]) Print a summary of the model.