<jupyter_start><jupyter_text>IA - Regrassão Linear, usando codigo ao inver de usar as formulas prontas das diversas bibliotecas como Numpy<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_boston
# compor a biblioteca
boston = load_boston()

# print(boston.DESCR )<jupyter_output><empty_output><jupyter_text>Formula minimizar o erro quadratico medio (MCO): $\beta =  $\(X^(T)X)^(-1)X^(T)Y$<jupyter_code># pega o numero de habitantes em boston, passa a x,y convertido em array
X = np.array(boston.data[:, 5])
Y = np.array(boston.target)

# Plota a matriz
plt.scatter(X, Y, alpha=0.4)

#print(X)  // numero de habitação
#print(Y)  // valor medio de venda

# Adicionar uma coluna de 1 para termos independentes
X = np.array([np.ones(506), X]).T # Transposta

#print(X)

# multiplica pela matrix transposta
B = np.linalg.inv(X.T @ X) @ X.T @ Y

plt.plot([4,9], [B[0] + B[1] * 4, B[0] + B[1] * 9], c="red")
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14343434343434344, 'fraction_numerical': 0.01616161616161616, 'mean_word_length': 5.006060606060606, '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': '562488', 'license': 'MIT', 'n_tokens_mistral': 416, 'n_tokens_neox': 407, 'n_words': 107, 'path': 'IA_Regressao_Linear.ipynb', 'repo_name': 'neviim/regresionLinear', 'size': '990'}