tensorly.regression
.CP_PLSR
- class CP_PLSR(n_components, tol=1e-09, n_iter_max=100, random_state=None, verbose=False)[source]
CP tensor regression
Learns a low rank CP tensor weight, This performs a partial least square regression to a tensor X (>= 2 modes) against a matrix Y. The first modes of X and Y will be considered coupled, and the decomposition will maximize the covariance between them.
- Parameters:
- n_componentsint
rank of the CP decomposition of the regression weights
- tolfloat
convergence value
- n_iter_maxint, optional, default is 100
maximum number of iteration
- random_stateNone, int or RandomState, optional, default is None
- verbosebool, default is False
whether to be verbose during fitting
References
[1]Rasmus Bro, “Multiway calibration. Multilinear PLS”, Chemometrics, 1996
- fit(X, Y)[source]
Fits the model to the data (X, Y)
- Parameters:
- Xndarray
tensor data of shape (n_samples, N1, …, NS)
- Y2D-array of shape (n_samples, n_predictions)
labels associated with each sample
- Returns:
- self
- fit_transform(X, Y)[source]
Learn and apply the dimension reduction on the train data.
- Parameters:
- Xarray-like of shape (n_samples, n_features)
Training vectors, where n_samples is the number of samples and n_features is the number of predictors.
- yarray-like of shape (n_samples, n_targets), default=None
Target vectors, where n_samples is the number of samples and n_targets is the number of response variables.
- Returns:
- selfndarray of shape (n_samples, n_components)
Return x_scores if Y is not given, (x_scores, y_scores) otherwise.
- get_params(**kwargs)[source]
Returns a dictionary of parameters
- predict(X)[source]
Returns the predicted labels for a new data tensor
- Parameters:
- Xndarray
tensor data of shape (n_samples, N1, …, NS)
- set_params(**parameters)[source]
Sets the value of the provided parameters
- transform(X, Y=None)[source]
Apply the dimension reduction from fitting to a new tensor.
- Parameters:
- Xarray-like of shape (n_samples, n_features)
Samples to transform.
- Yarray-like of shape (n_samples, n_targets), default=None
Target vectors.
- Returns:
- X_scores, Y_scoresarray-like or tuple of array-like
Return X_scores if Y is not given, (X_scores, Y_scores) otherwise.