UE1.3 · 6 ECTS

Mathématiques & Statistiques

45h CM + 45h TP — 8 séances. Les fondements mathématiques du Machine Learning : logique, probabilités, statistiques.

8 Séances45h CM45h TP6 ECTS
1

Logique propositionnelle et tables de vérité

Semaine 13CM+TP · 2h

Définitions

Proposition : Assertion vraie ou fausse. Conjonction (ET/∧) : vraie si les DEUX sont vraies. Disjonction (OU/∨) : vraie si AU MOINS UNE est vraie.

Lois de De Morgan : ¬(P∧Q) ≡ ¬P∨¬Q et ¬(P∨Q) ≡ ¬P∧¬Q — très utilisées en programmation.

Python
# Tables de vérité
for p in [True, False]:
    for q in [True, False]:
        print(f"{p} {q} | {p and q} | {p or q} | {not p}")

# Vérification De Morgan
assert not (p and q) == (not p) or (not q)
assert not (p or q)  == (not p) and (not q)

# Application : validation d'accès
age = 20; a_carte = True; est_employe = False
if (age >= 18 and a_carte) or est_employe:
    print("Accès autorisé")
2

Ensembles et combinatoire

Semaine 14CM+TP · 2h

Arrangement P(n,k) = n!/(n-k)! — ordre compte. Combinaison C(n,k) = n!/[k!(n-k)!] — ordre ne compte pas.

Python
import math
DATA = {"Python","SQL","Power BI","ML"}
IoT = {"Python","Arduino","MQTT","Réseaux"}
print("Union:", DATA | IoT)
print("Intersection:", DATA & IoT)

n, k = 10, 3
print(f"A({n},{k}) = {math.perm(n,k)}")  # 720
print(f"C({n},{k}) = {math.comb(n,k)}")  # 120

# Principe multiplicatif
print(f"Menus : {4 * 5 * 3}")  # 60
3

Probabilités fondamentales et formule de Bayes

Semaine 15CM+TP · 2h

Formule de Bayes : P(A|B) = P(B|A)·P(A) / P(B). Fondamental en IA bayésienne et diagnostic médical.

Python
# Bayes — test malaria Madagascar
P_M = 0.05      # Prévalence 5%
P_T_M = 0.98    # Sensibilité 98%
P_T_S = 0.03    # Faux positifs 3%

P_T = P_T_M * P_M + P_T_S * (1 - P_M)
P_M_sachant_T = P_T_M * P_M / P_T

print(f"P(test+) = {P_T:.4f}")
print(f"P(Malade|Test+) = {P_M_sachant_T:.4f}")
# Même avec un excellent test, si la maladie est rare,
# beaucoup de positifs sont des faux positifs !
4

Distributions discrètes — Binomiale et Poisson

Semaine 16CM+TP · 2h
Python
from scipy import stats; import numpy as np; import matplotlib.pyplot as plt

# Binomiale B(n=20, p=0.3) — sur 20 clients, 30% achètent
binom = stats.binom(n=20, p=0.3)
print(f"P(X=6) = {binom.pmf(6):.4f}")
print(f"P(X<=5) = {binom.cdf(5):.4f}")
print(f"E[X] = {binom.mean()}")  # 6

# Poisson Po(λ=5) — moyenne 5 clients/heure
poisson = stats.poisson(mu=5)
print(f"P(X=0) = {poisson.pmf(0):.4f}")

# Visualisation
x = np.arange(0, 15)
plt.bar(x-0.2, binom.pmf(x), width=0.4, label="Binomiale(20,0.3)")
plt.bar(x+0.2, poisson.pmf(x), width=0.4, label="Poisson(5)")
plt.legend()
plt.savefig("distributions_discrètes.png")
5

Statistiques descriptives — tendance centrale et dispersion

Semaine 17CM+TP · 2h
MesureDéfinitionPropriété
Moyenne μΣxi/nSensible aux outliers
MédianeValeur centrale après triRobuste aux outliers
Écart-type σ√VarianceMême unité que les données
IQRQ3 - Q1Mesure robuste
6

Visualisation statistique

Semaine 18CM+TP · 2h

Histogramme : distribution d'une variable continue.
Boxplot : résume min, Q1, médiane, Q3, max + outliers.
QQ-Plot : compare distribution observée à la normale.

7

Loi normale et Théorème Central Limite

Semaine 19CM+TP · 2h

Loi normale N(μ,σ²) : distribution en cloche symétrique. Z-score = (xi-μ)/σ.

TCL : la moyenne d'un grand nombre de variables indépendantes suit approximativement une loi normale, quelle que soit leur distribution d'origine.

IC95% : [μ-1.96σ, μ+1.96σ] — 95% des observations.

8

Corrélation et régression linéaire simple

Semaine 20CM+TP · 2h
ConceptDéfinition
r de PearsonForce relation linéaire entre 2 variables. r ∈ [-1,1]. |r|>0.7 = forte
Coefficient de détermination — variance expliquée par le modèle
Régressiony = ax + b — minimise somme carrés des résidus
Résiduy_réel - y_prédit
Python
from scipy import stats
import numpy as np

heures = np.array([2, 4, 6, 8, 10, 12, 14])
notes = np.array([5, 8, 10, 12, 14, 16, 18])

r, p_value = stats.pearsonr(heures, notes)
print(f"r = {r:.3f}")  # Proche de 1 (forte corrélation)

# Régression linéaire
slope, intercept, r_value, p_value, std_err = stats.linregress(heures, notes)
print(f"y = {slope:.2f}x + {intercept:.2f}")
print(f"R² = {r_value**2:.3f}")

# Prédiction
pred = slope * 9 + intercept
print(f"9h d'étude → note prédite = {pred:.1f}/20")