<jupyter_start><jupyter_text><jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv('Salary_Data.csv')
df.head(10)
df.isnull()
df.duplicated()
X = df[['YearsExperience']].values
Y = df[['Salary']].values
print(X)
print(Y)
plt.scatter(X,Y)
from sklearn.model_selection import train_test_split
x_train , x_test, y_train, y_test = train_test_split(X, Y, test_size= 0.3, random_state = 0)
from sklearn.linear_model import LinearRegression
reg = LinearRegression()
reg.fit(x_train, y_train)
reg.get_params()
reg.coef_
reg.intercept_
reg.score(x_test,y_test)
result = reg.predict(x_test)
result
plt.figure()
plt.scatter(x_train,y_train,color = 'blue')
plt.plot(x_train,reg.predict(x_train), color = 'red')
plt.xticks(range(0,12))
plt.xlabel("Experience in Years")
plt.ylabel("Salary")
plt.figure()
plt.scatter(x_test,y_test,color = 'blue')
plt.plot(x_test,reg.predict(x_test), color = 'red')
plt.xticks(range(0,12))
plt.xlabel("Experience in Years")
plt.ylabel("Salary")
plt.figure()
plt.scatter(x_test, y_test, color = 'red', label = 'Test Data')
plt.scatter(x_train,y_train, color = 'blue', label = 'Training Data')
plt.plot(X,reg.predict(X), color = 'green', label = 'Regression Line')
plt.xlabel('Experience in Years')
plt.ylabel('Salary')
plt.legend()
result = reg.predict(x_test)
print(result)
y_test<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15868477483917084, 'fraction_numerical': 0.007862759113652609, 'mean_word_length': 7.333333333333333, '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': '468248', 'license': 'Apache-2.0', 'n_tokens_mistral': 584, 'n_tokens_neox': 554, 'n_words': 108, 'path': 'SESSION_13_(SLR).ipynb', 'repo_name': 'madhavjk/DataScience-ML_and_DL', 'size': '1399'}