module mlmodel.interval_regressor
¶
Short summary¶
module mlinsights.mlmodel.interval_regressor
Implements a piecewise linear regression.
Classes¶
class 
truncated documentation 

Trains multiple regressors to provide a confidence interval on prediction. It only works for single regression. … 
Properties¶
property 
truncated documentation 

Returns the number of estimators = the number of buckets the data was split in. 
Methods¶
method 
truncated documentation 

Trains the binner and an estimator on every bucket. Parameters ——— X: features, … 

Computes the average predictions. Parameters ——— X: features, X is converted into an array … 

Computes the predictions for all estimators. Parameters ——— X: features, X is converted … 

Computes the predictions for all estimators. Sorts them for all observations. Parameters ——— … 
Documentation¶
Implements a piecewise linear regression.

class
mlinsights.mlmodel.interval_regressor.
IntervalRegressor
(estimator=None, n_estimators=10, n_jobs=None, alpha=1.0, verbose=False)[source]¶ Bases:
sklearn.base.BaseEstimator
,sklearn.base.RegressorMixin
Trains multiple regressors to provide a confidence interval on prediction. It only works for single regression. Every training is made with a new sample of the training data, parameter alpha let the user choose the size of this sample. A smaller alpha increases the variance of the predictions. The current implementation draws sample by random but keeps the weight associated to each of them. Another way could be to draw a weighted sample but give them uniform weights.
 Parameters
estimator – predictor trained on every bucket
n_estimators – number of estimators to train
n_jobs – number of parallel jobs (for training and predicting)
alpha – proportion of samples resampled for each training
verbose – boolean or use
'tqdm'
to use tqdm to fit the estimators

__init__
(estimator=None, n_estimators=10, n_jobs=None, alpha=1.0, verbose=False)[source]¶  Parameters
estimator – predictor trained on every bucket
n_estimators – number of estimators to train
n_jobs – number of parallel jobs (for training and predicting)
alpha – proportion of samples resampled for each training
verbose – boolean or use
'tqdm'
to use tqdm to fit the estimators

fit
(X, y, sample_weight=None)[source]¶ Trains the binner and an estimator on every bucket.
 Parameters
X (features, X is converted into an array if X is a dataframe) –
y (target) –
sample_weight (sample weights) –
 Returns
self
 Return type
returns an instance of self.

binner_
¶  Type
binner

estimators_
¶ mapped to a leave to the tree
 Type
dictionary of estimators, each of them

mean_estimator_
¶ datasets in case the binner can find a bucket for a new observation
 Type
estimator trained on the whole

dim_
¶  Type
dimension of the output

mean_
¶  Type
average targets

property
n_estimators_
¶ Returns the number of estimators = the number of buckets the data was split in.

predict
(X)[source]¶ Computes the average predictions.
 Parameters
X (features, X is converted into an array if X is a dataframe) –
 Returns
 Return type
predictions

predict_all
(X)[source]¶ Computes the predictions for all estimators.
 Parameters
X (features, X is converted into an array if X is a dataframe) –
 Returns
 Return type
predictions