AdSense

Friday, June 5, 2020

Additive Model and Multiplicative Model : Decomposing Time Series Data into Trend, Seasonality, and Residual (plus Monthly Average) + Polynomial Regression of Trend

Additive Model and Multiplicative Model : Decomposing Time Series Data into Trend, Seasonality, and Residual (plus Monthly Average) + Polynomial Regression of Trend



0_MacOS_Python_setup.txt
# Install on Terminal of MacOS


#pip3 install -U statsmodels

#pip3 install -U matplotlib

#pip3 install -U numpy

#pip3 install -U pandas

#pip3 install -U sympy

#pip3 install -U requests

#pip3 install -U scikit-learn

#pip3 install -U scikit-learn

#pip3 install -U ipython




1_MacOS_Terminal.txt
########## Run Terminal on MacOS and execute
### TO UPDATE
cd "YOUR_WORKING_DIRECTORY"

python3 ts.py airline-passengers.csv multiplicative 12

python3 pr.py 2 rescsv.csv trend 8




Input Data files


airline-passengers.csv
"Month","Passengers"
"1949-01",112
"1949-02",118
"1949-03",132
"1949-04",129
"1949-05",121
"1949-06",135
"1949-07",148
"1949-08",148
"1949-09",136
"1949-10",119
"1949-11",104
"1949-12",118
"1950-01",115
"1950-02",126
"1950-03",141
"1950-04",135
"1950-05",125
"1950-06",149
"1950-07",170
"1950-08",170
"1950-09",158
"1950-10",133
"1950-11",114
"1950-12",140
"1951-01",145
"1951-02",150
"1951-03",178
"1951-04",163
"1951-05",172
"1951-06",178
"1951-07",199
"1951-08",199
"1951-09",184
"1951-10",162
"1951-11",146
"1951-12",166
"1952-01",171
"1952-02",180
"1952-03",193
"1952-04",181
"1952-05",183
"1952-06",218
"1952-07",230
"1952-08",242
"1952-09",209
"1952-10",191
"1952-11",172
"1952-12",194
"1953-01",196
"1953-02",196
"1953-03",236
"1953-04",235
"1953-05",229
"1953-06",243
"1953-07",264
"1953-08",272
"1953-09",237
"1953-10",211
"1953-11",180
"1953-12",201
"1954-01",204
"1954-02",188
"1954-03",235
"1954-04",227
"1954-05",234
"1954-06",264
"1954-07",302
"1954-08",293
"1954-09",259
"1954-10",229
"1954-11",203
"1954-12",229
"1955-01",242
"1955-02",233
"1955-03",267
"1955-04",269
"1955-05",270
"1955-06",315
"1955-07",364
"1955-08",347
"1955-09",312
"1955-10",274
"1955-11",237
"1955-12",278
"1956-01",284
"1956-02",277
"1956-03",317
"1956-04",313
"1956-05",318
"1956-06",374
"1956-07",413
"1956-08",405
"1956-09",355
"1956-10",306
"1956-11",271
"1956-12",306
"1957-01",315
"1957-02",301
"1957-03",356
"1957-04",348
"1957-05",355
"1957-06",422
"1957-07",465
"1957-08",467
"1957-09",404
"1957-10",347
"1957-11",305
"1957-12",336
"1958-01",340
"1958-02",318
"1958-03",362
"1958-04",348
"1958-05",363
"1958-06",435
"1958-07",491
"1958-08",505
"1958-09",404
"1958-10",359
"1958-11",310
"1958-12",337
"1959-01",360
"1959-02",342
"1959-03",406
"1959-04",396
"1959-05",420
"1959-06",472
"1959-07",548
"1959-08",559
"1959-09",463
"1959-10",407
"1959-11",362
"1959-12",405
"1960-01",417
"1960-02",391
"1960-03",419
"1960-04",461
"1960-05",472
"1960-06",535
"1960-07",622
"1960-08",606
"1960-09",508
"1960-10",461
"1960-11",390
"1960-12",432




Python files


ts.py
########## Additive Model and Multiplicative Model : Decomposing Time Series Data into Trend, Seasonality, and Residual (plus Monthly Average) #########
#
#
#Run this code on Terminal of MacOS as follows:
#python3 ts.py (raw dataset csv file) (model:additive or multiplicative) (frequency)
#
#For instance,
#python3 ts.py airline-passengers.csv multiplicative 12
#
#Additive Model
# y(t) = Level + Trend + Seasonality + Noise
#
#Multiplicative Model
#y(t) = Level * Trend * Seasonality * Noise
#
#
#Input dataset:
#https://raw.githubusercontent.com/jbrownlee/Datasets/master/airline-passengers.csv
#
#
#Reference:
#https://machinelearningmastery.com/decompose-time-series-data-trend-seasonality/
#https://stackoverflow.com/questions/45184055/how-to-plot-multiple-seasonal-decompose-plots-in-one-figure


##### import

import sys
import datetime
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.seasonal import seasonal_decompose



##### arguments

csvf = str(sys.argv[1])    # e.g., airline-passengers.csv
md   = str(sys.argv[2])    # e.g., multiplicative
frq  = int(sys.argv[3])    # e.g., 12



##### Plot: Raw Dataset

dt_now = datetime.datetime.now()
#print(dt_now)
# 2019-02-04 21:04:15.412854

series = pd.read_csv(csvf, header=0, index_col=0)
#print(series)
'''
         Passengers
Month            
1949-01         112
1949-02         118
1949-03         132
1949-04         129
1949-05         121
...             ...
1960-08         606
1960-09         508
1960-10         461
1960-11         390
1960-12         432
'''
#print(type(series))
#<class 'pandas.core.frame.DataFrame'>


series.plot(figsize=(12,9))

plt.title("Raw Data")
plt.savefig("Figure_1_raw_data_" + dt_now.strftime('%Y-%m-%d_%H%M%S') + ".png")

plt.show()



##### Plot: Decomposing Raw (Observed) Data into Trend, Seasonality, and Residual

dta = series
#print(dta)
'''
         Passengers
Month            
1949-01         112
1949-02         118
1949-03         132
1949-04         129
1949-05         121
...             ...
1960-08         606
1960-09         508
1960-10         461
1960-11         390
1960-12         432

[144 rows x 1 columns]
'''
#print(type(dta))
#<class 'pandas.core.frame.DataFrame'>

yname = dta.columns[0]

dta.eval(yname).interpolate(inplace=True)

##statsmodels.api.tsa.seasonal_decompose(dta.eval(yname))
#res = seasonal_decompose(dta.eval(yname), model=md, freq=frq)
res = seasonal_decompose(dta.eval(yname), model=md, period=frq)
#print(res)

rescsv = pd.concat([res.observed, res.trend, res.seasonal, res.resid], axis=1, join='outer')
#print(rescsv)

pd.DataFrame(data=rescsv).to_csv("rescsv.csv", header=True, index=True)


def plotseasonal(res, axes ):
    res.observed.plot(ax=axes[0], legend=False)
    axes[0].set_ylabel('Observed')
    res.trend.plot(ax=axes[1], legend=False)
    axes[1].set_ylabel('Trend')
    res.seasonal.plot(ax=axes[2], legend=False)
    axes[2].set_ylabel('Seasonal')
    res.resid.plot(ax=axes[3], legend=False)
    axes[3].set_ylabel('Residual')


##### plot
#
# [Case A] When plotting one raw dataset and its trend, seasonality, and residual
fig, axes = plt.subplots(ncols=1, nrows=4, sharex=True, figsize=(12,9))
#print(type(fig))
#<class 'matplotlib.figure.Figure'>
#
#print(type(axes))
#<class 'numpy.ndarray'>
#
#
#print(axes)
'''
[<matplotlib.axes._subplots.AxesSubplot object at 0x128497130>
 <matplotlib.axes._subplots.AxesSubplot object at 0x129abe2b0>
 <matplotlib.axes._subplots.AxesSubplot object at 0x129aea430>
 <matplotlib.axes._subplots.AxesSubplot object at 0x129b17580>]
'''
plotseasonal(res, axes[:])
#
#
# [Case B]  When plotting three raw datasets and its trend, seasonality, and residual
#fig, axes = plt.subplots(ncols=3, nrows=4, sharex=True, figsize=(12,5))
#plotseasonal(res, axes[:,0])
#plotseasonal(res, axes[:,1])
#plotseasonal(res, axes[:,2])


plt.tight_layout()

plt.savefig("Figure_2_raw_data_trend_seasonality_residual_" + md + "_" + dt_now.strftime('%Y-%m-%d_%H%M%S') + ".png")

plt.show()



##### Plot: Raw (Observed) Data Monthly Average

# Convert to Pandas.Series (x and index: Month, y: Passengers)
dta2 = pd.Series(dta[yname], dtype='float')
#
#print(dta2)
'''
Month
1949-01    112.0
1949-02    118.0
1949-03    132.0
1949-04    129.0
1949-05    121.0
           ...
1960-08    606.0
1960-09    508.0
1960-10    461.0
1960-11    390.0
1960-12    432.0
Name: Passengers, Length: 144, dtype: float64
'''
#
#print(dta2.index)
'''
Index(['1949-01', '1949-02', '1949-03', '1949-04', '1949-05', '1949-06',
       '1949-07', '1949-08', '1949-09', '1949-10',
       ...
       '1960-03', '1960-04', '1960-05', '1960-06', '1960-07', '1960-08',
       '1960-09', '1960-10', '1960-11', '1960-12'],
      dtype='object', name='Month', length=144)
'''
#print(dta2.index.values)
#
#dta2.index = pd.to_datetime(dta2['Month'])
dta2.index = pd.to_datetime(dta2.index)
#
#print(dta2.index)
'''
DatetimeIndex(['1949-01-01', '1949-02-01', '1949-03-01', '1949-04-01',
               '1949-05-01', '1949-06-01', '1949-07-01', '1949-08-01',
               '1949-09-01', '1949-10-01',
               ...
               '1960-03-01', '1960-04-01', '1960-05-01', '1960-06-01',
               '1960-07-01', '1960-08-01', '1960-09-01', '1960-10-01',
               '1960-11-01', '1960-12-01'],
              dtype='datetime64[ns]', name='Month', length=144, freq=None)
'''
#
monthly_mean = dta2.groupby(dta2.index.month).mean()
#print(monthly_mean)
'''
Month
1     241.750000
2     235.000000
3     270.166667
4     267.083333
5     271.833333
6     311.666667
7     351.333333
8     351.083333
9     302.416667
10    266.583333
11    232.833333
12    261.833333
Name: Passengers, dtype: float64
'''
#print(type(monthly_mean))
#<class 'pandas.core.series.Series'>


pd.DataFrame(data=monthly_mean).to_csv("monthly_mean.csv", header=True, index=True)


monthly_mean.plot(kind='bar')

plt.title("Raw Data: Monthly Average")

plt.savefig("Figure_3_raw_data_monthly average_" + dt_now.strftime('%Y-%m-%d_%H%M%S') + ".png")

plt.show()




pr.py
########## Polynomial Regression (x: date vs y: Passengers) ##########

##### Run this script as follows:
#
#python3 pr.py (the number of degrees/orders of the polynominal regression model) (a file name that has two columns, date & new_cases) new_cases (signigicant figures of the polynominal regression model coefficients)
#
# For instance,
#python3 pr.py 2 rescsv.csv trend 8


### import
import numpy as np
import matplotlib.pyplot as plt
from sklearn.metrics import r2_score
import sys
import datetime
import os
import sympy as sym
from sympy.plotting import plot
from IPython.display import display
import pandas as pd


### arguments
deg = int(sys.argv[1])
trainingcsv = sys.argv[2]
yname = sys.argv[3]
coefdecimals = int(sys.argv[4])


### datetime
dt_now = datetime.datetime.now()
#print(dt_now)
# 2019-02-04 21:04:15.412854


### Training Data
tmp_training = pd.read_csv(trainingcsv)

#print(tmp_training)
#
# Delete all ROWS which has one or more NaN.
#print(tmp_training.dropna(how='any', axis=0))
tmp_training = tmp_training.dropna(how='any', axis=0)
#
#print(tmp_training)

x_training = tmp_training.index.values.tolist()
y_training = tmp_training[yname].values.tolist()


### LSM
#
#least-squares method (Degree of the polynomial fitting: n)
#LSM (Deg: n)
cf = ["LSM (Deg: " + str(deg) +  ")", lambda x, y: np.polyfit(x, y, deg)]


sym.init_printing(use_unicode=True)
x, y = sym.symbols("x y")


for method_name, method in [cf]:
    #print(method_name)
 
    ### calculating coefficients
    coefficients = method(x_training, y_training)
    #print(type(coefficients))
    #<class 'numpy.ndarray'>
    coefficients = np.round(coefficients, decimals = coefdecimals)
 
    ### sympy to show an equation
    expr = 0
    for index, coefficient in enumerate(coefficients):
        expr += coefficient * x ** (len(coefficients) - index - 1)
    display(sym.Eq(y, expr))
 
    ###R2
    fitted_curve = np.poly1d(method(x_training, y_training))
    r2 = r2_score(y_training, fitted_curve(x_training))
 
    ### Scatter Plot
    plt.figure(figsize=(12, 9))
    plt.scatter(x_training, y_training, label="Training Data")
    #
    # data plotting and drawing a fitted model
    x_latent = np.linspace(min(x_training), max(x_training), 100)
    fitted_curve = np.poly1d(method(x_training, y_training))(x_latent)
    plt.plot(x_latent, fitted_curve, c="red", label="Polynominal Regession")
    plt.title("Polynominal Regession of " + str(yname))
    plt.xlabel('Days')
    plt.ylabel(yname)
    plt.grid()  
    plt.legend(bbox_to_anchor=(0, 1), loc='upper left', borderaxespad=0, fontsize=12)
    plt.text(min(x_training),max(y_training)*0.80, sym.Eq(y, expr), fontsize=12)
    plt.text(min(x_training),max(y_training)*0.70, "R2 = " + str(r2), fontsize=12)
    plt.savefig("Figure_4_Polynominal_Regression_deg_" + str(deg) + "_" + dt_now.strftime('%Y-%m-%d_%H%M%S') + ".png")
    plt.show()



##### Output CSV
#print(x_latent)
print(len(x_latent))
#print(fitted_curve)
print(len(fitted_curve))
#
outputcsv = pd.concat([pd.Series(x_training), pd.Series(y_training)], axis=1, join='outer')
#outputcsv = pd.concat([pd.Series(x_training), pd.Series(y_training), pd.Series(fitted_curve)], axis=1, join='outer')
print(outputcsv)
pd.DataFrame(data=outputcsv).to_csv("outputcsv.csv", header=True, index=True)



Output Data files


rescsv.csv
Month,Passengers,trend,seasonal,resid
1949-01,112.0,,0.9102303673722006,
1949-02,118.0,,0.8836253206943756,
1949-03,132.0,,1.0073662876035454,
1949-04,129.0,,0.9759060123228472,
1949-05,121.0,,0.9813780274951293,
1949-06,135.0,,1.1127758266792729,
1949-07,148.0,126.79166666666666,1.2265555429312012,0.9516643164028834
1949-08,148.0,127.24999999999999,1.2199109694456252,0.9534014056242447
1949-09,136.0,127.95833333333331,1.0604919326468183,1.00221976781656
1949-10,119.0,128.58333333333331,0.9217572404104976,1.0040277671042104
1949-11,104.0,128.99999999999997,0.8011780824134743,1.0062701015971256
1949-12,118.0,129.75,0.8988243899850112,1.011811921520978
1950-01,115.0,131.25,0.9102303673722006,0.9626029932620286
1950-02,126.0,133.08333333333334,0.8836253206943756,1.0714668098946898
1950-03,141.0,134.91666666666669,1.0073662876035454,1.0374474253490114
1950-04,135.0,136.41666666666666,0.9759060123228472,1.0140476000435144
1950-05,125.0,137.41666666666669,0.9813780274951293,0.9269029690018589
1950-06,149.0,138.75000000000003,1.1127758266792729,0.9650406201566315
1950-07,170.0,140.91666666666666,1.2265555429312012,0.9835565624018564
1950-08,170.0,143.16666666666669,1.2199109694456252,0.9733720498615518
1950-09,158.0,145.70833333333331,1.0604919326468183,1.022504733680162
1950-10,133.0,148.41666666666666,0.9217572404104976,0.9721928212238378
1950-11,114.0,151.54166666666666,0.8011780824134743,0.9389527366650869
1950-12,140.0,154.70833333333331,0.8988243899850112,1.006791359050623
1951-01,145.0,157.125,0.9102303673722006,1.0138445970332666
1951-02,150.0,159.54166666666666,0.8836253206943756,1.0640180175116092
1951-03,178.0,161.83333333333331,1.0073662876035454,1.0918541020514378
1951-04,163.0,164.125,0.9759060123228472,1.0176650782477634
1951-05,172.0,166.66666666666666,0.9813780274951293,1.0515825411682371
1951-06,178.0,169.0833333333333,1.1127758266792729,0.9460443984897541
1951-07,199.0,171.24999999999997,1.2265555429312012,0.9474041369895129
1951-08,199.0,173.58333333333331,1.2199109694456252,0.9397599140119374
1951-09,184.0,175.45833333333331,1.0604919326468183,0.9888637442578553
1951-10,162.0,176.83333333333331,0.9217572404104976,0.9938808513926574
1951-11,146.0,178.04166666666669,0.8011780824134743,1.0235336960240646
1951-12,166.0,180.16666666666669,0.8988243899850112,1.0250824443004556
1952-01,171.0,183.125,0.9102303673722006,1.0258813915429423
1952-02,180.0,186.20833333333331,0.8836253206943756,1.0939695651963173
1952-03,193.0,189.04166666666663,1.0073662876035454,1.0134734098250622
1952-04,181.0,191.29166666666663,0.9759060123228472,0.9695596432636905
1952-05,183.0,193.5833333333333,0.9813780274951293,0.9632672518184556
1952-06,218.0,195.83333333333331,1.1127758266792729,1.0003735367649653
1952-07,230.0,198.0416666666666,1.2265555429312012,0.9468562364697322
1952-08,242.0,199.74999999999997,1.2199109694456252,0.9931170579946488
1952-09,209.0,202.20833333333334,1.0604919326468183,0.9746302068393307
1952-10,191.0,206.24999999999997,0.9217572404104976,1.0046686540245588
1952-11,172.0,210.41666666666666,0.8011780824134743,1.0202797112370305
1952-12,194.0,213.375,0.8988243899850112,1.0115406663515256
1953-01,196.0,215.83333333333331,0.9102303673722006,0.9976684371998933
1953-02,196.0,218.5,0.8836253206943756,1.0151646298680175
1953-03,236.0,220.91666666666663,1.0073662876035454,1.0604644361877407
1953-04,235.0,222.91666666666663,0.9759060123228472,1.0802327213533813
1953-05,229.0,224.08333333333331,0.9813780274951293,1.0413329150091515
1953-06,243.0,224.70833333333331,1.1127758266792729,0.971805633482808
1953-07,264.0,225.33333333333334,1.2265555429312012,0.9551932971060005
1953-08,272.0,225.33333333333334,1.2199109694456252,0.9894989240604416
1953-09,237.0,224.95833333333331,1.0604919326468183,0.9934337063380791
1953-10,211.0,224.58333333333334,0.9217572404104976,1.0192679634537005
1953-11,180.0,224.45833333333331,0.8011780824134743,1.0009392308728386
1953-12,201.0,225.54166666666666,0.8988243899850112,0.9915038921474064
1954-01,204.0,228.0,0.9102303673722006,0.9829784570782156
1954-02,188.0,230.45833333333331,0.8836253206943756,0.9232031554773301
1954-03,235.0,232.24999999999997,1.0073662876035454,1.004441682597805
1954-04,227.0,233.91666666666663,0.9759060123228472,0.9943898827760491
1954-05,234.0,235.625,0.9813780274951293,1.0119479145163468
1954-06,264.0,237.74999999999997,1.1127758266792729,0.9978740263893865
1954-07,302.0,240.5,1.2265555429312012,1.0237752892269063
1954-08,293.0,243.95833333333334,1.2199109694456252,0.98451837489729
1954-09,259.0,247.16666666666666,1.0604919326468183,0.9881036290010385
1954-10,229.0,250.24999999999997,0.9217572404104976,0.9927612987096137
1954-11,203.0,253.49999999999997,0.8011780824134743,0.9995143055122108
1954-12,229.0,257.125,0.8988243899850112,0.9908691997123485
1955-01,242.0,261.8333333333333,0.9102303673722006,1.0154045633681739
1955-02,233.0,266.66666666666663,0.8836253206943756,0.9888240858844841
1955-03,267.0,271.125,1.0073662876035454,0.9775844472954781
1955-04,269.0,275.2083333333333,0.9759060123228472,1.0015732252714535
1955-05,270.0,278.5,0.9813780274951293,0.9878755449160926
1955-06,315.0,281.9583333333333,1.1127758266792729,1.0039635286058564
1955-07,364.0,285.75,1.2265555429312012,1.038551231735955
1955-08,347.0,289.33333333333337,1.2199109694456252,0.9831117071644834
1955-09,312.0,293.24999999999994,1.0604919326468183,1.0032500825069086
1955-10,274.0,297.1666666666667,0.9217572404104976,1.0003083921250941
1955-11,237.0,301.0,0.8011780824134743,0.9827720360378518
1955-12,278.0,305.45833333333326,0.8988243899850112,1.0125534772990237
1956-01,284.0,309.9583333333333,0.9102303673722006,1.006615706613454
1956-02,277.0,314.4166666666667,0.8836253206943756,0.9970250216162121
1956-03,317.0,318.625,1.0073662876035454,0.9876248322104635
1956-04,313.0,321.74999999999994,0.9759060123228472,0.9968223994127333
1956-05,318.0,324.5,0.9813780274951293,0.9985644225806528
1956-06,374.0,327.08333333333326,1.1127758266792729,1.027556011760332
1956-07,413.0,329.54166666666663,1.2265555429312012,1.0217684733250962
1956-08,405.0,331.8333333333333,1.2199109694456252,1.0004764655259983
1956-09,355.0,334.45833333333326,1.0604919326468183,1.0008729746411495
1956-10,306.0,337.5416666666667,0.9217572404104976,0.983507052164718
1956-11,271.0,340.5416666666667,0.8011780824134743,0.9932760726708177
1956-12,306.0,344.0833333333333,0.8988243899850112,0.9894251399019294
1957-01,315.0,348.25,0.9102303673722006,0.993729329946053
1957-02,301.0,353.0,0.8836253206943756,0.964991833258292
1957-03,356.0,357.625,1.0073662876035454,0.9881769386852579
1957-04,348.0,361.375,0.9759060123228472,0.9867636566481572
1957-05,355.0,364.5,0.9813780274951293,0.9924176745109158
1957-06,422.0,367.16666666666674,1.1127758266792729,1.0328601494311507
1957-07,465.0,369.45833333333337,1.2265555429312012,1.0261249953429645
1957-08,467.0,371.2083333333333,1.2199109694456252,1.0312667769357124
1957-09,404.0,372.1666666666666,1.0604919326468183,1.0236147216993436
1957-10,347.0,372.41666666666663,0.9217572404104976,1.0108432339509779
1957-11,305.0,372.75,0.8011780824134743,1.0212995188396765
1957-12,336.0,373.625,0.8988243899850112,1.0005262806704482
1958-01,340.0,375.25,0.9102303673722006,0.9954212223576867
1958-02,318.0,377.9166666666667,0.8836253206943756,0.9522761826670493
1958-03,362.0,379.49999999999994,1.0073662876035454,0.9469114707882059
1958-04,348.0,380.0,0.9759060123228472,0.9383992537400733
1958-05,363.0,380.70833333333337,0.9813780274951293,0.9715785356347435
1958-06,435.0,380.95833333333337,1.1127758266792729,1.0261340434482746
1958-07,491.0,381.8333333333333,1.2265555429312012,1.0483841196851822
1958-08,505.0,383.6666666666666,1.2199109694456252,1.0789695108337816
1958-09,404.0,386.49999999999994,1.0604919326468183,0.9856540205065262
1958-10,359.0,390.3333333333333,0.9217572404104976,0.9977971302743561
1958-11,310.0,394.7083333333333,0.8011780824134743,0.9802939860543499
1958-12,337.0,398.625,0.8988243899850112,0.9405686948769
1959-01,360.0,402.54166666666663,0.9102303673722006,0.9825176026958595
1959-02,342.0,407.1666666666667,0.8836253206943756,0.950573575014168
1959-03,406.0,411.875,1.0073662876035454,0.9785278460391813
1959-04,396.0,416.33333333333326,0.9759060123228472,0.9746439890036597
1959-05,420.0,420.49999999999994,0.9813780274951293,1.0177637071285097
1959-06,472.0,425.5,1.1127758266792729,0.9968613350903052
1959-07,548.0,430.7083333333333,1.2265555429312012,1.0373135823544246
1959-08,559.0,435.125,1.2199109694456252,1.053100054130422
1959-09,463.0,437.7083333333333,1.0604919326468183,0.9974446537535596
1959-10,407.0,440.95833333333326,0.9217572404104976,1.0013370766167895
1959-11,362.0,445.8333333333333,0.8011780824134743,1.0134608455294587
1959-12,405.0,450.625,0.8988243899850112,0.9999191652088765
1960-01,417.0,456.3333333333333,0.9102303673722006,1.0039279399429428
1960-02,391.0,461.37499999999994,0.8836253206943756,0.9590793646523456
1960-03,419.0,465.20833333333326,1.0073662876035454,0.8940856500108696
1960-04,461.0,469.3333333333332,0.9759060123228472,1.0064947912800382
1960-05,472.0,472.74999999999994,0.9813780274951293,1.0173587647555493
1960-06,535.0,475.04166666666663,1.1127758266792729,1.0120789574210476
1960-07,622.0,,1.2265555429312012,
1960-08,606.0,,1.2199109694456252,
1960-09,508.0,,1.0604919326468183,
1960-10,461.0,,0.9217572404104976,
1960-11,390.0,,0.8011780824134743,
1960-12,432.0,,0.8988243899850112,



monthly_mean.csv
Month,Passengers
1,241.75
2,235.0
3,270.1666666666667
4,267.0833333333333
5,271.8333333333333
6,311.6666666666667
7,351.3333333333333
8,351.0833333333333
9,302.4166666666667
10,266.5833333333333
11,232.83333333333334
12,261.8333333333333



outputcsv.csv
,0,1
0,6,126.79166666666666
1,7,127.25
2,8,127.95833333333331
3,9,128.58333333333331
4,10,128.99999999999997
5,11,129.75
6,12,131.25
7,13,133.08333333333334
8,14,134.91666666666669
9,15,136.41666666666666
10,16,137.41666666666669
11,17,138.75000000000003
12,18,140.91666666666666
13,19,143.16666666666669
14,20,145.70833333333331
15,21,148.41666666666666
16,22,151.54166666666666
17,23,154.70833333333331
18,24,157.125
19,25,159.54166666666666
20,26,161.83333333333331
21,27,164.125
22,28,166.66666666666666
23,29,169.08333333333331
24,30,171.24999999999997
25,31,173.58333333333331
26,32,175.45833333333331
27,33,176.83333333333331
28,34,178.04166666666669
29,35,180.16666666666669
30,36,183.125
31,37,186.2083333333333
32,38,189.04166666666663
33,39,191.29166666666663
34,40,193.58333333333331
35,41,195.8333333333333
36,42,198.0416666666666
37,43,199.75
38,44,202.20833333333331
39,45,206.25
40,46,210.41666666666663
41,47,213.375
42,48,215.8333333333333
43,49,218.5
44,50,220.91666666666663
45,51,222.91666666666663
46,52,224.0833333333333
47,53,224.7083333333333
48,54,225.33333333333331
49,55,225.33333333333331
50,56,224.9583333333333
51,57,224.58333333333331
52,58,224.4583333333333
53,59,225.54166666666663
54,60,228.0
55,61,230.4583333333333
56,62,232.25
57,63,233.91666666666663
58,64,235.625
59,65,237.75
60,66,240.5
61,67,243.95833333333331
62,68,247.16666666666663
63,69,250.25
64,70,253.5
65,71,257.125
66,72,261.8333333333333
67,73,266.66666666666663
68,74,271.125
69,75,275.2083333333333
70,76,278.5
71,77,281.9583333333333
72,78,285.75
73,79,289.33333333333337
74,80,293.24999999999994
75,81,297.1666666666667
76,82,301.0
77,83,305.45833333333326
78,84,309.9583333333333
79,85,314.4166666666667
80,86,318.625
81,87,321.74999999999994
82,88,324.5
83,89,327.08333333333326
84,90,329.54166666666663
85,91,331.8333333333333
86,92,334.45833333333326
87,93,337.5416666666667
88,94,340.5416666666667
89,95,344.08333333333326
90,96,348.25
91,97,353.0
92,98,357.625
93,99,361.375
94,100,364.5
95,101,367.16666666666674
96,102,369.45833333333337
97,103,371.20833333333326
98,104,372.16666666666663
99,105,372.4166666666666
100,106,372.75
101,107,373.625
102,108,375.25
103,109,377.91666666666674
104,110,379.5
105,111,380.0
106,112,380.70833333333337
107,113,380.95833333333337
108,114,381.83333333333326
109,115,383.66666666666663
110,116,386.5
111,117,390.33333333333326
112,118,394.70833333333326
113,119,398.625
114,120,402.5416666666666
115,121,407.16666666666674
116,122,411.875
117,123,416.33333333333326
118,124,420.5
119,125,425.5
120,126,430.70833333333326
121,127,435.125
122,128,437.70833333333326
123,129,440.95833333333326
124,130,445.83333333333326
125,131,450.625
126,132,456.33333333333326
127,133,461.375
128,134,465.20833333333326
129,135,469.3333333333332
130,136,472.75
131,137,475.0416666666666




Figures
Figure_1_raw_data_2020-06-06_101033.png



Figure_2_raw_data_trend_seasonality_residual_multiplicative_2020-06-06_101033.png



Figure_3_raw_data_monthly average_2020-06-06_101033.png



Figure_4_Polynominal_Regression_deg_2_2020-06-06_101040.png


No comments:

Post a Comment

Deep Learning (Regression, Multiple Features/Explanatory Variables, Supervised Learning): Impelementation and Showing Biases and Weights

Deep Learning (Regression, Multiple Features/Explanatory Variables, Supervised Learning): Impelementation and Showing Biases and Weights ...