<jupyter_start><jupyter_text>La matrice de variance-covariance a les variances pour diagonale :<jupyter_code>V = cov(A, B, bias=True)
print(V)
covAB = V[0][1]
varA = V[0][0]
varB = V[1][1]
EA = mean(A)
EB = mean(B)
stdDevA = sqrt(varA)
stdDevB = sqrt(varB)
corr = covAB / (stdDevA * stdDevB)
print(covAB)
print(corr)<jupyter_output>1.4652777777777772
0.10130489326551938<jupyter_text>La corrélation entre A et B est très faible, le modèle linéaire est donc inadapté.<jupyter_code>B2approx = covAB/varA
B1approx = EB - B2approx * EA
print(B1approx)
print(B2approx)<jupyter_output>11.990281329923274
0.10792838874680304<jupyter_text>On obtient la droite de régression y = 11.99 + 0.11 x (qui ne nous servira pas à grand-chose, vu la qualité de l’approximation) Effaçons maintenant les deux dernières observations.<jupyter_code>del A[10:12]
del B[10:12]
print(A)
print(B)<jupyter_output>[3.0, 4.0, 6.0, 7.0, 9.0, 10.0, 9.0, 11.0, 12.0, 13.0]
[8.0, 9.0, 10.0, 13.0, 15.0, 14.0, 13.0, 16.0, 13.0, 19.0]<jupyter_text>Et c’est reparti.<jupyter_code>V = cov(A, B, bias=True)
covAB = V[0][1]
varA = V[0][0]
varB = V[1][1]
EA = mean(A)
EB = mean(B)
stdDevA = sqrt(varA)
stdDevB = sqrt(varB)
corr = covAB / (stdDevA * stdDevB)
print(corr)<jupyter_output>0.898205382062774<jupyter_text>Ah-hah, la corrélation est nettement meilleure quand on enlève les points dérangeants.<jupyter_code>B2approx = covAB/varA
B1approx = EB - B2approx * EA
print(B1approx)
print(B2approx)<jupyter_output>5.470119521912349
0.8964143426294822
{'fraction_non_alphanumeric': 0.14049039098740887, 'fraction_numerical': 0.13783962889330684, 'mean_word_length': 5.711111111111111, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '424153', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 820, 'n_tokens_neox': 695, 'n_words': 151, 'path': 'TD 2/Partie 2, Exercice 2.ipynb', 'repo_name': 'oliviercailloux/AD', 'size': '1509'}