<jupyter_start><jupyter_text>Regressão Múltipla<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import math
dataset = pd.read_csv('../0_datasets/house_prices.csv')
dataset.head()
dataset.drop(labels=['id','date'], axis=1, inplace=True)
dataset.head()
fig, ax = plt.subplots(figsize=(15,15))
ax = sns.heatmap(dataset.corr(), annot=True)
X = dataset.iloc[:, [2,3,9,10]].values
X
y = dataset.iloc[:, 0].values
y
from sklearn.model_selection import train_test_split
X_treinamento, X_teste, y_treinamento, y_teste = train_test_split(X, y, test_size=0.2, random_state=1)
from sklearn.linear_model import LinearRegression

regressor = LinearRegression()
regressor.fit(X_treinamento, y_treinamento)
regressor.score(X_teste, y_teste)<jupyter_output><empty_output><jupyter_text>Métricas de erros<jupyter_code>previsoes = regressor.predict(X_teste)
previsoes, y_teste
from sklearn.metrics import mean_absolute_error, mean_squared_error
mean_absolute_error(y_teste, previsoes)
mean_squared_error(y_teste, previsoes)
math.sqrt(mean_squared_error(y_teste, previsoes))
f, ax = plt.subplots(2,2)
ax[0,0].hist(X[0])
ax[0,1].hist(X[1])
ax[1,0].hist(X[2])
ax[1,1].hist(X[3])
plt.hist(y)
y = np.log(y)
plt.hist(y)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1405152224824356, 'fraction_numerical': 0.02263856362217018, 'mean_word_length': 8.639097744360901, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '641099', 'license': 'MIT', 'n_tokens_mistral': 552, 'n_tokens_neox': 529, 'n_words': 89, 'path': '9_correlacao_regressao/regressao_multipla.ipynb', 'repo_name': 'AlissonRaphael/statistics_for_data_science_and_machine_learning', 'size': '1281'}