<jupyter_start><jupyter_text>Importing libraries<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Importing Data<jupyter_code>url='https://raw.githubusercontent.com/AdiPersonalWorks/Random/master/student_scores%20-%20student_scores.csv'
data=pd.read_csv(url)
data.head()
data.shape
data.describe()
sns.regplot(x='Hours',y='Scores',data=data)
plt.show()<jupyter_output><empty_output><jupyter_text>Predictive Modelling- Linear Regression<jupyter_code>data_train=data.iloc[:20]
data_test=data.iloc[20:]
x_train=data_train.drop(['Scores'],axis=1)
y_train=data_train['Scores']
x_test=data_test.drop(['Scores'],axis=1)
from sklearn.linear_model import LinearRegression
lreg=LinearRegression()
lreg.fit(x_train,y_train)
lreg.score(x_train,y_train)
pred=lreg.predict(x_test)
df1=pd.DataFrame({'Actual':data_test['Scores'],'Predicted':pred})
df1<jupyter_output><empty_output><jupyter_text>Final Prediction<jupyter_code>dict1={'Hours':[9.25]}
df=pd.DataFrame(dict1)
df['Scores']=lreg.predict(df)
df
print('Hence, the score if student studies for 9.25 hours is: {}'.format(list(df['Scores'])[0]))<jupyter_output>Hence, the score if student studies for 9.25 hours is: 91.09485441683266<jupyter_text>Evaluating the model<jupyter_code>def rmse(y,y1):
    add=(y-y1)**2
    final=np.sqrt(np.mean(add))
    return final
print('Therefore, the root mean squared error is {}'.format(rmse(data_test['Scores'],pred)))<jupyter_output>Therefore, the root mean squared error is 5.931635159442725
StarcoderdataJupyterStructuredCleanDedup