I tried running the Lasso Regression with Crude oil price, I can't shuffle the train and test set when I split into train and test set
Crude Oil Price in 2020, it's very strange because of COVID-19
But I want to know how to fix the error on train and test set, I need to use this with no shuffle
# Import Libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#%matplotlib inline
plt.style.use('ggplot')
import warnings; warnings.simplefilter('ignore')
# Read data from CSV to Pandas
df = pd.read_csv('https://www.kaggle.com/yothinpukongnin/crude-oil-price?select=DB_2.csv
', index_col=0)
#df = df.iloc[ 0:108 , : ]
X = df.drop(['Dubai','EU_RUB'], axis=1)
y = df['Dubai']
# Split Train and Test Set
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=7, shuffle = False)
#Lasso Regression
from sklearn.linear_model import Lasso
reg = Lasso(alpha=0.5)
reg.fit(X_train, y_train)
#R^esults from traditional Lasso
from sklearn.metrics import mean_squared_error
print('Lasso Regression: R^2 score on training set', reg.score(X_train, y_train)*100)
print('Lasso Regression: R^2 score on test set', reg.score(X_test, y_test)*100)
R square for test set = -356