<jupyter_start><jupyter_text>Simple Linear Regression<jupyter_code>from google.colab import drive
drive.mount('/content/drive')


drive.mount("/content/drive", force_remount=True)<jupyter_output>Mounted at /content/drive<jupyter_text>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('/content/drive/MyDrive/Machine Learning A-Z (Codes and Datasets)/Part 2 - Regression/Section 4 - Simple Linear Regression/Python/Salary_Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, -1].values<jupyter_output><empty_output><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)<jupyter_output><empty_output><jupyter_text>Training the Simple Linear Regression model on the Training set<jupyter_code>from sklearn.linear_model import LinearRegression
regressor = LinearRegression() # regressor is an object of the Linear Regression Class
regressor.fit(X_train, y_train) # fit method trains the regression model on the training set<jupyter_output><empty_output><jupyter_text>Predicting the Test set results---<jupyter_code>Y_prediction = regressor.predict(X_test)<jupyter_output><empty_output><jupyter_text>Visualising the Training set results<jupyter_code>#before entering here remember that the model was already trained
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("years of experience")
plt.ylabel("salary")
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_test, Y_prediction, color = 'blue')
plt.title (' Salary  vs Experience (Training Set)')
plt.xlabel("years of experience")
plt.ylabel("salary")
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10788973384030419, 'fraction_numerical': 0.003326996197718631, 'mean_word_length': 8.073275862068966, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '524395', 'license': 'MIT', 'n_tokens_mistral': 739, 'n_tokens_neox': 701, 'n_words': 160, 'path': 'ML/Regression/Linear regression/simple_linear_regression.ipynb', 'repo_name': 'ftkhateeb/ML-DL-models', 'size': '2104'}