mlxtend version: 0.9.2dev

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.

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

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.

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.

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

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.

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.

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

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.