PcaLdaClassification

class PcaLdaClassification(explained_variance=0.8, da_type='lda', PCA_kwargs={'n_components': 0.8}, DA_kwargs={})[source][source]

Class for the PCA - LDA Classifier

Parameters:
  • variance (explained) – the number of modes that explain the cumulative variance of the dataset

  • da_type (string, optional, default lda) – type of discriminant analysis; lda or qda

fit(X_flat_train, y_train)[source][source]

Train PCA - LDA classifier

Parameters:
  • X_flat_train (numpy 2d array of shape [n_samples,n_features]) – This is the neural data. See example file for an example of how to format the neural data correctly

  • y_train (numpy 1d array of shape (n_samples), with integers)

  • classes (representing) – This is the outputs that are being predicted

get_scores(deep=True)[source][source]

Get scores of pca and lda model

Args:

deep (bool, optional): Defaults to True.

Returns:

scores: dict Returns fitted scores of PCA and LDA

predict(X_flat_test)[source][source]

Predict outcomes using trained PCA LDA Decoder

Parameters:

X_flat_test (numpy 2d array of shape [n_samples,n_features]) – This is the neural data being used to predict outputs.

Returns:

y_test_predicted – The predicted outputs

Return type:

numpy 1d array with integers as classes

score(X, y, sample_weight=None)[source][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 – Mean accuracy of self.predict(X) wrt. y.

Return type:

float

set_fit_request(*, X_flat_train: bool | None | str = '$UNCHANGED$', y_train: bool | None | str = '$UNCHANGED$') PcaLdaClassification[source]

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
  • X_flat_train (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for X_flat_train parameter in fit.

  • y_train (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for y_train parameter in fit.

  • self (PcaLdaClassification)

Returns:

self – The updated object.

Return type:

object

set_predict_request(*, X_flat_test: bool | None | str = '$UNCHANGED$') PcaLdaClassification[source]

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
Returns:

self – The updated object.

Return type:

object

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') PcaLdaClassification[source]

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
  • sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in score.

  • self (PcaLdaClassification)

Returns:

self – The updated object.

Return type:

object