<jupyter_start><jupyter_text>Simple Linear Regression<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd<jupyter_output><empty_output><jupyter_text>Data Loading<jupyter_code>PATH = "../../../Regression/Simple_Linear_Regression/Python/Salary_Data.csv"
dataset = pd.read_csv(PATH)
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, -1].values<jupyter_output><empty_output><jupyter_text>Train Test Split<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.20, 
                                                    random_state=42)<jupyter_output><empty_output><jupyter_text>Model<jupyter_code>from sklearn.linear_model import LinearRegression

regressor = LinearRegression()
regressor.fit(X_train, y_train)
y_pred = regressor.predict(X_test)<jupyter_output><empty_output><jupyter_text>Visualization<jupyter_code>plt.figure(figsize=(12, 8))
plt.scatter(X_train, y_train, color='red')
plt.plot(X_train, regressor.predict(X_train), color='blue')
plt.title("Salary vs Experience (Training Set)")
plt.xlabel("Experience (in years)")
plt.ylabel("Salary")
plt.show()
plt.figure(figsize=(12, 8))
plt.scatter(X_test, y_test, color='red')
plt.plot(X_train, regressor.predict(X_train), color='blue')
plt.title("Salary vs Experience (Test Set)")
plt.xlabel("Experience (in years)")
plt.ylabel("Salary")
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13408939292861907, 'fraction_numerical': 0.00867244829886591, 'mean_word_length': 5.302521008403361, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '599427', 'license': 'MIT', 'n_tokens_mistral': 560, 'n_tokens_neox': 524, 'n_words': 81, 'path': 'Machine Learning Projects/Useful_Code_Examples/Regression/Simple_Linear_Regression.ipynb', 'repo_name': 'samlaubscher/HacktoberFest2020-Contributions', 'size': '1499'}