Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# importing libraries
from sklearn.linear_model import LinearRegression
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
# separate the independent and target variable
train_X = train_data.drop(columns=['Item_Identifier','Item_Outlet_Sales'])
train_Y = train_data['Item_Outlet_Sales']
# randomly split the data
train_x, test_x, train_y, test_y = train_test_split(train_X, train_Y,test_size=0.25,random_state=0)
# shape of train and test splits
train_x.shape, test_x.shape, train_y.shape, test_y.shape
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment