<jupyter_start><jupyter_text>Buissness Problem<jupyter_code>#import liberaries
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from pandas.plotting import scatter_matrix
from sklearn.metrics import mean_squared_error
from sklearn.linear_model import Ridge,Lasso
import joblib

#to load the dataset
student=pd.read_csv('studentdata.csv')
student
student.info()
student['study_hours'].isnull().sum()
student['student_marks'].isnull().sum()
student.shape
student.describe()
meanvalues=student['study_hours'].mean()
meanvalues
studentfilled=student.fillna(value=meanvalues)
studentfilled
studentfilled
studentfilled.isnull().sum()<jupyter_output><empty_output><jupyter_text>analysis<jupyter_code>plt.scatter(x=studentfilled.study_hours,y=studentfilled.student_marks)
plt.xlabel('STUDENTS STUDY HOURS',color='red',fontsize=16)
plt.ylabel('STUDENTS MARKS',color='red',fontsize=16)
plt.title('STUDENTS DATA',color='black',fontsize=20)
plt.show()
relation=studentfilled.corr()
relation
scatter_matrix(relation)
plt.show()
#frm this we can visviluaize rhat our data is lineaR
#X=studentfilled['study_hours']
#y=studentfilled['student_marks']''''''
X
X=studentfilled.drop('student_marks',axis=1)
y=studentfilled.drop('study_hours',axis=1)
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.2,random_state=51)
X_train.shape
X_test.shape
y_train.shape
y_test.shape<jupyter_output><empty_output><jupyter_text>linear model<jupyter_code>#creating the object for that 
lr=LinearRegression()
lr.fit(X_train,y_train)
lr.coef_
lr.intercept_<jupyter_output><empty_output><jupyter_text>testing<jupyter_code>X_test
y_test
predictions=lr.predict(X_test)
predictions
lr.score(X_test,y_test)#as this is keen to be sccurate 
#but we can still try for the lasso and ridge in order to increase the accuracy

mse=mean_squared_error(y_test,predictions)
rmse=np.sqrt(mse)
rmse<jupyter_output><empty_output><jupyter_text>checking for ridge and lasso<jupyter_code>rd=Ridge()
rd.fit(X_train,y_train)
predict=rd.predict(X_test)
predict
rd.score(X_test,y_test)#it is almost same
mse=mean_squared_error(y_test,predict)
rmse=np.sqrt(mse)
rmse
ls=Lasso()
ls.fit(X_train,y_train)
pre=ls.predict(X_test)
pre
ls.score(X_test,y_test)
mse=mean_squared_error(y_test,pre)
rmse=np.sqrt(mse)
rmse
y_test
#so most accurate is linear itself
combineddata=pd.DataFrame(np.c_[X_test,y_test,predictions],columns=['study_hours','originaldata','predicteddata'])
combineddata
#how our data is so accurate<jupyter_output><empty_output><jupyter_text>saving  theMODEL<jupyter_code>#save ml model import the liberary joblib
joblib.dump(rd,'STUDENT_MARK_PREDICTER.pkl')
#to call this model 
model=joblib.load("STUDENT_MARK_PREDICTER.pkl")
model
model.predict([[5]])
#it means it is wokding properly<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11543715846994536, 'fraction_numerical': 0.004439890710382513, 'mean_word_length': 10.716, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '82243', 'license': 'MIT', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1086, 'n_words': 187, 'path': 'STUDENT_PREDICTER.ipynb', 'repo_name': 'Garimadhall4/Student_Marks_Predicter', 'size': '2928'}