Skip to content

models

class Penalty(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: StrEnum, Enum

elasticnet = ‘elasticnet’

l1 = ‘l1’

l2 = ‘l2’

class ScoringMethod(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: StrEnum, Enum

accuracy = ‘accuracy’

adjusted_mutual_info_score = ‘adjusted_mutual_info_score’

adjusted_rand_score = ‘adjusted_rand_score’

average_precision = ‘average_precision’

balanced_accuracy = ‘balanced_accuracy’

completeness_score = ‘completeness_score’

d2_absolute_error_score = ‘d2_absolute_error_score’

d2_pinball_score = ‘d2_pinball_score’

d2_tweedie_score = ‘d2_tweedie_score’

explained_variance = ‘explained_variance’

f1 = ‘f1’

f1_macro = ‘f1_macro’

f1_micro = ‘f1_micro’

f1_samples = ‘f1_samples’

f1_weighted = ‘f1_weighted’

fowlkes_mallows_score = ‘fowlkes_mallows_score’

homogeneity_score = ‘homogeneity_score’

jaccard = ‘jaccard’

max_error = ‘max_error’

mutual_info_score = ‘mutual_info_score’

neg_brier_score = ‘neg_brier_score’

neg_log_loss = ‘neg_log_loss’

neg_mean_absolute_error = ‘neg_mean_absolute_error’

neg_mean_absolute_percentage_error = ‘neg_mean_absolute_percentage_error’

neg_mean_gamma_deviance = ‘neg_mean_gamma_deviance’

neg_mean_poisson_deviance = ‘neg_mean_poisson_deviance’

neg_mean_squared_error = ‘neg_mean_squared_error’

neg_mean_squared_log_error = ‘neg_mean_squared_log_error’

neg_median_absolute_error = ‘neg_median_absolute_error’

neg_root_mean_squared_error = ‘neg_root_mean_squared_error’

normalized_mutual_info_score = ‘normalized_mutual_info_score’

precision = ‘precision’

r2 = ‘r2’

rand_score = ‘rand_score’

recall = ‘recall’

roc_auc = ‘roc_auc’

roc_auc_ovo = ‘roc_auc_ovo’

roc_auc_ovo_weighted = ‘roc_auc_ovo_weighted’

roc_auc_ovr = ‘roc_auc_ovr’

roc_auc_ovr_weighted = ‘roc_auc_ovr_weighted’

top_k_accuracy = ‘top_k_accuracy’

v_measure_score = ‘v_measure_score’

class Solver(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: StrEnum, Enum

lbfgs = ‘lbfgs’

liblinear = ‘liblinear’

newton_cg = ‘newton-cg’

newton_cholesky = ‘newton-cholesky’

sag = ‘sag’

saga = ‘saga’

permutation_testing(estimator, X, Y, binary=False, nb_permutations=1000, scoring=‘r2’, splits=10, processes=1, verbose=False)

Function to perform permutation testing on a model.

Parameters

estimator : Model to use.

X : Dataframe containing the predictor variables.

Y : Dataframe containing the dependent variables.

binary : If the dependent variable is binary. Defaults to False.

nb_permutations : Number of iterations to perform. Defaults to 1000.

scoring : Scoring method to use. Defaults to ‘r2’.

splits : Number of fold to use in cross-validation. Defaults to 10.

processes : Number of cpus to use during processing. Defaults to 1.

verbose : Verbose mode. Defaults to False.

Returns

mod : Model.

score : Score for the model.

coef : Coefficients for the model.

perm_score : Scores for the permutation testing.

score_pvalue : P-value for the model.

perm_coef : Coefficients for the permutation testing.

coef_pvalue : P-value for the coefficients.

plsr_cv(X, Y, nb_comp, max_iter=1000, splits=10, processes=1, verbose=False)

Function to perform a PLSR model with cross-validation between a set of predictor and dependent variables.

Parameters

X : Dataframe containing the predictor variables.

Y : Dataframe containing the dependent variables.

nb_comp : Number of components to use.

max_iter : Maximum number of iterations. Defaults to 1000.

splits : Number of fold to use in cross-validation. Defaults to 10.

processes : Number of cpus to use during processing. Defaults to 1.

verbose : Verbose mode. Defaults to False.

Returns

plsr : PLSR model.

mse : List of mean squared errors.

score_c : R2 score for the model.

score_cv : R2 score for the cross-validation.

rscore : Square root of the R2 score.

mse_c : Mean squared error for the model.

mse_cv : Mean squared error for the cross-validation.