【问题标题】:Numerical prediction using Machine learning [closed]使用机器学习进行数值预测
【发布时间】:2017-05-03 12:20:39
【问题描述】:

我从幼稚的数值预测开始。这是训练数据

https://gist.github.com/karimkhanp/75d6d5f9c4fbaaaaffe8258073d00a75

测试数据

https://gist.github.com/karimkhanp/0f93ecf5fe8ec5fccc8a7f360a6c3950

我编写了基本的 scikit learn 代码来训练和测试。

import pandas as pd
import pylab as pl
from sklearn import datasets
from sklearn import metrics, linear_model
from sklearn.linear_model import LogisticRegression, LinearRegression, BayesianRidge, OrthogonalMatchingPursuitCV, SGDRegressor
from datetime import datetime, date, timedelta

class NumericPrediction(object):
    def __init__(self):
        pass
    def dataPrediction(self):
        Train = pd.read_csv("data_scientist_assignment.tsv", sep='\t', parse_dates=['date'])
        Train_visualize = Train
        Train['timestamp'] = Train.date.values.astype(pd.np.int64)
        Train_visualize['date'] = Train['timestamp']
        print Train.describe()
        x1=["timestamp", "hr_of_day"]
        test=pd.read_csv("test.tsv", sep='\t', parse_dates=['date'])
        test['timestamp'] = test.date.values.astype(pd.np.int64)
        model = LinearRegression()
        model.fit(Train[x1], Train["vals"])
        # print(model)
        # print model.score(Train[x1], Train["vals"])
        print model.predict(test[x1])

        Train.hist()
        pl.show()

if __name__ == '__main__':
    NumericPrediction().dataPrediction()

但是这里的准确率非常低。因为做法很幼稚。有什么更好的建议来提高准确性(在算法、示例、参考、库方面)?

【问题讨论】:

    标签: python machine-learning statistics neural-network classification


    【解决方案1】:

    首先,您的“测试”集看起来不正确。请检查一下。

    其次,你的模型注定要失败。绘制你的数据——你看到了什么?显然,我们这里有一个季节性,而线性回归假设观察是独立的。请务必注意,您在这里处理的是时间序列

    R 语言在时间序列方面非常出色,具有用于时间序列预测的高级软件包,例如 bsts。尽管如此,这里的 Python 还是一样好。 Pandas 模块会很好地为您服务。请注意,您可能不必在这里使用机器学习。检查 ARMAARIMABayesian structural time series 也很棒。

    Here 是一篇非常好的文章,它指导您了解处理时间序列数据的基础知识。

    【讨论】:

      猜你喜欢
      • 2012-11-16
      • 2012-05-30
      • 2017-06-05
      • 1970-01-01
      • 1970-01-01
      • 2017-04-21
      • 1970-01-01
      • 1970-01-01
      • 2020-10-07
      相关资源
      最近更新 更多