【问题标题】:scikit learn random forest gives relative bad predictionscikit learn random forest 给出了相对不好的预测
【发布时间】:2015-10-23 13:05:54
【问题描述】:

我正在使用 scikit-learn 使用随机森林和随机树分类器来预测证券交易所方向。我的特征是像简单移动平均线这样的指标。我的问题是,对于具有默认参数的两种算法,我都得到了相对糟糕的预测(大约 50%)。我怎样才能提高这种准确性?代码如下:

    X = data_from_csv[['RSI', 'CCI', '5SMA', '10SMA', 'ROC', 'Momentum',  '%K', '%D']].astype(np.float32)
    y = data_from_csv['Direction1'].astype(np.float32)

    X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2)
    rf = RandomForestClassifier()
    rf.fit(X_train,y_train)
    y_pred = rf.predict(X_test)

    print metrics.accuracy_score(y_test, y_pred), 'train/test split random forest'

    X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2)
    rt = tree.DecisionTreeClassifier()
    rt.fit(X_train,y_train)
    y_pred = rt.predict(X_test)

    print metrics.accuracy_score(y_test, y_pred), 'train/test split decision tree'

【问题讨论】:

  • 不要使用默认参数,调整它们...... ML不是算法,你不能“只是运行”算法并期望它解决问题。
  • 我已经尝试从像 n_estimators 中设置参数以获取 10-200 范围内的值,但没有帮助
  • 10 折交叉验证也是,但结果没有改善
  • 提供一个最小可复现的例子(数据),否则没人能帮忙

标签: python-2.7 machine-learning scikit-learn


【解决方案1】:

最可能的情况是您的训练数据没有很好的预测价值。鉴于您正在尝试“预测股票交易方向”,这不足为奇,因为这个问题几乎无法解决。

【讨论】:

    猜你喜欢
    • 2023-03-21
    • 2014-06-27
    • 2014-08-04
    • 2017-04-25
    • 2016-07-30
    • 2018-01-09
    • 2013-05-31
    • 2019-01-08
    • 2015-11-02
    相关资源
    最近更新 更多