<jupyter_start><jupyter_text><jupyter_code>import numpy as np
from sklearn.linear_model import LinearRegression
import csv
import matplotlib.pyplot as plt
%matplotlib notebook
with open("/home/gato/Scripts/py_ex/LearnPython-main/files/cars.csv", "r") as f:
    csv_reader = csv.DictReader(f)
    cars = list(csv_reader)
horsepower = [int(keys['Horsepower']) for keys in cars]
torque = [int(keys['Torque']) for keys in cars]
x = np.array(horsepower).reshape(-1,1)
y = np.array(torque).reshape(-1,1)
l_r = LinearRegression()
l_r.fit(x, y)
y_pred = l_r.predict(x)
##
## the interceptor and the slope
alpha = str(round(l_r.intercept_[0], 5)) ## el interceptor[0] y cinco decimales
beta = str(round(l_r.coef_[0][0], 5))
alpha, beta
fig1, ax1 = plt.subplots()
ax1.set_title('interceptor: {} and pendiente: {}'.format(alpha, beta))
ax1.scatter(x, y)
ax1.plot(x, y_pred, c='r', alpha=0.25)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16245883644346873, 'fraction_numerical': 0.019758507135016465, 'mean_word_length': 6.015384615384615, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '80289', 'license': 'MIT', 'n_tokens_mistral': 378, 'n_tokens_neox': 361, 'n_words': 79, 'path': 'reg_linear.ipynb', 'repo_name': 'marioymario/Human_Resourses_attrition', 'size': '911'}