asaplib.fit package¶
Submodules¶
asaplib.fit.base module¶
Base class for regressions
-
class
asaplib.fit.base.
RegressorBase
[source]¶ Bases:
sklearn.base.BaseEstimator
,sklearn.base.RegressorMixin
Base class for regressions contains generic methods for computing errors
-
fit_predict
(X, y, X_test)[source]¶ Train the ridge regression model with the design matrix and trainLabel. :param X: :type X: array-like, shape=[n_descriptors, n_samples] :param Input points.: :param y: :type y: array-like, shape=[n_samples] :param Input points.: :param X_test: :type X_test: array-like, shape=[n_descriptors, n_test_samples] :param Input points.:
-
fit_predict_error
(X, y, X_test, y_test)[source]¶ Train the ridge regression model with the design matrix and trainLabel. and does prediction on test samples, and compute the error :param X: :type X: array-like, shape=[n_descriptors, n_samples] :param Input points.: :param y: :type y: array-like, shape=[n_samples] :param Input points.: :param X_test: :type X_test: array-like, shape=[n_descriptors, n_test_samples] :param Input points.:
-
get_params
(deep=True)[source]¶ Get parameters for this estimator.
- Parameters
deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
params – Parameter names mapped to their values.
- Return type
mapping of string to any
-
get_train_test_error
(X_train, y_train, X_test, y_test, verbose=True, return_pred=True)[source]¶ train the model, and get the test error
-
predict_error
(X, y)[source]¶ compute the score of the predictions compared with the true values :param X: :type X: array-like, shape=[n_descriptors, n_samples] :param Input points.: :param y: :type y: array-like, shape=[n_samples] :param Input points.:
-
set_params
(deep=True)[source]¶ Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
**params (dict) – Estimator parameters.
- Returns
self – Estimator instance.
- Return type
object
-
asaplib.fit.getscore module¶
Functions for assessing the quality of the fits
asaplib.fit.krr module¶
NOTE: These methods operate directly on the kernel matrix!!! some functions are adapted from Felix Musil’s ml_tools
-
class
asaplib.fit.krr.
KRR
(jitter)[source]¶ Bases:
asaplib.fit.base.RegressorBase
-
get_params
(deep=True)[source]¶ Get parameters for this estimator.
- Parameters
deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
params – Parameter names mapped to their values.
- Return type
mapping of string to any
-
predict_uncertainty
(k, delta)[source]¶ k.shape is expected as (nPred, nTrain), delta is the variance of y
-
set_params
(params, deep=True)[source]¶ Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
**params (dict) – Estimator parameters.
- Returns
self – Estimator instance.
- Return type
object
-
-
class
asaplib.fit.krr.
KRRFastCV
(jitter, delta, cv)[source]¶ Bases:
asaplib.fit.base.RegressorBase
taken from: An, S., Liu, W., & Venkatesh, S. (2007). Fast cross-validation algorithms for least squares support vector machine and kernel ridge regression. Pattern Recognition, 40(8), 2154-2162. https://doi.org/10.1016/j.patcog.2006.12.015
-
get_params
(deep=True)[source]¶ Get parameters for this estimator.
- Parameters
deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
params – Parameter names mapped to their values.
- Return type
mapping of string to any
-
set_params
(params, deep=True)[source]¶ Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
**params (dict) – Estimator parameters.
- Returns
self – Estimator instance.
- Return type
object
-
-
class
asaplib.fit.krr.
KRRSparse
(jitter, delta, sigma)[source]¶ Bases:
asaplib.fit.base.RegressorBase
-
fit_predict
(kMM, kNM, y, kNM_test)[source]¶ Train the ridge regression model with the design matrix and trainLabel. :param X: :type X: array-like, shape=[n_descriptors, n_samples] :param Input points.: :param y: :type y: array-like, shape=[n_samples] :param Input points.: :param X_test: :type X_test: array-like, shape=[n_descriptors, n_test_samples] :param Input points.:
-
fit_predict_error
(kMM, kNM, y, kNM_test, y_test)[source]¶ Train the ridge regression model with the design matrix and trainLabel. and does prediction on test samples, and compute the error :param X: :type X: array-like, shape=[n_descriptors, n_samples] :param Input points.: :param y: :type y: array-like, shape=[n_samples] :param Input points.: :param X_test: :type X_test: array-like, shape=[n_descriptors, n_test_samples] :param Input points.:
-
get_params
(deep=True)[source]¶ Get parameters for this estimator.
- Parameters
deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
params – Parameter names mapped to their values.
- Return type
mapping of string to any
-
predict
(kNM)[source]¶ kNM: the kernel matrix between the representative and the new structures with shape (N,M)
-
set_params
(params, deep=True)[source]¶ Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
**params (dict) – Estimator parameters.
- Returns
self – Estimator instance.
- Return type
object
-
asaplib.fit.ridgeregression module¶
-
class
asaplib.fit.ridgeregression.
RidgeRegression
(jitter)[source]¶ Bases:
asaplib.fit.base.RegressorBase
-
fit
(X, y)[source]¶ Train the ridge regression model with the design matrix and trainLabel. :param X: :type X: array-like, shape=[n_descriptors, n_samples] :param Input points.: :param y: :type y: array-like, shape=[n_samples] :param Input points.:
-
get_params
(deep=True)[source]¶ Get parameters for this estimator.
- Parameters
deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
params – Parameter names mapped to their values.
- Return type
mapping of string to any
-
set_params
(params, deep=True)[source]¶ Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
**params (dict) – Estimator parameters.
- Returns
self – Estimator instance.
- Return type
object
-
asaplib.fit.sparse_krr_wrapper module¶
Tools for performing sparse kernel ridge regression of design matrices using sparse KRR NOTE: this class operate directly on design matrices. for methods handingly kmatrix, see ./krr.py
-
class
asaplib.fit.sparse_krr_wrapper.
SPARSE_KRR_Wrapper
(kernel, krr_obj, sparse_mode='fps', n_sparse=None)[source]¶ Bases:
asaplib.fit.base.RegressorBase
-
fit
(X, y)[source]¶ Train the krr model with the design matrix and trainLabel. :param X: :type X: array-like, shape=[n_descriptors, n_samples] :param Input points.: :param y: :type y: array-like, shape=[n_samples] :param Input points.:
-
get_params
(deep=True)[source]¶ Get parameters for this estimator.
- Parameters
deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
params – Parameter names mapped to their values.
- Return type
mapping of string to any
-
set_params
(params, deep=True)[source]¶ Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
**params (dict) – Estimator parameters.
- Returns
self – Estimator instance.
- Return type
object
-