set_params()
noun
say it: “SET puh-RAMZ” /ˈsɛt pəˈræmz/
In scikit-learn, the method that changes a model's settings by name.
What does set_params() do in scikit-learn?
set_params() changes a model's settings by name, such as tree.set_params(max_depth=5), and hands back the model.
On a pipeline, step__setting names reach inside a step, such as tree__max_depth. The new settings take effect at
the next fit().
from sklearn.tree import DecisionTreeClassifier
tree = DecisionTreeClassifier(max_depth=3)
tree.set_params(max_depth=5)
print(tree.max_depth) # 5
In a sentence
- “She called set_params() with knn__n_neighbors=7 to reach inside the pipeline.”
- “set_params() changed the tree's depth to 5 before the next fit().”
Level: Freelancer · More Python terms at this level
Updated