Contents

scikits.learn.logistic.LogisticRegression

class scikits.learn.logistic.LogisticRegression(penalty='l2', eps=0.0001, C=1.0, fit_intercept=True)

Logistic Regression.

Implements L1 and L2 regularized logistic regression.

Parameters :

X : array-like, shape = [n_samples, n_features]

Training vector, where n_samples in the number of samples and n_features is the number of features.

Y : array, shape = [n_samples]

Target vector relative to X

penalty : string, ‘l1’ or ‘l2’

Used to specify the norm used in the penalization

C : float

Specifies the strength of the regularization. The smaller it is the bigger in the regularization.

fit_intercept : bool, default: True

Specifies if a constant (a.k.a. bias or intercept) should be added the decision function

See also

LinearSVC

References

LIBLINEAR – A Library for Large Linear Classification http://www.csie.ntu.edu.tw/~cjlin/liblinear/

Attributes

coef_ array, shape = [n_classes-1, n_features] Coefficient of the features in the decision function.
intercept_ array, shape = [n_classes-1] intercept (a.k.a. bias) added to the decision function. It is available only when parameter intercept is set to True

Methods

fit(X, Y) self Fit the model
predict(X) array Predict using the model.
__init__(penalty='l2', eps=0.0001, C=1.0, fit_intercept=True)
fit(X, Y, **params)

Fit the model according to the given training data and parameters.

Parameters :

X : array-like, shape = [nsamples, nfeatures]

Training vector, where nsamples in the number of samples and nfeatures is the number of features.

Y : array, shape = [nsamples]

Target vector relative to X

Returns :

self : object

Returns self.

predict(T)

This function does classification or regression on an array of test vectors T.

For a classification model, the predicted class for each sample in T is returned. For a regression model, the function value of T calculated is returned.

For an one-class model, +1 or -1 is returned.

Parameters :T : array-like, shape = [n_samples, n_features]
Returns :C : array, shape = [nsample]
score(X, y)

Returns the mean error rate on the given test data and labels.

Parameters :

X : array-like, shape = [n_samples, n_features]

Training set.

y : array-like, shape = [n_samples]

Labels for X.

Returns :

z : float