using your age and duration of workout finding how much calories you burned!
dataset: https://www.kaggle.com/fmendes/fmendesdat263xdemos/download
.........................................................................................................................................................
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import pickle
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
df_calories=pd.read_csv("ineuron/calories.csv")
df_exercise=pd.read_csv("ineuron/exercise.csv")
data=df_exercise.merge(df_calories, on='User_ID')
#print(data.head())
#[:,0:-1] all rows and all expect last column (independent variable) also feature column
#data_x = data.iloc[:,:-1].values
data_x= df.loc[:,[ 'Weight','Age','Duration']]
data_y=df.iloc[:,-1]
#[:,-1]all rows and only last column (dependent variable) also target column
#data_y = data.iloc[:,-1].values
x_train,x_test,y_train,y_test = train_test_split(data_x,data_y,test_size=0.3, random_state=0)
reg = LinearRegression()
reg.fit(x_train,y_train)
print("train_score=" ,reg.score(x_train,y_train))
print("train_score=" ,reg.score(x_test,y_test))
''''
pickle.dump(reg,open("taxi.pkl",'wb'))
model=pickle.load(open('taxi.pkl','rb'))
print(model.predict([[60,20,14]]))
'''
print(reg.predict([[60,20,14]]))
%matplotlib inline
plt.xlabel("Age")
plt.ylabel("Calories")
plt.scatter(df['Duration'],df["Calories"],cmap= None, marker="+")
Comments
Post a Comment