mirror of
https://github.com/Ladebeze66/ft_linear_regression.git
synced 2025-12-15 21:56:48 +01:00
10 lines
334 B
Python
10 lines
334 B
Python
import numpy as np
|
|
|
|
# Fonction de coût
|
|
def compute_cost(theta_0, theta_1, X, y):
|
|
m = len(y)
|
|
predictions = theta_0 + theta_1 * X # calcul des prédictions h(θ)
|
|
errors = predictions - y # Erreur entre prédictions et vrai prix
|
|
cost = (1 / (2 * m)) * np.sum(errors **2) # Somme des erreurs quadratiques
|
|
return cost
|