<jupyter_start><jupyter_text>Visualización de datos:<jupyter_code>x = np.array([5,15,30,25,35,45,47,55]).reshape((-1,1))
y = np.array([5,20,18,14,32,22,32,38])

plt.scatter(x,y)
def train_linear(x,y):
    x_mean = np.mean(x)
    y_mean = np.mean(y)
    xy_dot = np.dot(x.T,y)
    n      = len(x)
    
    w0 = (y_mean*sum(x**2) - x_mean*xy_dot)/(sum(x**2) - n*x_mean**2) 
    w1 = (xy_dot - n*x_mean*y_mean)/(sum(x**2) - n*x_mean**2)
    
    return w0,w1
print(train_linear(x,y))
def predict_linear(x,w):
    return w[0] + w[1]*x 
w = train_linear(x,y)
y_pred = predict_linear(x,w)

x_test = 20
y_test = predict_linear(x_test,w)

plt.scatter(x,y,color='black')
plt.plot(x,y_pred,marker='*')
plt.plot(x_test,y_test,marker='o')
model = LinearRegression()
model.fit(x,y)
y_sk = model.predict(x)

print(model.intercept_)
print(model.coef_)

plt.plot(x,y_sk,marker='*')
plt.scatter(x,y)<jupyter_output>4.911439805279915
[0.55139487]
{'fraction_non_alphanumeric': 0.20797413793103448, 'fraction_numerical': 0.07543103448275862, 'mean_word_length': 5.071895424836601, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '596195', 'license': 'MIT', 'n_tokens_mistral': 503, 'n_tokens_neox': 461, 'n_words': 54, 'path': 'Materias/MachineLearning_I/S4.1-RLinealSimple.ipynb', 'repo_name': 'jorgeo80/UP_MDC', 'size': '928'}