代码之家  ›  专栏  ›  技术社区  ›  Outcast

网格搜索后改善不大

  •  0
  • Outcast  · 技术社区  · 8 年前

    # Instantiate random forest
    from sklearn.ensemble import RandomForestClassifier
    random_forest = RandomForestClassifier()
    
    # K-Fold Cross Validation (for grid search)
    inner_cross_validator = StratifiedKFold(n_splits=k_fold, shuffle=True)
    
    
    from sklearn.model_selection import GridSearchCV
    
    # Define parameters for grid search
    number_of_trees = {'n_estimators': [100, 300, 500]}
    max_features_per_tree = {'max_features': [0.2, 0.5, 0.8]}
    min_samples_split_per_node = {'min_samples_split': [0.2, 0.5, 0.8]}
    parameters = {**number_of_trees, **max_features_per_tree, **min_samples_split_per_node}
    
    # Execute grid search and retrieve the best classifier
    best_random_forest = GridSearchCV(estimator=random_forest, param_grid=parameters, scoring='average_precision', cv=inner_cross_validator, n_jobs=3)
    best_random_forest.fit(X_train, y_train)
    

    然而,网格搜索后的查全率和查全率几乎没有提高。

    一般来说,在我过去处理其他数据集的经验中,我没有注意到在网格搜索之后,与SkLearn这样的库的默认值相比,在各种度量的得分上有超过5%或很少有10%的改进。

    我能做些什么(在特征工程阶段之后)来显著提高我的分类模型的性能吗?

    1 回复  |  直到 8 年前
        1
  •  2
  •   amanbirs    8 年前

    除了特性工程(有很大的性能提升空间)之外,您可以尝试:

    1. 随机搜索:在定义的范围内搜索随机选择的超参数值。这应该 http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.RandomizedSearchCV.html

    2. 使用不同的算法:您当前正在使用RandomForest。这是一种非常有效的方法,可以减少预测的方差,并略微提高性能。但是,其他方法,如梯度增强,应该给你更好的性能。

    3. 不同算法的集成:这是一个非常广泛的主题,涵盖了许多不同的方法来组合模型以提高性能。 https://www.analyticsvidhya.com/blog/2018/06/comprehensive-guide-for-ensemble-models/