ResponseVariableRangeADChecker#
- class skfp.applicability_domain.ResponseVariableRangeADChecker(threshold: float | None = None, n_jobs: int | None = None, verbose: int | dict = 0)#
Response variable range method.
Defines applicability domain based on the range of response values observed in the training data [1]. New predictions are considered inside the applicability domain if they lie within the min-max range of training targets.
Typically, this method is used after model prediction, and checks whether predicted values lie within the known domain of the response variable.
Note that this method does not consider molecular structure or descriptors and operates purely in the output (target) space. It only supports one-dimensional (1D) target values. Passing multi-label targets will raise a
ValueError.This method scales extremely well with the number of samples, as it only operates in the 1D target space.
- Parameters:
threshold (float, default=None) – Maximum allowed distance from the training response mean. If float, defines a symmetric interval around the mean:
[mean - threshold, mean + threshold], and predictions outside this range are considered outside the applicability domain. IfNone(default), the method uses the full min–max range of training targets as bounds.n_jobs (int, default=None) – The number of jobs to run in parallel.
transform_x_y()andtransform()are parallelized over the input molecules.Nonemeans 1 unless in ajoblib.parallel_backendcontext.-1means using all processors. See scikit-learn documentation onn_jobsfor more details.verbose (int or dict, default=0) – Controls the verbosity when filtering molecules. If a dictionary is passed, it is treated as kwargs for
tqdm(), and can be used to control the progress bar.
References
Examples
>>> import numpy as np >>> from skfp.applicability_domain import ResponseVariableRangeADChecker >>> y_train = np.array([0.5, 1.2, 1.5, 0.9]) >>> y_pred = np.array([1.0, 1.6, 0.4]) >>> response_range_ad_checker = ResponseVariableRangeADChecker() >>> response_range_ad_checker ResponseVariableRangeADChecker()
>>> response_range_ad_checker.fit(y_train) ResponseVariableRangeADChecker()
>>> response_range_ad_checker.predict(y_pred) array([ True, False, False])
Methods
fit(y[, X])Fit applicability domain estimator.
fit_predict(X[, y])Perform fit on X and returns labels for X.
Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
predict(y)Predict labels (1 inside AD, 0 outside AD) of X according to the fitted model.
Calculate the applicability domain score of samples.
set_params(**params)Set the parameters of this estimator.
- fit(y: ndarray, X: ndarray | None = None)#
Fit applicability domain estimator.
- Parameters:
X (array-like of shape (n_samples, n_features)) – The input samples.
y (any) – Unused, kept for scikit-learn compatibility.
- Returns:
self – Fitted estimator.
- Return type:
object
- fit_predict(X, y=None, **kwargs)#
Perform fit on X and returns labels for X.
Returns -1 for outliers and 1 for inliers.
- Parameters:
X ({array-like, sparse matrix} of shape (n_samples, n_features)) – The input samples.
y (Ignored) – Not used, present for API consistency by convention.
**kwargs (dict) –
Arguments to be passed to
fit.Added in version 1.4.
- Returns:
y – 1 for inliers, -1 for outliers.
- Return type:
ndarray of shape (n_samples,)
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequestencapsulating routing information.- Return type:
MetadataRequest
- get_params(deep=True)#
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:
dict
- predict(y: ndarray) ndarray#
Predict labels (1 inside AD, 0 outside AD) of X according to the fitted model.
- Parameters:
X (array-like of shape (n_samples, n_features)) – The data matrix.
- Returns:
is_inside_applicability_domain – Returns 1 for molecules inside the applicability domain, and 0 for those outside (outliers).
- Return type:
ndarray of shape (n_samples,)
- score_samples(y: ndarray) ndarray#
Calculate the applicability domain score of samples. It is defined as the absolute distance of each predicted value from the training response mean. Lower scores indicate that a prediction is closer to the center of the training response distribution.
- Parameters:
y (array-like of shape (n_samples,)) – Predicted response values.
- Returns:
scores – Applicability domain scores of samples.
- Return type:
ndarray of shape (n_samples,)
- set_params(**params)#
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). 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:
estimator instance