对于不同的超参数配置sklearn RandomizedSearchCV,得分值完全相同

2024-09-27 21:29:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试为一个定制的无监督模型的sklearn管道寻找最佳的超参数配置,它将我的数据转换成向量表示,然后在随机森林分类器中用来预测标签。然而,当我使用Sklearn的随机搜索时,我经常得到不同的结果,因为所有分割的训练/测试分数完全相同,即使HP组合不同。在

enter image description here

令人困惑的是,当我在参数网格中只给出很少的值时(例如,对于n_估计值,只给出[1,10]而不是list(range(1,10)),这种情况就不会发生。在

我的网格如下所示:

param_grid = dict(n2vec__dim=list(range(16,266)),
              n2vec__p=[0.5,1,1.5,2],
              n2vec__path_length=list(range(1,26)),
              n2vec__num_paths=list(range(1,20)),
              n2vec__q=[0.5,1,1.5,2],
              randomforestclassifier__n_estimators=[5,10,20],
              randomforestclassifier__criterion=['gini','entropy'],
              randomforestclassifier__max_features=['auto',None,'log2'],
              randomforestclassifier__min_samples_split =[2,2,3,5,6,7,8,9],
              randomforestclassifier__min_samples_leaf =[1,5],
              randomforestclassifier__min_impurity_decrease =[0,1,20])


grid_search = RandomizedSearchCV(pipe, param_distributions=param_grid, n_iter=5, 
                             scoring='f1_micro',return_train_score=True, n_jobs=4) 

有人知道这是什么原因吗?在

任何帮助都将不胜感激。在


Tags: 数据模型网格参数管道paramrangesklearn

热门问题