Jed Rembold
March 18, 2026
In both Python and R, we commonly need to select many feature columns, which can be cumbersome
Can select all “but one” fairly easily:
model.fit(
train_df.drop('label', axis=1),
train_df.label
)
model_fit <- model %>%
fit(label ~ . - label, data=train_df)ML models operate on iterative approaches toward some optimum
If they move slowly toward that optimum, you might need to allow for more iterations
model = LogisticRegression(max_iter=10000)
model <- multinom_reg() %>%
set_engine("nnet", maxit=10000)Can also try different solvers/engines
LogisticRegression(solver="newton-cg")
model <- multinom_reg() %>%
set_engine("glmnet", maxit=10000)You can construct your own arbitrary ensembles
In Python:
combo = VotingClassifier(
[
('logreg',log_mod), # first model
('dec_tree',tree) # second model
],
voting='soft')
combo.fit(training_df[['x','y']])A bit more complicated, but can be done in R with the
stacks library

random_state won’t always
generate a very different model
BaggingClassifierbaguette library

In Python, random forest models come from the Scikit-learn
ensemble module
from sklearn.ensemble import RandomForestClassifier
forest = RandomForestClassifier()In R, they are one of Parsnips available models
forest <- rand_forest(mode="classification")Fitting, computing confusion matrices, visualizing classification boundaries, etc. proceed exactly as they have for other models
n_estimators (default=100)max_features
max_depth,
max_leaf_nodes, etc.trees (default=100)mtry
min_n is the minimum number of points
still in a node to be split furtherwarm_start option lets you
resume from last training point