我使用了三个分类器(RandomForestClassifier
,KNearestNeighborClassifier
和SVM Classifier
),如下所示:
>> svm_clf_sl_GSSVC(C=5, cache_size=200, class_weight=None, coef0=0.0, decision_function_shape='ovo', degree=3, gamma='auto', kernel='rbf', max_iter=-1, probability=True, random_state=41, shrinking=True, tol=0.001, verbose=False)>> knn_clf_sl_GSKNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski', metric_params=None, n_jobs=1, n_neighbors=3, p=2, weights='distance')>> for_clf_sl_GSRandomForestClassifier(bootstrap=True, class_weight=None, criterion='entropy', max_depth=None, max_features='auto', max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, min_samples_leaf=1, min_samples_split=2, min_weight_fraction_leaf=0.0, n_estimators=500, n_jobs=1, oob_score=False, random_state=None, verbose=0, warm_start=False)
在训练过程中,RandomForestClassifer
在数据预测上的f1_score
表现最佳,其次是KNearestNeighborClassifier
,然后是SVMClassifier
。这是我的X_train(如果需要,可以询问我是如何获得这些标准化值的)以及y_train:
>> X_trainarray([[-0.11034393, -0.72380296, 0.15254572, ..., 0.4166148 , -0.91095473, -0.91095295], [ 1.6817184 , 0.40040944, -0.6770607 , ..., -0.2403781 , 0.02962478, 0.02962424], [ 1.01128052, -0.21062032, -0.2460462 , ..., -0.04817728, -0.15848331, -0.15847739], ..., [-1.18666853, 0.87297522, 0.47136779, ..., -0.19599824, 0.72417473, 0.72416714], [ 1.6835304 , 0.40605067, -0.63383059, ..., -0.37094083, 0.09505496, 0.09505389], [ 0.19950709, -1.04624152, -0.18351693, ..., 0.4362658 , -0.77994791, -0.77994176]])>> y_train_sl874 01863 01493 0288 1260 0495 01529 01704 175 11792 0626 099 1222 0774 052 11688 11770 053 11814 0488 0230 0481 0132 1831 01166 11593 0771 01785 0616 0207 0 ..155 11506 0719 0547 0613 0652 01351 0304 01689 11693 11128 01323 0763 0701 0467 0917 0329 0375 01721 0928 01784 01200 0832 0986 01687 1643 0802 0280 11864 01045 0Name: Type of Formation_shaly limestone, Length: 1390, dtype: uint8
如你所见,我的y_train是以布尔形式存在的(即哪些实例是True
,哪些是False
)。
我想通过使用predict_proba
进一步提高预测的准确性,具体方法是:当我看到来自第一个分类器(比如RandomForestClassifier
)的预测对特定实例的置信水平较低(<60%)时(这是我首先需要找到的),它会转到下一个分类器(比如KNearestNeighborClassifier
),并检查这些实例在下一个分类器上的置信水平,如果它比前一个分类器的置信水平高(>60%),则接受该分类器的解决方案。同样,如果这个分类器在相同实例上的置信水平仍然较低(<60%),则转到第三个分类器并对第三个分类器执行相同的操作。
最后,如果第三个分类器的置信水平也较低(<60%),我需要接受在所有三个分类器中具有最高置信水平的分类器的解决方案。
由于我对机器学习还比较新手,可能有些说法会让你感到困惑,为此我表示歉意,请在我的错误之处进行纠正。
编辑:下方显示了X_test和y_test。我需要在X_test_prepared上进行预测,并使用f1_score
评估预测结果和y_test_sl。预测的y必须经过所有三个分类器,并对所有实例具有最佳的置信水平。
>> X_test_preparedarray([[ 0.69961751, -0.11156033, -0.43852312, ..., -0.40967982, 0.32099948, 0.32099952], [ 0.90256086, -0.54532856, -0.46399801, ..., -0.05752097, -0.54261829, -0.54261947], [ 1.67447042, 0.24530384, -1.0113221 , ..., -0.54844942, -0.26066608, -0.26066032], ..., [ 0.28104683, 1.52670909, 0.62653301, ..., -1.15596295, 2.05859487, 2.05859247], [ 1.50595496, 0.84507934, -0.44109634, ..., -0.71277072, 0.14474518, 0.14474398], [-1.63423112, -0.12690448, 0.48577783, ..., -0.36025459, 0.29137477, 0.29137047]])>> y_test_sl1321 01433 01859 01496 0492 0736 0996 01001 0634 01486 0910 01579 0373 01750 01563 01584 051 1349 01162 1594 01121 01637 01116 0106 11533 0993 0960 0277 0142 11010 0 ..1104 11404 01646 01009 061 1444 010 1704 0744 0418 0998 0740 0465 097 11550 11738 0978 0690 01071 01228 11539 0145 11015 01371 01758 0315 071 11090 01766 033 1Name: Type of Formation_shaly limestone, Length: 515, dtype: uint8
回答: