<jupyter_start><jupyter_text>Scikit-learn>this notebook illustrates how to draw a simple regression line using the SciKit library.>For Scikit-learn to work correctly, you’ll need a 64-bit version of Python 3, and the NumPy and SciPy libraries. For visual data plots, you’ll also need matplotlib.  Import Scikit-learn - Matplolib - Sklearn<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Generate synthetic regression datajust for the sake of testing we're going to generate synthetic variable to define our 2 our variables (regressors, X) and (predictor, Y).first we need to reshape X into 2d array as required by SciKit library, for more info refer to  :https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.htmlsklearn.linear_model.LinearRegression.fit<jupyter_code>np.random.seed(5)
x = np.arange(20, 60).reshape((-1, 1))                       # AGEs 
y = np.sort(np.random.randint(25000, 35000, size=40))        # INCOMEs
model = LinearRegression()
model.fit(x.reshape(-1,1),y.reshape(-1,1))
print(f"intercept\t {model.intercept_[0]}\nSlope\t\t {model.coef_[0,0]}\nR Squared\t {model.score(x,y)}")
y_hat = model.predict(x.reshape(-1,1))
plt.plot(x, y, 'o', label='original data')
plt.plot(x, y_hat, 'r', label='fitted line')
plt.legend()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11911357340720222, 'fraction_numerical': 0.022853185595567867, 'mean_word_length': 5.337719298245614, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 1, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '27915', 'license': 'MIT', 'n_tokens_mistral': 524, 'n_tokens_neox': 489, 'n_words': 133, 'path': 'Linear_Regression/Simply_Linear_Regression_by_SKlearn.ipynb', 'repo_name': 'akladyous/Machine-Learning', 'size': '1444'}