【问题标题】:GridSearchCV Keeps Returning Smallest Alpha for Ridge RegressionGridSearchCV 不断返回用于岭回归的最小 Alpha
【发布时间】:2022-01-07 21:11:23
【问题描述】:

我正在尝试使用来自 moneypuck 的数据来预测 NHL 球员在给定赛季中的进球数。我不希望任何人看这个,但如果你想略读,这里是我从数据集中保留的(相当大量的)特征列表:

['team', 'position', 'games_played', 'icetime', 'shifts', 'gameScore', 'onIce_xGoalsPercentage', 'offIce_xGoalsPercentage', 'onIce_corsiPercentage', 'offIce_corsiPercentage', 'onIce_fenwickPercentage', 'offIce_fenwickPercentage', 'iceTimeRank', 'I_F_xOnGoal', 'I_F_xGoals', 'I_F_xRebounds', 'I_F_xFreeze', 'I_F_xPlayStopped', 'I_F_xPlayContinuedInZone', 'I_F_xPlayContinuedOutsideZone', 'I_F_flurryAdjustedxGoals', 'I_F_scoreVenueAdjustedxGoals', 'I_F_flurryScoreVenueAdjustedxGoals', 'I_F_shotsOnGoal', 'I_F_missedShots', 'I_F_blockedShotAttempts', 'I_F_shotAttempts', 'I_F_rebounds', 'I_F_freeze', 'I_F_playStopped', 'I_F_playContinuedInZone', 'I_F_playContinuedOutsideZone', 'penalties', 'I_F_penalityMinutes', 'I_F_faceOffsWon', 'I_F_hits', 'I_F_takeaways', 'I_F_giveaways', 'I_F_lowDangerShots', 'I_F_mediumDangerShots', 'I_F_highDangerShots', 'I_F_lowDangerxGoals', 'I_F_mediumDangerxGoals', 'I_F_highDangerxGoals', 'I_F_scoreAdjustedShotsAttempts', 'I_F_unblockedShotAttempts', 'I_F_scoreAdjustedUnblockedShotAttempts', 'I_F_dZoneGiveaways', 'I_F_xGoalsFromxReboundsOfShots', 'I_F_xGoalsFromActualReboundsOfShots', 'I_F_reboundxGoals', 'I_F_xGoals_with_earned_rebounds', 'I_F_xGoals_with_earned_rebounds_scoreAdjusted', 'I_F_xGoals_with_earned_rebounds_scoreFlurryAdjusted', 'I_F_shifts', 'I_F_oZoneShiftStarts', 'I_F_dZoneShiftStarts', 'I_F_neutralZoneShiftStarts', 'I_F_flyShiftStarts', 'I_F_oZoneShiftEnds', 'I_F_dZoneShiftEnds', 'I_F_neutralZoneShiftEnds', 'I_F_flyShiftEnds', 'faceoffsWon', 'faceoffsLost', 'timeOnBench', 'penalityMinutes', 'penalityMinutesDrawn', 'penaltiesDrawn', 'shotsBlockedByPlayer', 'OnIce_F_xOnGoal', 'OnIce_F_xGoals', 'OnIce_F_flurryAdjustedxGoals', 'OnIce_F_scoreVenueAdjustedxGoals', 'OnIce_F_flurryScoreVenueAdjustedxGoals', 'OnIce_F_shotsOnGoal', 'OnIce_F_missedShots', 'OnIce_F_blockedShotAttempts', 'OnIce_F_shotAttempts', 'OnIce_F_rebounds', 'OnIce_F_lowDangerShots', 'OnIce_F_mediumDangerShots', 'OnIce_F_highDangerShots', 'OnIce_F_lowDangerxGoals', 'OnIce_F_mediumDangerxGoals', 'OnIce_F_highDangerxGoals', 'OnIce_F_scoreAdjustedShotsAttempts', 'OnIce_F_unblockedShotAttempts', 'OnIce_F_scoreAdjustedUnblockedShotAttempts', 'OnIce_F_xGoalsFromxReboundsOfShots', 'OnIce_F_xGoalsFromActualReboundsOfShots', 'OnIce_F_reboundxGoals', 'OnIce_F_xGoals_with_earned_rebounds', 'OnIce_F_xGoals_with_earned_rebounds_scoreAdjusted', 'OnIce_F_xGoals_with_earned_rebounds_scoreFlurryAdjusted', 'OffIce_F_xGoals', 'OffIce_A_xGoals', 'OffIce_F_shotAttempts', 'OffIce_A_shotAttempts', 'xGoalsForAfterShifts', 'xGoalsAgainstAfterShifts', 'corsiForAfterShifts', 'corsiAgainstAfterShifts', 'fenwickForAfterShifts', 'fenwickAgainstAfterShifts']

(注:I_F_ 表示“个人为”,OneIce_F_ 表示“在冰上为”。小写“x”表示“预期”。)

我在团队中使用了一种热编码并使用列变换器定位特征,然后构建了一个管道,在应用列变换器后对所有特征应用标准缩放,最终进行岭回归。但是当尝试使用 GridSearchCV 在我的 Ridge 模型中调整 alpha 时,最好的交叉验证分数总是由我测试的最小 alpha 值给出。更奇怪的是,设置 alpha=0.01,该模型能够以平均绝对误差仅为 0.07 的方式猜测进球数,如果我们将预测值四舍五入,它可以准确预测每个球员的进球数。测试集。

这显然是无稽之谈,因为系数很大(我得到的数字是 433835277890.1854),但我不明白为什么。我没有在列表中看到任何可以“放弃”玩家为模型打进多少球的功能。为了 100% 确定这一点,我检查了 Ridge 学到的最大系数;它们是最大正系数和最大负系数的“OnIce_F_lowDangerShots”和“OnIce_F_shotsOnGoal”。所以没有什么可以透露球员进了多少球。

【问题讨论】:

  • 感谢金狮的推荐。我会试试看。然而,我仍然想了解 Ridge 的幕后情况。只是说我想不通感觉有点便宜,所以我将使用不同的模型。
  • 尝试 tpot 以找到解决问题的最佳分类器。具有大量特征的分类器可能很难找到。 tpot 发现最佳分类器,然后使用 randomgridsearch 调整参数。

标签: python machine-learning regression


【解决方案1】:
from tpot import TPOTClassifier

tpot=TPOTClassifier(generations=3, population_size=5, verbosity=2, offspring_size=10, scoring='accuracy', cv=5)
tpot.fit(X_train,y_train)

print(tpot.score(X_test,y_test))


generations: iterations to run training
population_size: the number of models to keep after each iteration
offspring_size: number of models to produce in each iteration
mutation_rate: the proportion of pipelines to apply randomness
crossover_rate: the proportion of pipelines to breed each iteration
scoring: the function to determine the best models
cv: cross-validation strategy to use


TPOT is quite unstable when only running with low generations, population size and offspring.

假设最好的分类器是 MLPClassifier

然后使用 GridSearch 调整参数

逐步细化

另一种调整参数的方法是使用逐步优化,并通过迭代尝试然后绘制结果来查看哪个参数组合提高了准确性。

预处理

您可以使用标准缩放器对数据进行归一化以消除噪声并使用简单的 imputer 来修复 nan。通过逻辑回归和分析特征的概率,找出是否可以删除任何特征。

【讨论】:

    猜你喜欢
    • 2018-02-02
    • 2018-09-29
    • 1970-01-01
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    • 2018-02-21
    • 2016-11-28
    • 2018-05-05
    相关资源
    最近更新 更多