shnitsel.analyze.pls¶
Functions¶
|
Performs the partial least squares analysis on the two data arrays provided as arguments and returns the |
|
Wrapper function to perform partial least square analysis on two variables of a dataset |
Module Contents¶
- pls(xdata_array, ydata_array, n_components=2, common_dim=None)¶
Performs the partial least squares analysis on the two data arrays provided as arguments and returns the requested number of resulting main components.
- Parameters:
xdata_array (xr.DataArray) – First set of data. Shape should be (n_samples, n_features) with n_samples being the length of the common dimension with ydata_array.
ydata_array (xr.DataArray) – Second set of data. Shape should be (n_samples, n_targets) with n_samples being the length of the common dimension with xdata_array.
n_components (int, optional) – Number of most relevant main components that should be returned. Defaults to 2.
common_dim (str | None, optional) – The common dimension which should not be reduced in the course of the analysis. Defaults to None and will attempt to find a single common dimension.
- Raises:
ValueError – If either xdata_array or ydata_array do not have exactly 2 dimensions.
ValueError – If no common_dim was set and x and y data did not have exactly 1 dimension in common to allow for automatic identification of the common dimension.
- Returns:
The dataset holding the results of the PLS analysis. Results will either be in variables with the same name as xdata_array or ydata_array or in variables x and y if the names on the respective array are not set.
- Return type:
xr.Dataset
- pls_ds(dataset, xname, yname, n_components=2, common_dim=None)¶
Wrapper function to perform partial least square analysis on two variables of a dataset
- Parameters:
dataset (xr.Dataset) – The dataset holding the variables to apply PLS to
xname (str) – The name of the variable to use as the x data for the PLS.
yname (str) – The name of the variable to use as the y data for the PLS.
n_components (int, optional) – Number of most relevant main components that should be returned. Defaults to 2.
common_dim (str | None, optional) – The common dimension which should not be reduced in the course of the analysis. Defaults to None and will attempt to find a single common dimension.
- Returns:
The result of the call to pls(). Has the results of the PLS as variables in either the same names as xname and yname or in x and y.s
- Return type:
xr.Dataset