A random forest or a histogram gradient boosting fitted to records (scikit-learn's RandomForestClassifier and HistGradientBoostingClassifier for classes, their regressors for values, the same trees): the rows of a table, or the cells of maps (the predictors a stack, the target a map; a sample of the cells, drawn as numpy's default_rng(seed) draws it). Its predictors' importances: a forest's mean decrease of impurity, a boosting's share of the gain of its splits.
Input
Type
What it is
table
table
the records: the predictors and the target, a column each
predictors
stack
or maps: a layer per predictor (stack.of)
target
map
with maps: the classes or values to learn
cells
map
with maps: the cells to learn from (non-zero; default all)
Output
Type
What it is
model
ml_model
the fitted forest
importance
table
the importance of each predictor (they add up to 1)
Setting
Type
What it is
column
text
with a table: the target's column (default target)
columns
any
with a table: the predictors' columns (default: all but the target's)
task
text
classes or values; auto (default): classes when the target holds 50 whole numbers or fewer
sample
number
the records to learn from: a number (1 or more) or a share (below 1) drawn at random (default all)
stratify
bool
draw the sample from each class apart (default false)
seed
integer
the seed of the sample's draw (numpy's; default 1)
method
text
random_forest (default; scikit-learn's RandomForest) or gradient_boosting (its HistGradientBoosting, without early stopping)
n_estimators
integer
random_forest: the trees (default 100)
max_depth
integer
the trees' depth at most (default none)
min_samples_split
integer
random_forest: the records a node needs to split (default 2)
min_samples_leaf
integer
the records of a leaf at least (default: 1 for a forest, 20 for boosting)
max_features
any
the predictors tried at each split: sqrt, log2, all, a number or a share (default: sqrt for classes, all for values, as scikit-learn); gradient_boosting: a share (default 1)
bootstrap
bool
random_forest: each tree on a bootstrap (default true)
learning_rate
number
gradient_boosting: the shrinkage of the leaves (0.1)
max_iter
integer
gradient_boosting: the iterations (100)
max_leaf_nodes
integer
gradient_boosting: the leaves of a tree at most (31; null for no limit)
l2_regularization
number
gradient_boosting: the leaves' L2 penalty (0)
max_bins
integer
gradient_boosting: the bins of a predictor, 2-255 (255)
The permutation importance of each predictor of a fitted model (scikit-learn's permutation_importance, the same numbers): how much its score (a classifier's accuracy, a regressor's R²) drops when the predictor's values are shuffled among the records, shuffle after shuffle (numpy's RandomState); best on records the model did not learn from.
Input
Type
What it is
modelrequired
ml_model
the fitted model (ml.fit)
tablerequired
table
the records: the predictors and the target, a column each
Output
Type
What it is
importance
table
the mean drop of the score, a column per predictor
sd
table
its standard deviation over the shuffles
repeats
table
the drop at every shuffle: repeat, then a column per predictor
How a fitted model's prediction follows a predictor (scikit-learn's partial_dependence, its brute method): every record with the predictor set to each value of a grid (its distinct values when fewer than the grid's resolution, else from one percentile of it to another, as scipy's mquantiles), the predictions averaged: the value of a regressor, the probability of each class of a classifier (the second of two).
Input
Type
What it is
modelrequired
ml_model
the fitted model (ml.fit)
tablerequired
table
the records, a column per predictor
Output
Type
What it is
table
table
a row per value of the grid: the predictor's value, then the mean prediction (value, or p_)
The potential of each class from a model per class (landschaft's Estimator with scikit-learn's RandomForestClassifier, or HistGradientBoostingClassifier, the same maps): where each class is (presence, as lulcc's models), or where it appeared between two maps among the cells without it (expansion: PLUS's land expansion analysis, LEAS, the growth probability CARS takes); with each driver's contribution (the models' importances).
Input
Type
What it is
landscaperequired
map
the map at the start
later
map
the later map (expansion)
driversrequired
stack
the explanatory variables, a layer each
cells
map
the cells to learn from (non-zero; default all)
Output
Type
What it is
potential
stack
the probability of each class (of its presence, or of its expansion), where the drivers have values
importance
table
a row per class: class, then each driver's contribution (they add up to 1)
model
ml_model
the forests, for ml.predict on other drivers
Setting
Type
What it is
target
text
expansion (where the class appeared; needs the later map) or presence (where it is); default: expansion with a later map, else presence
classes
any
the classes to model (default: those of the maps)
sample
number
the cells each class's forest learns from: a number (1 or more) or a share (below 1) drawn at random (default all)
stratify
bool
draw the sample from the presences and the absences apart, in their proportions (default false)
balance
bool
as many absences as presences (default false)
seed
integer
the seed of the draws (numpy's default_rng; default 1)
method
text
random_forest (default; scikit-learn's RandomForest) or gradient_boosting (its HistGradientBoosting, without early stopping)
n_estimators
integer
random_forest: the trees (default 100)
max_depth
integer
the trees' depth at most (default none)
min_samples_split
integer
random_forest: the records a node needs to split (default 2)
min_samples_leaf
integer
the records of a leaf at least (default: 1 for a forest, 20 for boosting)
max_features
any
the predictors tried at each split: sqrt, log2, all, a number or a share (default: sqrt for classes, all for values, as scikit-learn); gradient_boosting: a share (default 1)
bootstrap
bool
random_forest: each tree on a bootstrap (default true)
learning_rate
number
gradient_boosting: the shrinkage of the leaves (0.1)
max_iter
integer
gradient_boosting: the iterations (100)
max_leaf_nodes
integer
gradient_boosting: the leaves of a tree at most (31; null for no limit)
l2_regularization
number
gradient_boosting: the leaves' L2 penalty (0)
max_bins
integer
gradient_boosting: the bins of a predictor, 2-255 (255)
A fitted model (ml.fit, ml.potential) on maps or on the rows of a table: the value, or the class of the largest probability (the first on ties, as scikit-learn's predict) and the probability of each class (a forest's predict_proba, or each class's potential). No value where a predictor has none.
Input
Type
What it is
modelrequired
ml_model
the fitted model
predictors
stack
maps: a layer per predictor, named as in the fit
table
table
or the rows of a table, a column per predictor
Output
Type
What it is
map
map
with maps: the value, or the class of the largest probability
probability
stack
with maps: the probability of each class
table
table
with a table: its columns, then prediction and the probability of each class (p_)
Esc
Try MSPA, least cost, weights of evidence or coordinator.