Ejemplo n.º 1
0
    df.
    loc[:,
        ['item', 'Flag_Occurence', 'month', 'quarter', 'half', 'year', 'woy']])
y = df.loc[:, 'Quantity']

from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x,
                                                    y,
                                                    test_size=0.2,
                                                    random_state=42)

#['item','Flag_Occurence','month','quarter','half','year', 'woy']
# with statsmodels
X = sm.add_constant(x_train)  # adding a constant
model = sm.OLS(y_train, X).fit()
print(model.summary())

#removed 'year'
X = X[:, [0, 1, 2, 3, 4, 5, 7]]
#['item','Flag_Occurence','month','quarter','half', 'woy']
model = sm.OLS(y_train, X).fit()
print(model.summary())

#removed 'quarter'
X = X[:, [0, 1, 2, 3, 5, 6]]
#['item','Flag_Occurence','month','half', 'woy']
model = sm.OLS(y_train, X).fit()
print(model.summary())

#removed 'half'
#['item','Flag_Occurence','month', 'woy']