aub_htp.machine_learning#
Machine Learning for Alpha Stable Distributions.
|
Scikit-learn compatible Alpha-stable linear regression. |
|
|
|
|
|
- class aub_htp.machine_learning.AlphaStableKMeans(n_clusters: int = 8, alpha: float = 1.0, *, max_iter: int = 100, tol: float = 1e-06)#
Bases:
ClusterMixin,BaseEstimator- fit(X, y=None)#
- predict(X)#
- score(X, y=None, sample_weight=None)#
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') AlphaStableKMeans#
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.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.
Parameters#
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter inscore.
Returns#
- selfobject
The updated object.
- class aub_htp.machine_learning.AlphaStableLinearRegressor(alpha: float = 1.0, *, max_iter: int = 5000, tol: float = 1e-06, optimizer: str = 'Powell')#
Bases:
RegressorMixin,BaseEstimatorScikit-learn compatible Alpha-stable linear regression.
Given \(\textbf{x}\) and \(\textbf{y}\) as training data, where \(\textbf{x}\) is a matrix of shape (n_samples, n_features) and \(\textbf{y}\) is a matrix of shape (n_samples, n_targets), the objective is to find the weights \(\textbf{w}\) and bias \(b\) that minimizes the loss function:
\[\mathrm{arg\,min}_{\mathbf{w}, b} P_\alpha(y - (\mathbf{x}\mathbf{w}^T + b))^\alpha\]- fit(X, y)#
- predict(X)#
- score(X, y, sample_weight=None)#
Return coefficient of determination on test data.
The coefficient of determination, \(R^2\), is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares
((y_true - y_pred)** 2).sum()and \(v\) is the total sum of squares((y_true - y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.Parameters#
- Xarray-like of shape (n_samples, n_features)
Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape
(n_samples, n_samples_fitted), wheren_samples_fittedis the number of samples used in the fitting for the estimator.- yarray-like of shape (n_samples,) or (n_samples, n_outputs)
True values for X.
- sample_weightarray-like of shape (n_samples,), default=None
Sample weights.
Returns#
- scorefloat
\(R^2\) of
self.predict(X)w.r.t. y.
Notes#
The \(R^2\) score used when calling
scoreon a regressor usesmultioutput='uniform_average'from version 0.23 to keep consistent with default value ofr2_score(). This influences thescoremethod of all the multioutput regressors (except forMultiOutputRegressor).
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') AlphaStableLinearRegressor#
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.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.
Parameters#
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter inscore.
Returns#
- selfobject
The updated object.
- class aub_htp.machine_learning.AlphaStablePCA(n_components: int = None, alpha: float = 1.0, *, shape_estimation_method: Literal['method1', 'method2', 'method3'] = 'method1')#
Bases:
TransformerMixin,BaseEstimator- components_: ndarray#
- fit(X, y=None)#
- fit_transform(X, y=None)#
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Parameters#
- Xarray-like of shape (n_samples, n_features)
Input samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None
Target values (None for unsupervised transformations).
- **fit_paramsdict
Additional fit parameters. Pass only if the estimator accepts additional params in its fit method.
Returns#
- X_newndarray array of shape (n_samples, n_features_new)
Transformed array.
- location_: ndarray#
- power_: ndarray#
- score(X, y=None)#
- shape_: ndarray#
- transform(X)#
- class aub_htp.machine_learning.AlphaStableShape(alpha: float = 1.0, alpha_kernel: float = None, alpha_data: float = None, method: Literal['method1', 'method2', 'method3'] = 'method1')#
Bases:
BaseEstimator- fit(X, y=None)#
- score(X, y=None)#
- aub_htp.machine_learning.l_alpha_loss(y, y_pred, *, alpha: float)#
- aub_htp.machine_learning.r_alpha_score(y, y_pred, *, alpha: float) float#