<jupyter_start><jupyter_text>NAME: <NAME>   The Sparks Foundation Task1 Simple Linear Regression<jupyter_code>#importing the libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#loading the dataset
data=pd.read_csv("https://raw.githubusercontent.com/AdiPersonalWorks/Random/master/student_scores%20-%20student_scores.csv")
data

data.describe()
#exploring the data
data.isnull().any()
data.head(3)
data.tail(3)
#Dependent and Independent variables
x1=data['Hours']
y1=data['Scores']
print(x1.shape,y1.shape)

#In order to feed x to sklearn, it should be a 2D array (a matrix)
# Therefore, we must reshape it 
#this will not be needed when we've got more than 1 feature (as the inputs will be a 2D array by default)
xmat=x1.values.reshape(-1,1)
xmat.shape
#data Visualisation
plt.scatter(x1,y1, marker="*",alpha=0.9,color="red")
plt.xlabel("Hours Studied")
plt.ylabel("Percentage Secured")
plt.title("Hours vs Percentage")
plt.legend(["Scores"])
plt.show()
#creating LinearRegression Object
from sklearn.linear_model import LinearRegression
reg=LinearRegression()
reg.fit(xmat,y1)<jupyter_output><empty_output><jupyter_text>R-Squared<jupyter_code>reg.score(xmat,y1)<jupyter_output><empty_output><jupyter_text>Intercept & Coefficient<jupyter_code>c=reg.intercept_
m=reg.coef_
c
m<jupyter_output><empty_output><jupyter_text>Making Prediction<jupyter_code>reg.predict([[9.5]])
# Parametrized version of the regression line
#yhat = reg.coef_*xmat + reg.intercept_
# Non-parametrized version of the regression line
#yhat = 9.77*x + 2.48

# Plotting the regression line

plt.scatter(x1,y1)
yhat=m*xmat+c
fig=plt.plot(x1,yhat,lw="4",c="orange",label="Regression line")
plt.xlabel("Hours Studied",fontsize=10)
plt.ylabel("Percentage Secured",fontsize=10)
plt.title("Hours vs Percentage")
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12987012987012986, 'fraction_numerical': 0.021103896103896104, 'mean_word_length': 7.721698113207547, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 1, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '217799', 'license': 'MIT', 'n_tokens_mistral': 734, 'n_tokens_neox': 685, 'n_words': 147, 'path': 'Student Percentage Prediction.ipynb', 'repo_name': 'likitha4/MLTasks', 'size': '1861'}