class sklearn.linear_model.PassiveAggressiveClassifier(C=1.0, fit_intercept=True, max_iter=None, tol=None, early_stopping=False, validation_fraction=0.1, n_iter_no_change=5, shuffle=True, verbose=0, loss=’hinge’, n_jobs=None, random_state=None, warm_start=False, class_weight=None, average=False, n_iter=None)
[source]
Passive Aggressive Classifier
Read more in the User Guide.
Parameters: 


Attributes: 

See also
Online PassiveAggressive Algorithms <http://jmlr.csail.mit.edu/papers/volume7/crammer06a/crammer06a.pdf> K. Crammer, O. Dekel, J. Keshat, S. ShalevShwartz, Y. Singer  JMLR (2006)
>>> from sklearn.linear_model import PassiveAggressiveClassifier >>> from sklearn.datasets import make_classification >>> >>> X, y = make_classification(n_features=4, random_state=0) >>> clf = PassiveAggressiveClassifier(max_iter=1000, random_state=0) >>> clf.fit(X, y) PassiveAggressiveClassifier(C=1.0, average=False, class_weight=None, early_stopping=False, fit_intercept=True, loss='hinge', max_iter=1000, n_iter=None, n_iter_no_change=5, n_jobs=None, random_state=0, shuffle=True, tol=None, validation_fraction=0.1, verbose=0, warm_start=False) >>> print(clf.coef_) [[0.29509834 0.33711843 0.56127352 0.60105546]] >>> print(clf.intercept_) [2.54153383] >>> print(clf.predict([[0, 0, 0, 0]])) [1]
decision_function (X)  Predict confidence scores for samples. 
densify ()  Convert coefficient matrix to dense array format. 
fit (X, y[, coef_init, intercept_init])  Fit linear model with Passive Aggressive algorithm. 
get_params ([deep])  Get parameters for this estimator. 
partial_fit (X, y[, classes])  Fit linear model with Passive Aggressive algorithm. 
predict (X)  Predict class labels for samples in X. 
score (X, y[, sample_weight])  Returns the mean accuracy on the given test data and labels. 
set_params (*args, **kwargs)  
sparsify ()  Convert coefficient matrix to sparse format. 
__init__(C=1.0, fit_intercept=True, max_iter=None, tol=None, early_stopping=False, validation_fraction=0.1, n_iter_no_change=5, shuffle=True, verbose=0, loss=’hinge’, n_jobs=None, random_state=None, warm_start=False, class_weight=None, average=False, n_iter=None)
[source]
decision_function(X)
[source]
Predict confidence scores for samples.
The confidence score for a sample is the signed distance of that sample to the hyperplane.
Parameters: 


Returns: 

densify()
[source]
Convert coefficient matrix to dense array format.
Converts the coef_
member (back) to a numpy.ndarray. This is the default format of coef_
and is required for fitting, so calling this method is only required on models that have previously been sparsified; otherwise, it is a noop.
Returns: 


fit(X, y, coef_init=None, intercept_init=None)
[source]
Fit linear model with Passive Aggressive algorithm.
Parameters: 


Returns: 

get_params(deep=True)
[source]
Get parameters for this estimator.
Parameters: 


Returns: 

loss_function
DEPRECATED: Attribute loss_function was deprecated in version 0.19 and will be removed in 0.21. Use loss_function_
instead
partial_fit(X, y, classes=None)
[source]
Fit linear model with Passive Aggressive algorithm.
Parameters: 


Returns: 

predict(X)
[source]
Predict class labels for samples in X.
Parameters: 


Returns: 

score(X, y, sample_weight=None)
[source]
Returns the mean accuracy on the given test data and labels.
In multilabel classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Parameters: 


Returns: 

sparsify()
[source]
Convert coefficient matrix to sparse format.
Converts the coef_
member to a scipy.sparse matrix, which for L1regularized models can be much more memory and storageefficient than the usual numpy.ndarray representation.
The intercept_
member is not converted.
Returns: 


For nonsparse models, i.e. when there are not many zeros in coef_
, this may actually increase memory usage, so use this method with care. A rule of thumb is that the number of zero elements, which can be computed with (coef_ == 0).sum()
, must be more than 50% for this to provide significant benefits.
After calling this method, further fitting with the partial_fit method (if any) will not work until you call densify.
sklearn.linear_model.PassiveAggressiveClassifier
© 2007–2018 The scikitlearn developers
Licensed under the 3clause BSD License.
http://scikitlearn.org/stable/modules/generated/sklearn.linear_model.PassiveAggressiveClassifier.html