<jupyter_start><jupyter_text>Introduction to Machine Learning in Python 1.0 LINEAR REGRESSION.<jupyter_code># Loading the libraries
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd<jupyter_output><empty_output><jupyter_text>The Data<jupyter_code>X = np.array([1,2,3,5,6,7,9,13,15,20]).reshape((-1,1))
y = np.array([2,3,4,6,6,7,8,10,12,13])

print(X)
print(y)
## THE MODEL
model = LinearRegression(normalize=True)

fit = model.fit(X,y)<jupyter_output><empty_output><jupyter_text>MAKING PREDICTIONS<jupyter_code>pred = fit.predict(X)
pred
# predicted against true values
data = {'actual': y, 'predicted': pred}
df = pd.DataFrame(data=data)
df<jupyter_output><empty_output><jupyter_text>MODEL PERFORMANCE coefficient of determination<jupyter_code>print('Coefficient of determination: %.2f' %r2_score(y,pred))<jupyter_output>Coefficient of determination: 0.97<jupyter_text>Mean squared error<jupyter_code>print('Mean squared error: %.2f' %mean_squared_error(y,pred))<jupyter_output>Mean squared error: 0.40<jupyter_text>model coefficient<jupyter_code>print('Coefficient: %.2f' %fit.coef_)<jupyter_output>Coefficient: 0.59<jupyter_text>Model Visualization<jupyter_code>plt.scatter(X,y)
plt.plot(X,pred, color='red')
plt.show()
thanks for watching!!!<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13257305773342837, 'fraction_numerical': 0.03136136849607983, 'mean_word_length': 10.32258064516129, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '138872', 'license': 'MIT', 'n_tokens_mistral': 578, 'n_tokens_neox': 538, 'n_words': 91, 'path': '1.0 Linear Regression.ipynb', 'repo_name': 'clinton-mwachia/Machine-Learning-With-Python', 'size': '1403'}