<jupyter_start><jupyter_text>**Importing libraries**<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline<jupyter_output><empty_output><jupyter_text>**Importing dataset**Grade_Set_1.csv dataset = pd.read_csv('C:/Users/srikanth/Desktop/MLInternship/Batch1/day4/datasets/Grade_Set_1.csv')<jupyter_code>dataset = pd.read_csv('./datasets/Grade_Set_1.csv') # Comma seperated values
dataset

dataset.keys()<jupyter_output><empty_output><jupyter_text>**Step-1: Converting Dataframes into array**<jupyter_code>X = dataset['Hours_Studied'].values # independent variable
y = dataset['Test_Grade'].values # independent variable<jupyter_output><empty_output><jupyter_text>**Step-2: if data is unstructued -> converting into structred**<jupyter_code>X = np.reshape(X,(len(X),1)) # reshaping
y = np.reshape(y,(len(y),1)) # reshaping
print('Shape of X ', X.shape)
print('Shape of y ', y.shape)
dataset.corr()<jupyter_output><empty_output><jupyter_text>**Step-3: Visualize the data : Scatter**<jupyter_code>plt.style.use('fivethirtyeight')
plt.scatter(X,y)
plt.xlabel('Hours Studied')
plt.ylabel('Test Grade')
plt.title('Hours vs Grade')
plt.show()<jupyter_output><empty_output><jupyter_text>Building Simple linear regression using**sklearn**<jupyter_code>from sklearn.linear_model import LinearRegression
predictor = LinearRegression()
predictor.fit(X,y) # training model(linear regression)
y_pred = predictor.predict(X) # input values
dataset['Predicted'] = y_pred
dataset
plt.style.use('fivethirtyeight')
plt.scatter(X,y)
plt.plot(X,y_pred, 'r')

plt.xlabel('Hours Studied')
plt.ylabel('Test Grade')
plt.title('Hours vs Grade')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1472140762463343, 'fraction_numerical': 0.005865102639296188, 'mean_word_length': 9.035294117647059, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 26, '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': '249065', 'license': 'MIT', 'n_tokens_mistral': 651, 'n_tokens_neox': 620, 'n_words': 101, 'path': '03 - Regression/Batch1/01-Linear Regression.ipynb', 'repo_name': 'madhu0309/Internship', 'size': '1705'}