<jupyter_start><jupyter_text>Calculate b<jupyter_code>div = np.sum(x ** 2) - np.sum(x) ** 2 / len(points)
num = (np.sum(x * y) - (np.sum(x) * np.sum(y)) / len(points))
b = num / div<jupyter_output><empty_output><jupyter_text>Calculate a<jupyter_code>a = (np.sum(y) - b * np.sum(x)) / len(points)
a, b
6 /7, 4 /7
from sklearn import datasets, linear_model
clf = linear_model.LinearRegression()
clf.fit(x, y)
clf.coef_, clf.intercept_
dir(clf)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18471337579617833, 'fraction_numerical': 0.012738853503184714, 'mean_word_length': 5.2105263157894735, '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': '284390', 'license': 'Apache-2.0', 'n_tokens_mistral': 220, 'n_tokens_neox': 213, 'n_words': 39, 'path': 'nbs_gil/m5/playground.ipynb', 'repo_name': 'gilfernandes/fastai-exercises', 'size': '471'}