返回列表

24th Solution.

533. Playground Series - Season 3, Episode 5 | playground-series-s3e5

开始: 2023-01-31 结束: 2023-02-13 数据算法赛
第24名方案

第24名方案

作者: DavidHGuerrero | 比赛排名: 第24名

大家好,

祝贺本次比赛的获胜者!🙌

代码

提交链接: https://www.kaggle.com/code/davidhguerrero/drop-features-reduction-with-t-sne-model?scriptVersionId=119026084

概述

首先推荐阅读 ambrosm 的文章 Is this competition a lottery?(这场比赛是买彩票吗?)

对我来说,确实如此 😊

Score Screenshot

简单的解决方案:
堆叠算法并使用 Optuna 探索最佳的 K-Fold,不涉及算法的更多参数。聚合了原始数据集 + 合成数据集。
模型 A: LGBMClassifier
模型 B: CatBoostClassifier
模型 C: LGBMRegressorWithRounder

Model Diagram

使用 Optuna 训练许多快速模型(探索较少的参数)。

首先仅调整 random_state 和 k-Fold 的 n_splits

scores =[]

def find_out_parameters_model(trial):
    random_state = trial.suggest_int('random_state', 1000, 2000)
    n_splits = trial.suggest_int('n_splits', 8, 20)
    cv = StratifiedKFold(n_splits=n_splits, shuffle=True, random_state=conf.random)
    my_model = LGBMClassifier( 
        random_state = random_state
    )
    for fold, (train_idx, valid_idx) in enumerate(cv.split(X, y)):
        X_train, X_valid = X.iloc[train_idx], X.iloc[valid_idx]
        y_train , y_valid = y.iloc[train_idx] , y.iloc[valid_idx]
        my_model.fit(
            X_train, y_train,
            eval_set= [(X_valid,y_valid)],
            early_stopping_rounds = 50,
            verbose=0
        )
        
        preds_valid = my_model.predict(X_valid)
        score = cohen_kappa_score(y_valid,  preds_valid, weights = "quadratic")
        scores.append(score)
    return np.mean(scores)

这个类帮助我清理和组织 notebook 代码:

class conf:
    index = 'Id'
    target = 'quality'
    random = 2023
    
    load_original = True
    only_positive = False

    include_optuna = False
    
    include_lgbm = False
    include_catboost = False
    include_lgbm_regression = True
    n_trials = 10

np.random.seed(conf.random)

使用互信息测量变量之间的依赖关系,并添加/删除了一些 特征工程思路(感谢 Jose Cáliz)。
移除了模型 A 和 B。仅使用一个模型得分更好:LGBMRegressorWithRounder。将其他模型搁置一边。

集成最佳的 LGBMRegressorWithRounder

同比赛其他方案