<jupyter_start><jupyter_text>**TASK 1: PREDICTION USING SUPERVISED MACHINE LEARNING** **BY: <NAME>** **Here in this task, we have to predict the percentage of a student based on the no. of study hours.** **In this task, we will implement simple linear regression.**  Importing the libraries<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd<jupyter_output><empty_output><jupyter_text>Importing the dataset<jupyter_code>dataset = pd.read_csv('https://raw.githubusercontent.com/AdiPersonalWorks/Random/master/student_scores%20-%20student_scores.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, -1].values
print(X)
print(y)<jupyter_output>[[2.5]
 [5.1]
 [3.2]
 [8.5]
 [3.5]
 [1.5]
 [9.2]
 [5.5]
 [8.3]
 [2.7]
 [7.7]
 [5.9]
 [4.5]
 [3.3]
 [1.1]
 [8.9]
 [2.5]
 [1.9]
 [6.1]
 [7.4]
 [2.7]
 [4.8]
 [3.8]
 [6.9]
 [7.8]]
[21 47 27 75 30 20 88 60 81 25 85 62 41 42 17 95 30 24 67 69 30 54 35 76
 86]<jupyter_text>Splitting the dataset into the Training set and Test set<jupyter_code>from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)
print(X_train)
print(X_test)
print(y_train)
print(y_test)<jupyter_output>[35 24 86 76 17 47 85 42 81 88 67 30 25 60 30 75 21 54 95 41]
[20 27 69 30 62]<jupyter_text>Training the Simple Linear Regression model on the Training set<jupyter_code>from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)<jupyter_output><empty_output><jupyter_text>Predicting the Test set results<jupyter_code>y_pred = regressor.predict(X_test)<jupyter_output><empty_output><jupyter_text>Visualising the Training set results<jupyter_code>plt.scatter(X_train, y_train, color = 'red')
plt.plot(X_train, regressor.predict(X_train), color = 'blue')
plt.title('Hours vs Score(Training Set)')
plt.xlabel('Hours')
plt.ylabel('Score')
plt.show()<jupyter_output><empty_output><jupyter_text>Visualising the Test set results<jupyter_code>plt.scatter(X_test, y_test, color = 'red')
plt.plot(X_train, regressor.predict(X_train), color = 'blue')
plt.title('Hours Vs Score (Testing set)')
plt.xlabel('Hours')
plt.ylabel('Score')
plt.show()<jupyter_output><empty_output><jupyter_text>Making Prediction<jupyter_code>print("Percentage for 9.25 hours for study is:" ,regressor.predict([[9.25]]),"%")<jupyter_output>Percentage for 9.25 hours for study is: [93.69173249] %<jupyter_text>Evaluating Model<jupyter_code>from sklearn.metrics import mean_absolute_error
from sklearn.metrics import r2_score
print('Mean Absolute Error:', mean_absolute_error(y_test, y_pred))
print('R-square Value:',r2_score(y_test,y_pred))<jupyter_output>Mean Absolute Error: 4.183859899002982
R-square Value: 0.9454906892105354
{'fraction_non_alphanumeric': 0.13566030946383592, 'fraction_numerical': 0.07700611730838432, 'mean_word_length': 6.493261455525606, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '213831', 'license': 'MIT', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1080, 'n_words': 257, 'path': 'Prediction_using_Supervised_ML (1).ipynb', 'repo_name': 'akanksha198/GRIPMAR21', 'size': '2787'}