mlxtend version: 0.13.0

LinearDiscriminantAnalysis

LinearDiscriminantAnalysis(n_discriminants=None)

Linear Discriminant Analysis Class

Parameters

  • n_discriminants : int (default: None)

    The number of discrimants for transformation. Keeps the original dimensions of the dataset if None.

Attributes

  • w_ : array-like, shape=[n_features, n_discriminants]

    Projection matrix

  • e_vals_ : array-like, shape=[n_features]

    Eigenvalues in sorted order.

  • e_vecs_ : array-like, shape=[n_features]

    Eigenvectors in sorted order.

Examples

For usage examples, please see http://rasbt.github.io/mlxtend/user_guide/feature_extraction/LinearDiscriminantAnalysis/

Methods


fit(X, y, n_classes=None)

Fit the LDA model with X.

Parameters

  • X : {array-like, sparse matrix}, shape = [n_samples, n_features]

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

  • y : array-like, shape = [n_samples]

    Target values.

  • n_classes : int (default: None)

    A positive integer to declare the number of class labels if not all class labels are present in a partial training set. Gets the number of class labels automatically if None.

Returns

  • self : object

get_params(deep=True)

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.'

    adapted from https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py

    Author: Gael Varoquaux gael.varoquaux@normalesup.org

    License: BSD 3 clause


set_params(params)

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

adapted from https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py

Author: Gael Varoquaux gael.varoquaux@normalesup.org

License: BSD 3 clause


transform(X)

Apply the linear transformation on X.

Parameters

  • X : {array-like, sparse matrix}, shape = [n_samples, n_features]

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

Returns

  • X_projected : np.ndarray, shape = [n_samples, n_discriminants]

    Projected training vectors.

PrincipalComponentAnalysis

PrincipalComponentAnalysis(n_components=None, solver='eigen')

Principal Component Analysis Class

Parameters

  • n_components : int (default: None)

    The number of principal components for transformation. Keeps the original dimensions of the dataset if None.

  • solver : str (default: 'eigen')

    Method for performing the matrix decomposition. {'eigen', 'svd'}

Attributes

  • w_ : array-like, shape=[n_features, n_components]

    Projection matrix

  • e_vals_ : array-like, shape=[n_features]

    Eigenvalues in sorted order.

  • e_vecs_ : array-like, shape=[n_features]

    Eigenvectors in sorted order.

  • loadings_ : array_like, shape=[n_features, n_features]

    The factor loadings of the original variables onto the principal components. The columns are the principal components, and the rows are the features loadings. For instance, the first column contains the loadings onto the first principal component. Note that the signs may be flipped depending on whether you use the 'eigen' or 'svd' solver; this does not affect the interpretation of the loadings though.

Examples

For usage examples, please see http://rasbt.github.io/mlxtend/user_guide/feature_extraction/PrincipalComponentAnalysis/

Methods


fit(X)

Learn model from training data.

Parameters

  • X : {array-like, sparse matrix}, shape = [n_samples, n_features]

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

Returns

  • self : object

get_params(deep=True)

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.'

    adapted from https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py

    Author: Gael Varoquaux gael.varoquaux@normalesup.org

    License: BSD 3 clause


set_params(params)

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

adapted from https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py

Author: Gael Varoquaux gael.varoquaux@normalesup.org

License: BSD 3 clause


transform(X)

Apply the linear transformation on X.

Parameters

  • X : {array-like, sparse matrix}, shape = [n_samples, n_features]

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

Returns

  • X_projected : np.ndarray, shape = [n_samples, n_components]

    Projected training vectors.

RBFKernelPCA

RBFKernelPCA(gamma=15.0, n_components=None, copy_X=True)

RBF Kernel Principal Component Analysis for dimensionality reduction.

Parameters

  • gamma : float (default: 15.0)

    Free parameter (coefficient) of the RBF kernel.

  • n_components : int (default: None)

    The number of principal components for transformation. Keeps the original dimensions of the dataset if None.

  • copy_X : bool (default: True)

    Copies training data, which is required to compute the projection of new data via the transform method. Uses a reference to X if False.

Attributes

  • e_vals_ : array-like, shape=[n_features]

    Eigenvalues in sorted order.

  • e_vecs_ : array-like, shape=[n_features]

    Eigenvectors in sorted order.

  • X_projected_ : array-like, shape=[n_samples, n_components]

    Training samples projected along the component axes.

Examples

For usage examples, please see http://rasbt.github.io/mlxtend/user_guide/feature_extraction/RBFKernelPCA/

Methods


fit(X)

Learn model from training data.

Parameters

  • X : {array-like, sparse matrix}, shape = [n_samples, n_features]

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

Returns

  • self : object

get_params(deep=True)

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.'

    adapted from https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py

    Author: Gael Varoquaux gael.varoquaux@normalesup.org

    License: BSD 3 clause


set_params(params)

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

adapted from https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py

Author: Gael Varoquaux gael.varoquaux@normalesup.org

License: BSD 3 clause


transform(X)

Apply the non-linear transformation on X.

Parameters

  • X : {array-like, sparse matrix}, shape = [n_samples, n_features]

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

Returns

  • X_projected : np.ndarray, shape = [n_samples, n_components]

    Projected training vectors.