【发布时间】:2021-11-24 00:48:35
【问题描述】:
我想在拟合前后检查 scikit-learn 模型的超参数值:
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
X, y = make_classification(n_samples=1000, n_features=4, n_informative=2, n_redundant=0)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
clf = RandomForestClassifier(random_state=0)
print(clf.get_params())
clf.fit(X_train, y_train)
print(clf.get_params())
它在模型拟合之前和之后给了我相同的值。我认为模型拟合后的超参数应该不同。我做错了吗?
另外,当我想使用模型进行预测时,模型用于预测的超参数是什么?
感谢您的帮助。
【问题讨论】:
标签: python scikit-learn hyperparameters model-fitting