【问题标题】:What data should I use on predicting month values using linear regression我应该使用哪些数据来使用线性回归预测月份值
【发布时间】:2023-02-07 22:01:59
【问题描述】:

使用线性回归预测下个月的值。 我使用基于 6 个月的历史值来预测未来值。 我对因变量使用疫苗接种计数,对自变量使用月份,并将其转换为从 1 开始的整数。

例子。

历史数据:

月份因变量自变量 6月15日 1 7 月 14 日 2 8 月 18 日 3 9 月 19 日 4 10 月 20 日 5 11 月 22 日 6 日

那是对的吗?

因变量 = 接种疫苗的人数 自变量=月份转换为从1开始的数字

如果我的数据正确,希望给我一些想法

See picture below.

【问题讨论】:

    标签: linear-regression forecasting


    【解决方案1】:

    Python 简单线性回归:

    Hardcover
    Date    
    2000-04-01  139
    2000-04-02  128
    2000-04-03  172
    2000-04-04  139
    2000-04-05  191
    
    
    df['Time'] = np.arange(len(df.index))
    
    
              Hardcover     Time
      Date      
    2000-04-01  139       0
    2000-04-02  128       1
    2000-04-03  172       2
    2000-04-04  139       3
    2000-04-05  191       4
    
    fig, ax = plt.subplots()
    ax.plot('Time', 'Hardcover', data=df, color='0.75')
    ax = sns.regplot(x='Time', y='Hardcover', data=df, ci=None, scatter_kws=dict(color='0.25'))
    ax.set_title('Time Plot of Hardcover Sales');
    

    【讨论】:

      猜你喜欢
      • 2019-02-01
      • 2020-06-16
      • 1970-01-01
      • 1970-01-01
      • 2020-07-17
      • 2016-08-26
      • 1970-01-01
      • 2022-11-11
      • 1970-01-01
      相关资源
      最近更新 更多