Last active
June 4, 2019 20:45
-
-
Save karanjakhar/6ac104021fe51d05a16e3330060bb0cd to your computer and use it in GitHub Desktop.
Importing wine data and predicting quality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#importing libraries | |
from sklearn.linear_model import LinearRegression | |
from sklearn.model_selection import train_test_split | |
from sklearn.metrics import mean_squared_error | |
import pandas as pd | |
#loading data | |
data = pd.read_csv('path of your csv file here.csv') | |
#getting information | |
data.info() | |
#printing first 5 rows of the data | |
data.head() | |
#getting target and features | |
train_data = df.drop('target',axis = 1) | |
y_train = df['target'] | |
#separating train and test set | |
x_train,x_test,y_train,y_test = train_test_split(train_data,y_train) | |
#training model and predicting | |
model = LinearRegression() | |
model.fit(x_train,y_train) | |
print(mean_squared_error(model.predict(x_test),y_test)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment