<jupyter_start><jupyter_text><NAME> [Task 1]<jupyter_code>#Import necessary libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
#Let's read the data
df=pd.read_csv('student_scores.csv')
df.head()
#Quick statistics of data
df.describe()
#Let's visualize data if we can see any pattern
df.plot(x='Hours',y='Scores',style='o')
plt.title('Hours vs Percentage')
plt.xlabel('Hours')
plt.ylabel('Percentage')
#From above plot, data is linearly dstributed. We will use linear regression model to train our data.
X=df.iloc[:, :-1].values
y=df.iloc[:, 1].values
#Spliting data to train and test
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.30, random_state=0)
from sklearn.linear_model import LinearRegression
lr=LinearRegression()
lr.fit(X_train,y_train)
print(lr.intercept_)
lr.coef_
prediction=lr.predict(X_test)
plt.scatter(y_test,prediction)
fitting_line=(lr.coef_*X+lr.intercept_)
#This is how our linear fit looks.
plt.scatter(X,y,color='black')
plt.plot(X,fitting_line,'r')
from sklearn import metrics
metrics.r2_score(y_test,prediction)
metrics.mean_absolute_error(y_test,prediction)
metrics.mean_squared_error(y_test,prediction)
#Root mean squared error
np.sqrt(metrics.mean_squared_error(y_test,prediction))
prediction
test=pd.DataFrame({'Actual':y_test,'Predicted':prediction})
test.head()
#You can predict the scores based on no of study hours per day.
hours=input('No of Study Hours per day:')
hours=np.asarray(hours,dtype='float64').reshape(1, -1)
pred=lr.predict(hours)
print("Predicted Score = {}".format(pred[0]))<jupyter_output>No of Study Hours per day:9.5
Predicted Score = 95.36219890645782
{'fraction_non_alphanumeric': 0.124, 'fraction_numerical': 0.017714285714285714, 'mean_word_length': 7.625615763546798, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '145040', 'license': 'CC0-1.0', 'n_tokens_mistral': 662, 'n_tokens_neox': 618, 'n_words': 156, 'path': 'Saurabh_Parmar_Task1_GRIPMARCH.ipynb', 'repo_name': 'SAURABH318/Score-Prediction', 'size': '1758'}