chemicalchecker.tool.targetmate.nonconformist.nc.RegressorNc

class RegressorNc(model, err_func=<chemicalchecker.tool.targetmate.nonconformist.nc.AbsErrorErrFunc object>, normalizer=None, beta=0)[source]

Bases: BaseModelNc

Nonconformity scorer using an underlying regression model.

Parameters

modelRegressorAdapter

Underlying regression model used for calculating nonconformity scores.

err_funcRegressionErrFunc

Error function object.

normalizerBaseScorer

Normalization model.

betafloat

Normalization smoothing parameter. As the beta-value increases, the normalized nonconformity function approaches a non-normalized equivalent.

Attributes

modelRegressorAdapter

Underlying model object.

err_funcRegressionErrFunc

Scorer function used to calculate nonconformity scores.

See also

ProbEstClassifierNc, NormalizedRegressorNc

Methods

fit

Fits the underlying model of the nonconformity scorer.

get_params

Get parameters for this estimator.

predict

Constructs prediction intervals for a set of test examples.

score

Calculates the nonconformity score of a set of samples.

set_params

Set the parameters of this estimator.

fit(x, y)

Fits the underlying model of the nonconformity scorer.

Parameters

xnumpy array of shape [n_samples, n_features]

Inputs of examples for fitting the underlying model.

ynumpy array of shape [n_samples]

Outputs of examples for fitting the underlying model.

Returns

None

get_params(deep=True)

Get parameters for this estimator.

Parameters

deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns

paramsdict

Parameter names mapped to their values.

predict(x, nc, significance=None)[source]

Constructs prediction intervals for a set of test examples.

Predicts the output of each test pattern using the underlying model, and applies the (partial) inverse nonconformity function to each prediction, resulting in a prediction interval for each test pattern.

Parameters

xnumpy array of shape [n_samples, n_features]

Inputs of patters for which to predict output values.

significancefloat

Significance level (maximum allowed error rate) of predictions. Should be a float between 0 and 1. If None, then intervals for all significance levels (0.01, 0.02, …, 0.99) are output in a 3d-matrix.

Returns

pnumpy array of shape [n_samples, 2] or [n_samples, 2, 99]

If significance is None, then p contains the interval (minimum and maximum boundaries) for each test pattern, and each significance level (0.01, 0.02, …, 0.99). If significance is a float between 0 and 1, then p contains the prediction intervals (minimum and maximum boundaries) for the set of test patterns at the chosen significance level.

score(x, y=None)

Calculates the nonconformity score of a set of samples.

Parameters

xnumpy array of shape [n_samples, n_features]

Inputs of examples for which to calculate a nonconformity score.

ynumpy array of shape [n_samples]

Outputs of examples for which to calculate a nonconformity score.

Returns

ncnumpy array of shape [n_samples]

Nonconformity scores of 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

**paramsdict

Estimator parameters.

Returns

selfestimator instance

Estimator instance.