<jupyter_start><jupyter_text>**Import the libraries.**<jupyter_code>import numpy as np #library used for working with arrays.
import matplotlib.pyplot as plt #data visualization and graphical plotting library.
import pandas as pd #library written for the Python programming language for data manipulation.<jupyter_output><empty_output><jupyter_text>**Import the dataset.**In this section i am going to use dataset downloaded by me from https://www.kaggle.com/tmcketterick/heights-and-weights.<jupyter_code>dataset = pd.read_csv('../input/heights-and-weights/data.csv')
dataset.head() #returns top 5 rows from dataset.
dataset.count()<jupyter_output><empty_output><jupyter_text>This data set gives average masses for women as a function of their height in a sample of American women of age 30–39. The data contains the variables:Height (m)Weight (kg).<jupyter_code>X = dataset.iloc[:, :-1].values #returns all rows and first column
y = dataset.iloc [:, -1].values #returns all rows and last column<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)
#test_size - represent the proportion of the dataset to include in the train split.<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.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') #show the result of the training set
plt.title('Height vs Weight (Training Set)')
plt.xlabel('Height (m)')
plt.ylabel('Weight (kg)')
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') #show the result of the training set
plt.title('Height vs Weight (Test Set)')
plt.xlabel('Height (m)')
plt.ylabel('Weight (kg)')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11655683690280066, 'fraction_numerical': 0.004118616144975288, 'mean_word_length': 7.290102389078498, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '572000', 'license': 'Apache-2.0', 'n_tokens_mistral': 818, 'n_tokens_neox': 780, 'n_words': 218, 'path': 'simple-linear-regression-example.ipynb', 'repo_name': 'kamisettysaisupreeth/machine-learning-linear-regression-mini-project', 'size': '2428'}