<jupyter_start><jupyter_text>Regressão linear simples<jupyter_code>from sklearn.linear_model import LinearRegression
lr_1 = LinearRegression()
lr_1.fit(X, y)
from sklearn.preprocessing import PolynomialFeatures
pf = PolynomialFeatures(degree=2)
X_poly = pf.fit_transform(X)
lr_2 = LinearRegression()
lr_2.fit(X_poly, y)<jupyter_output><empty_output><jupyter_text>Visualizando os resultados  Regressão linear<jupyter_code>plt.scatter(X, y, color="red")
plt.plot(X, lr_1.predict(X), color="blue")
plt.title('Nível versus Salários (RL)')
plt.xlabel('Nível')
plt.ylabel('Salário')
from sklearn.metrics import mean_squared_error
y_pred = lr_1.predict(X)
rmse = np.sqrt(mean_squared_error(y, y_pred))
print('RMSE {}'.format(rmse))<jupyter_output>RMSE 163388.73519272613<jupyter_text>Regressão polinomial<jupyter_code>plt.scatter(X, y, color="red")
plt.plot(X, lr_2.predict(X_poly), color="blue")
plt.title('Nível versus Salários (RL)')
plt.xlabel('Nível')
plt.ylabel('Salário')
from sklearn.metrics import mean_squared_error
from sklearn.metrics import mean_absolute_error

y_pred = lr_2.predict(X_poly)
mae = mean_absolute_error(y, y_pred)
mse = mean_squared_error(y, y_pred)
rmse = np.sqrt(mean_squared_error(y, y_pred))

print('Comparação enntre metricas de erros:')
print('MAE {}'.format(mae))
print('MSE {}'.format(mse))
print('RMSE {}'.format(rmse))<jupyter_output>Comparação enntre metricas de erros:
MAE 70218.1818181819
MSE 6758833333.333336
RMSE 82212.12400451247
{'fraction_non_alphanumeric': 0.13428766189502386, 'fraction_numerical': 0.04976141785957737, 'mean_word_length': 9.054794520547945, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '398098', 'license': 'MIT', 'n_tokens_mistral': 656, 'n_tokens_neox': 587, 'n_words': 101, 'path': 'aprendizado-de-maquina-i/regressao/salaries.ipynb', 'repo_name': 'andredarcie/my-data-science-notebooks', 'size': '1467'}