PValueDropRegressor

class pyoptex.analysis.estimators.p_value_drop_model.PValueDropRegressor(factors=(), Y2X=<function identityY2X>, random_effects=(), conditional=False, threshold=0.05, dependencies=None, mode=None)[source]

A regressor implementing the RegressionMixin and ConditionalRegressionMixin interfaces.

Permits to fit a simple model provided in Y2X with optionally random effects. Model selection from the model matrix is done by dropping terms one-by-one based on the highest p-value, higher than the threshold.

If desired, the model can force weak and strong heredity by setting the mode to ‘weak’ or ‘strong’ respectively, and providing a dependency matrix.

Note

It also includes all parameters and attributes from RegressionMixin and ConditionalRegressionMixin

Attributes

thresholdfloat

The p-value threshold, any term above is dropped (while adhering to the selected mode).

dependenciesnp.array(2d)

The dependency matrix of size (N, N) with N the number of terms in the encoded model (output from Y2X). Term i depends on term j if dep(i, j) = true.

modeNone, ‘weak’ or ‘strong’

The heredity mode to adhere to.

__init__(factors=(), Y2X=<function identityY2X>, random_effects=(), conditional=False, threshold=0.05, dependencies=None, mode=None)[source]

P-value based model selection regressor.

Parameters

factorslist(Factor)

A list of factors to be used during fitting. It contains the categorical encoding, continuous normalization, etc.

Y2Xfunc(Y)

The function to transform a design matrix Y to a model matrix X.

random_effectslist(str)

The names of any random effect columns. Every random effect is interpreted as a string column and encoded using effect encoding.

conditionalbool

Whether to create a conditional model or not.

thresholdfloat

The p-value threshold, any term above is dropped (while adhering to the selected mode).

dependenciesnp.array(2d)

The dependency matrix of size (N, N) with N the number of terms in the encoded model (output from Y2X). Term i depends on term j if dep(i, j) = true.

modeNone, ‘weak’ or ‘strong’

The heredity mode to adhere to.

Methods

PValueDropRegressor.fit(X, y)

Fits the data.

PValueDropRegressor.formula([labels])

Creates the prediction formula of the fit for the encoded and normalized data.

PValueDropRegressor.get_metadata_routing()

Get metadata routing of this object.

PValueDropRegressor.get_params([deep])

Get parameters for this estimator.

PValueDropRegressor.model_formula(model)

Creates the prediction formula of the fit for the encoded and normalized data.

PValueDropRegressor.pred_var(X)

Prediction variances for the new values specified in X.

PValueDropRegressor.predict(X)

Predict on new data after fitting.

PValueDropRegressor.preprocess_fit(X, y)

Preprocesses before fitting the data.

PValueDropRegressor.preprocess_predict(X)

Preprocessing the incoming data before prediction.

PValueDropRegressor.score(X, y[, sample_weight])

Return the coefficient of determination of the prediction.

PValueDropRegressor.set_params(**params)

Set the parameters of this estimator.

PValueDropRegressor.set_score_request(*[, ...])

Request metadata passed to the score method.

PValueDropRegressor.summary()

Generates a summary of the fit in case it was stored during training in the fit_ attribute.

Attributes

PValueDropRegressor.M_

Alias for information_matrix

PValueDropRegressor.Minv_

Alias for inv_information_matrix

PValueDropRegressor.V_

Alias for obs_cov

PValueDropRegressor.Vinv_

Alias for inv_obs_cov

PValueDropRegressor.information_matrix

The information matrix of the fitted data.

PValueDropRegressor.inv_information_matrix

The inverse of the information matrix.

PValueDropRegressor.inv_obs_cov

The inverse of the observation covariance matrix.

PValueDropRegressor.is_fitted

Checks whether the regressor has been fitted.

PValueDropRegressor.obs_cov

The observation covariance matrix \(V = var(Y)\).

PValueDropRegressor.total_var

The total variance on the normalized y-values.