guide.GuideRegressor¶
- class guide.GuideRegressor(*, loss='squared_error', quantile=0.5, quantiles=(0.25, 0.75), node_model='constant', degree=2, stepwise_alpha=0.05, max_variables=None, backward=True, prediction_truncation='none', max_depth=10, min_samples_leaf=2, min_gain=1e-12, interactions=True, significance_level=0.1, max_split_candidates=100, pruning='cv', cv_folds=10, cv_standard_errors=0.25, ccp_alpha=0.0, max_leaves=None, categorical_features=None, feature_roles=None, periodic_features=None, missing_flags=None, n_jobs=None, random_state=0)¶
GUIDE regression tree.
- Parameters:
- loss{“squared_error”, “quantile”, “dual_quantile”, “poisson”, “logistic”}, default=”squared_error”
Node loss. Poisson accepts an
exposureinfitandpredict. Logistic fits a 0/1 response and predicts probabilities."dual_quantile"fits two quantiles at once andpredictreturns them as an array of shape (n_samples, 2).- quantilefloat, default=0.5
Quantile probability for
loss="quantile".- quantiles(float, float), default=(0.25, 0.75)
Lower and upper probabilities for
loss="dual_quantile".- node_model{“constant”, “linear”, “polynomial”, “stepwise”}, default=”constant”
Leaf model. Unless
feature_rolessays otherwise, these leaves regress on every numeric feature, and categorical features are used only for splitting."stepwise"is experimental: its variable selection does not fully match GUIDE.- degreeint, default=2
Polynomial degree for
node_model="polynomial".- stepwise_alphafloat, default=0.05
Entry and removal significance level for
node_model="stepwise".- max_variablesint, default=None
Most variables a stepwise leaf may use; None means no limit.
- backwardbool, default=True
Run backward elimination after forward selection in stepwise leaves.
- prediction_truncation{“none”, “node_range”, “node_range_expanded”, “global_range”}, default=”none”
Limits on predictions of linear least-squares leaves: the leaf’s training response range, that range widened by 10% at each end, or the whole training range (GUIDE’s default).
- max_depthint, default=10
- min_samples_leafint, default=2
- min_gainfloat, default=1e-12
Minimum loss reduction for a split.
- interactionsbool, default=True
Run pairwise interaction tests during variable selection.
- significance_levelfloat, default=0.1
- max_split_candidatesint, default=100
Cutpoints evaluated per numeric split; 0 evaluates all.
- pruning{“cv”, “cost_complexity”, “max_leaves”, “validation”, “none”}, default=”cv”
"validation"prunes on thevalidation_datapassed tofit.- cv_foldsint, default=10
- cv_standard_errorsfloat, default=0.25
Standard-error rule for cross-validation pruning.
- ccp_alphafloat, default=0.0
Complexity parameter for
pruning="cost_complexity".- max_leavesint, default=None
Leaf count for
pruning="max_leaves".- categorical_featuresarray-like of str, int or bool, default=None
Categorical columns. By default, object, string, categorical and boolean DataFrame columns are categorical and arrays are numeric.
- feature_rolesdict, default=None
Maps column names or indices to
"split"(splitting only),"fit"(leaf regressor only),"both"or"excluded", overriding the defaults described undernode_model.- periodic_featuresdict, default=None
Maps numeric column names or indices to their period, such as 24 for hour of day. Periodic features split into intervals that may wrap around and are used only for splitting.
- missing_flagsdict, default=None
Maps a categorical flag column to the column whose missing values it explains (GUIDE’s M variables), for example
{"income_reason": "income"}. Splits can then route each missing code separately. Requires constant leaves.- n_jobsint, default=None
Threads for cross-validation pruning, forest trees and importance permutations. Unlike most scikit-learn estimators, None uses all cores, as does -1; -2 uses all but one, and so on. Results do not depend on it.
- random_stateint, RandomState instance or None, default=0
Seed for cross-validation folds. Fits are deterministic by default.
Notes
With quantile losses, sample weights set each node’s quantile, but each row counts once when choosing splits, following GUIDE.
- __init__(*, loss='squared_error', quantile=0.5, quantiles=(0.25, 0.75), node_model='constant', degree=2, stepwise_alpha=0.05, max_variables=None, backward=True, prediction_truncation='none', max_depth=10, min_samples_leaf=2, min_gain=1e-12, interactions=True, significance_level=0.1, max_split_candidates=100, pruning='cv', cv_folds=10, cv_standard_errors=0.25, ccp_alpha=0.0, max_leaves=None, categorical_features=None, feature_roles=None, periodic_features=None, missing_flags=None, n_jobs=None, random_state=0)¶
Methods
__init__(*[, loss, quantile, quantiles, ...])apply(X)Terminal node id of each sample.
fit(X, y[, sample_weight, exposure, ...])Fit the model.
get_depth()Depth of the fitted tree; a single leaf has depth 0.
get_metadata_routing()Get metadata routing of this object.
get_n_leaves()Number of terminal nodes in the fitted tree.
get_params([deep])Get parameters for this estimator.
predict(X[, exposure])Predicted response; Poisson models fitted with exposure need it here too.
score(X, y[, sample_weight])Return coefficient of determination on test data.
set_fit_request(*[, exposure, ...])Configure whether metadata should be requested to be passed to the
fitmethod.set_params(**params)Set the parameters of this estimator.
set_predict_request(*[, exposure])Configure whether metadata should be requested to be passed to the
predictmethod.set_score_request(*[, sample_weight])Configure whether metadata should be requested to be passed to the
scoremethod.to_dot()The fitted model in Graphviz DOT format.
to_json()The fitted model in the format saved by the guide-rs CLI.
to_text()The fitted model as indented text.