Machine learning 这是不是太合适了?或者发生了什么?

Machine learning 这是不是太合适了?或者发生了什么?,machine-learning,scikit-learn,Machine Learning,Scikit Learn,该数据如下: square AP-00 AP-01 AP-02 AP-03 AP-04 AP-05 AP-06 AP-07 AP-08 s-01 -30 -28 -40 -44 -62 -60 -78 -60 -62 s-01 -30 -52 -38 -44 -62 -60 -78 -60 -68 s-01 -30 -17

该数据如下:

square  AP-00  AP-01  AP-02   AP-03  AP-04  AP-05  AP-06   AP-07  AP-08    
s-01     -30   -28    -40     -44    -62    -60    -78     -60    -62   
s-01     -30   -52    -38     -44    -62    -60    -78     -60    -68   
s-01     -30   -17    -36     -40    -62    -58    -66     -60    -68   
s-01     -28   -19    -36     -36    -62    -56    -36     -52    -68   
s-01     -28   -17    -36     -40    -54    -56    -36     -52    -64 
...      ...   ...    ...     ...    ...    ...    ...     ...    ...   
-数据形状:15071行×10列 -目标y是一个方柱 -特征X为AP-00 AP-01 AP-02 AP-03 AP-04 AP-05 AP-06 AP-07 AP-08

值为Xs是RSSI值,这取决于收集的RSSI值,应将其分类为所需的平方 方柱为多级s-01、s-02、s-03

我给它配上了随机森林分类器

clf = RandomForestClassifier()
x_train,x_test,y_train,y_test = train_test_split(X,y,test_size = 0.30,random_state = 42)
clf.fit(x_train,y_train)
y_hat = clf.predict(x_test)
accuracy_score(y_hat,y_test)
0.9838746309334545

-注意:数据是平衡的,所以我认为它是过度拟合的

我决定做一个交叉验证:X_-train和Y_-train

model = RandomForestClassifier()
scores1 = cross_val_score(model,x_train,y_train, cv = 5)
print(scores1)
array([0.98199513, 0.98199513, 0.98442822, 0.97955209, 0.98344693])
再次进行X_测试和Y_测试:

scores2 = cross_val_score(model,x_test,y_test, cv = 10)
print(scores2)
array([0.98637911, 0.97048808, 0.97616345, 0.975     , 0.96931818])
那么,这是否意味着我的模型没有过度拟合?或者你能解释发生了什么?它能在没有任何超参数调整的情况下提供这种精度吗

您没有过度装修,因此您的模型是正确的

正如你们所说的,若你们在火车和测试数据之间获得了相似的精度值,你们并没有过度拟合。也许你的问题是很容易解决与这些功能幸运哈哈

我建议您绘制哪些功能对您的模型最重要,这将有助于您进一步了解哪些功能使您能够实现这些高精度:

feat_importances = pd.Series(clf.feature_importances_, index=X.columns)
feat_importances.nlargest(10).plot(kind='barh')

此外,是的,您可以在不调整超参数的情况下获得如此高的精度。默认的hyperparameters通常工作得很好,显然,通过更改一些字段,可以稍微提高精度。调整hyperparameters对于避免过度拟合非常有用,但这不是您的情况。

过度拟合意味着,尽管您的模型在验证集表现良好,但在测试集中表现不佳。我看你的准确度和打印分数结果没有任何问题。你可以说你的模型不太合适。@Ahx-aha现在我知道了,谢谢!!