<jupyter_start><jupyter_text>**12.a. sum(y^2) = sum(x^2)12.b. regressions with different coefficients**<jupyter_code>x1 = pd.DataFrame(np.random.normal(0.0, 1.0, 100))
y1 = 2*x1
# regression 1
data_1= pd.concat([x1, y1], axis = 1)
reg_x = ols("y1~x1+0", data = data_1).fit()
reg_x.summary()
# regression 2
reg_y = ols("x1~y1+0", data = data_1).fit()
reg_y.summary()
x2 = pd.DataFrame(np.random.normal(0, 1, 100))
y2 = pd.DataFrame(np.random.choice(x2[0], size = 100, replace = False))
print("Summation x^2: %f" % np.sum(pow(x2[0], 2)))
print("Summation y^2: %f\n" % np.sum(pow(y2[0], 2)))
# regression 1
data_2 = pd.concat([x2, y2], axis = 1)
reg_x = ols("y2~x2+0", data = data_2).fit()
reg_x.summary()
# regression 2
reg_y = ols("x2~y2+0", data = data_2).fit()
reg_y.summary()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.22057001239157373, 'fraction_numerical': 0.080545229244114, 'mean_word_length': 5.622950819672131, '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': '296551', 'license': 'MIT', 'n_tokens_mistral': 406, 'n_tokens_neox': 378, 'n_words': 70, 'path': 'Chapter 3/Applied Exercises/12.ipynb', 'repo_name': 'arpanganguli/ISLR-Python', 'size': '807'}