<jupyter_start><jupyter_text>$a={\frac {\sum_{i=1}^m \left({x^{\left(i \right)}} - \overline x\right) \left({y^{\left(i \right)}} - \overline y\right)}{\sum_{i=1}^m{\left({x^{\left(i \right)}} - \overline x\right)^2}}}$      $b = \overline y - a\overline x$<jupyter_code>x_mean = np.mean(x)
y_mean = np.mean(y)
num = 0.0
d = 0.0
for x_i, y_i in zip(x, y):
    num += (x_i - x_mean) * (y_i - y_mean)
    d += (x_i - x_mean) ** 2
a = num / d
b = y_mean - a * x_mean
a
b
y_hat = a * x + b
plt.scatter(x ,y)
plt.plot(x, y_hat, color='r')
plt.axis([0, 6, 0, 6])
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.24790619765494137, 'fraction_numerical': 0.020100502512562814, 'mean_word_length': 3.3649635036496353, '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': '227025', 'license': 'MIT', 'n_tokens_mistral': 298, 'n_tokens_neox': 284, 'n_words': 63, 'path': 'data/09-Simple-Linear-Regression.ipynb', 'repo_name': 'IIMostro/machine-learning', 'size': '597'}