sklearn.lda
.LDA¶
Warning
DEPRECATED
-
class
sklearn.lda.
LDA
(solver='svd', shrinkage=None, priors=None, n_components=None, store_covariance=False, tol=0.0001)[source]¶ Alias for
sklearn.discriminant_analysis.LinearDiscriminantAnalysis
.Deprecated since version 0.17: This class will be removed in 0.19. Use
sklearn.discriminant_analysis.LinearDiscriminantAnalysis
instead.Methods
decision_function
(X)Predict confidence scores for samples. fit
(X, y[, store_covariance, tol])Fit LinearDiscriminantAnalysis model according to the given training data and parameters. fit_transform
(X[, y])Fit to data, then transform it. get_params
([deep])Get parameters for this estimator. predict
(X)Predict class labels for samples in X. predict_log_proba
(X)Estimate log probability. predict_proba
(X)Estimate probability. score
(X, y[, sample_weight])Returns the mean accuracy on the given test data and labels. set_params
(\*\*params)Set the parameters of this estimator. transform
(X)Project data to maximize class separation. -
__init__
(solver='svd', shrinkage=None, priors=None, n_components=None, store_covariance=False, tol=0.0001)[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: X : {array-like, sparse matrix}, shape = (n_samples, n_features)
Samples.
Returns: array, shape=(n_samples,) if n_classes == 2 else (n_samples, n_classes) :
Confidence scores per (sample, class) combination. In the binary case, confidence score for self.classes_[1] where >0 means this class would be predicted.
-
fit
(X, y, store_covariance=None, tol=None)[source]¶ - Fit LinearDiscriminantAnalysis model according to the given
training data and parameters.
Changed in version 0.17: Deprecated store_covariance have been moved to main constructor.
Changed in version 0.17: Deprecated tol have been moved to main constructor.
Parameters: X : array-like, shape (n_samples, n_features)
Training data.
y : array, shape (n_samples,)
Target values.
-
fit_transform
(X, y=None, **fit_params)[source]¶ Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Parameters: X : numpy array of shape [n_samples, n_features]
Training set.
y : numpy array of shape [n_samples]
Target values.
Returns: X_new : numpy array of shape [n_samples, n_features_new]
Transformed array.
-
get_params
(deep=True)[source]¶ Get parameters for this estimator.
Parameters: deep : boolean, optional
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns: params : mapping of string to any
Parameter names mapped to their values.
-
predict
(X)[source]¶ Predict class labels for samples in X.
Parameters: X : {array-like, sparse matrix}, shape = [n_samples, n_features]
Samples.
Returns: C : array, shape = [n_samples]
Predicted class label per sample.
-
predict_log_proba
(X)[source]¶ Estimate log probability.
Parameters: X : array-like, shape (n_samples, n_features)
Input data.
Returns: C : array, shape (n_samples, n_classes)
Estimated log probabilities.
-
predict_proba
(X)[source]¶ Estimate probability.
Parameters: X : array-like, shape (n_samples, n_features)
Input data.
Returns: C : array, shape (n_samples, n_classes)
Estimated probabilities.
-
score
(X, y, sample_weight=None)[source]¶ Returns the mean accuracy on the given test data and labels.
In multi-label 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: X : array-like, shape = (n_samples, n_features)
Test samples.
y : array-like, shape = (n_samples) or (n_samples, n_outputs)
True labels for X.
sample_weight : array-like, shape = [n_samples], optional
Sample weights.
Returns: score : float
Mean accuracy of self.predict(X) wrt. y.
-
set_params
(**params)[source]¶ Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.Returns: self :
-