python 过度拟合以及如何控制它

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 过度拟合以及如何控制它相关的知识,希望对你有一定的参考价值。

# Create a new array with the added features: features_two
features_two = train[["Pclass","Age","Sex","Fare", "SibSp", "Parch", "Embarked"]].values

#Control overfitting by setting "max_depth" to 10 and "min_samples_split" to 5 : my_tree_two
max_depth = 10
min_samples_split = 5
my_tree_two = tree.DecisionTreeClassifier(max_depth = 10, min_samples_split = 5, random_state = 1)
my_tree_two = my_tree_two.fit(features_two, target)

#Print the score of the new decison tree
print(my_tree_two.score(features_two, target))

以上是关于python 过度拟合以及如何控制它的主要内容,如果未能解决你的问题,请参考以下文章

K-Fold 如何防止模型中的过度拟合

python 检查过度拟合

机器学习中的过度拟合术语

如何测试过度拟合的随机森林回归模型?

在机器学习中过度拟合术语

如何使用 GridSearchCV 测试回归交叉验证中的过度拟合?