Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在RandomForestClassifier上执行GridSearchCV会产生较低的精度_Python_Scikit Learn_Random Forest - Fatal编程技术网

Python 在RandomForestClassifier上执行GridSearchCV会产生较低的精度

Python 在RandomForestClassifier上执行GridSearchCV会产生较低的精度,python,scikit-learn,random-forest,Python,Scikit Learn,Random Forest,我试图提高RandomForestClassifier的性能,该分类器使用GridSearchCV对负面评论和正面评论进行分类,但其准确率似乎总是比基本算法低10%左右。为什么会这样?请在下面找到我的代码: 90%准确率的基本算法: algo_base = RandomForestClassifier() algo_base.fit(X_train, y_train) param_grid = { 'criterion':['gini', 'entropy'], 'max_de

我试图提高RandomForestClassifier的性能,该分类器使用GridSearchCV对负面评论和正面评论进行分类,但其准确率似乎总是比基本算法低10%左右。为什么会这样?请在下面找到我的代码:

90%准确率的基本算法:

algo_base = RandomForestClassifier()
algo_base.fit(X_train, y_train)
param_grid = {
    'criterion':['gini', 'entropy'],
    'max_depth':[5, 10, 15],
    'n_estimators':[150, 200, 250, 300]
}

rfc = RandomForestClassifier(random_state=42)

CV_rfc = GridSearchCV(estimator = rfc, param_grid = param_grid, cv = 10, n_jobs=-1, verbose=4)

CV_rfc.fit(X_train, y_train)
精度为80%的GridSearchCV算法:

algo_base = RandomForestClassifier()
algo_base.fit(X_train, y_train)
param_grid = {
    'criterion':['gini', 'entropy'],
    'max_depth':[5, 10, 15],
    'n_estimators':[150, 200, 250, 300]
}

rfc = RandomForestClassifier(random_state=42)

CV_rfc = GridSearchCV(estimator = rfc, param_grid = param_grid, cv = 10, n_jobs=-1, verbose=4)

CV_rfc.fit(X_train, y_train)

基线模型的默认值与网格搜索中给出的值不同。 例如,n_估计量的默认值是100。
看一看

您尚未包含已修复的链接,可能是由于您指定了10倍交叉验证,因此数据量不正确。请尝试更改它并查看结果。