11 Commits

10 changed files with 1387 additions and 486 deletions

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Loïc GUEZO and chahrazad DAHMANI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -3,7 +3,7 @@
> A **University of Paris-Est Créteil (UPEC)** Semester 6 project. > A **University of Paris-Est Créteil (UPEC)** Semester 6 project.
## Documentation ## Documentation
- 🇫🇷 [Version Française](https://guezoloic.github.io/millesima-ai-engine) - 🇫🇷 [Version Française](https://millesima-ai.github.guezoloic.com)
> note: only french version enabled for now. > note: only french version enabled for now.
--- ---
@@ -12,7 +12,7 @@
1. **Clone the repository:** 1. **Clone the repository:**
```bash ```bash
git clone https://github.com/votre-pseudo/millesima-ai-engine.git git clone https://github.com/guezoloic/millesima-ai-engine.git
cd millesima-ai-engine cd millesima-ai-engine
``` ```

View File

@@ -5,12 +5,12 @@ Lobjectif de ce projet est détudier, en utilisant des méthodes dappre
## projet ## projet
<div style="text-align: center;"> <div style="text-align: center;">
<object <object
data="/millesima-ai-engine/projet.pdf" data="/projet.pdf"
type="application/pdf" type="application/pdf"
width="100%" width="100%"
height="1000px" height="1000px"
> >
<p>Votre navigateur ne peut pas afficher ce PDF. <p>Votre navigateur ne peut pas afficher ce PDF.
<a href="/millesima-ai-engine/projet.pdf">Cliquez ici pour le télécharger.</a></p> <a href="/projet.pdf">Cliquez ici pour le télécharger.</a></p>
</object> </object>
</div> </div>

1287
docs/learning.ipynb Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
site_name: "Projet Millesima S6" site_name: "Projet Millesima S6"
site_url: "https://github.guezoloic.com/millesima-ai-engine/" site_url: "https://millesima-ai.github.guezoloic.com"
theme: theme:
name: "material" name: "material"
@@ -7,6 +7,7 @@ theme:
plugins: plugins:
- search - search
- mkdocstrings - mkdocstrings
- mkdocs-jupyter
extra: extra:
generator: false generator: false

View File

@@ -1,5 +1,5 @@
[project] [project]
name = "projet-millesima-s6" name = "millesima-project-s6"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"requests==2.32.5", "requests==2.32.5",
@@ -7,7 +7,8 @@ dependencies = [
"pandas==2.3.3", "pandas==2.3.3",
"tqdm==4.67.3", "tqdm==4.67.3",
"scikit-learn==1.7.2", "scikit-learn==1.7.2",
"matplotlib==3.10.8" "matplotlib==3.10.8",
"seaborn==0.13.2"
] ]
[tool.pytest.ini_options] [tool.pytest.ini_options]
@@ -16,7 +17,12 @@ testpaths = ["tests"]
[project.optional-dependencies] [project.optional-dependencies]
test = ["pytest==8.4.2", "requests-mock==1.12.1", "flake8==7.3.0"] test = ["pytest==8.4.2", "requests-mock==1.12.1", "flake8==7.3.0"]
doc = ["mkdocs<2.0.0", "mkdocs-material==9.6.23", "mkdocstrings[python]"] doc = [
"mkdocs<2.0.0",
"mkdocs-material==9.6.23",
"mkdocstrings[python]",
"mkdocs-jupyter==0.26.1",
]
[build-system] [build-system]
requires = ["setuptools", "wheel"] requires = ["setuptools", "wheel"]

View File

@@ -97,11 +97,12 @@ class Cleaning:
return self return self
def main() -> None: def main(filename: str | None = None) -> None:
if len(argv) != 2: if not filename:
raise ValueError(f"Usage: {argv[0]} <filename.csv>") if len(argv) != 2:
raise ValueError(f"Usage: {argv[0]} <filename.csv>")
filename = argv[1]
filename = argv[1]
cleaning: Cleaning = ( cleaning: Cleaning = (
Cleaning(filename) Cleaning(filename)
.drop_empty_appellation() .drop_empty_appellation()

View File

@@ -1,93 +1,64 @@
# from typing import Any, Callable
# from pandas import DataFrame
# from sklearn.linear_model import LinearRegression
# from sklearn.preprocessing import StandardScaler
# from sklearn.model_selection import train_test_split
# from sklearn.pipeline import make_pipeline
# import matplotlib.pyplot as plt
# from cleaning import Cleaning
from typing import Any, Callable # class Learning:
from pandas import DataFrame # def __init__(self, vins: DataFrame, target: str) -> None:
from sklearn.linear_model import LinearRegression # self.X = vins.drop(target, axis=1)
from sklearn.preprocessing import StandardScaler # self.y = vins[target]
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
import matplotlib.pyplot as plt
from cleaning import Cleaning # self.X_train, self.X_test, self.y_train, self.y_test = train_test_split(
# self.X, self.y, test_size=0.25, random_state=49
# )
# def evaluate(
# self,
# estimator,
# pretreatment=None,
# fn_score=lambda m, xt, yt: m.score(xt, yt),
# ):
class Learning: # pipeline = make_pipeline(pretreatment, estimator) if pretreatment else estimator
def __init__(self, vins: DataFrame, target: str) -> None: # pipeline.fit(self.X_train, self.y_train)
self.X = vins.drop(target, axis=1) # score = fn_score(pipeline, self.X_test, self.y_test)
self.y = vins[target] # prediction = pipeline.predict(self.X_test)
self.X_train, self.X_test, self.y_train, self.y_test = train_test_split( # return score, prediction
self.X, self.y, test_size=0.25, random_state=49
)
def evaluate( # def draw(self, predictions, y_actual):
self, # plt.figure(figsize=(8, 6))
estimator,
pretreatment=None,
fn_score=lambda m, xt, yt: m.score(xt, yt),
):
pipeline = make_pipeline(pretreatment, estimator) if pretreatment else estimator # plt.scatter(
pipeline.fit(self.X_train, self.y_train) # predictions,
score = fn_score(pipeline, self.X_test, self.y_test) # y_actual,
prediction = pipeline.predict(self.X_test) # alpha=0.5,
# c="royalblue",
# edgecolors="k",
# label="Vins",
# )
return score, prediction # mn = min(predictions.min(), y_actual.min())
# mx = max(predictions.max(), y_actual.max())
# plt.plot(
# [mn, mx],
# [mn, mx],
# color="red",
# linestyle="--",
# lw=2,
# label="Prédiction Parfaite",
# )
def draw(self, predictions, y_actual): # plt.xlabel("Prix estimés (estim_LR)")
plt.figure(figsize=(8, 6)) # plt.ylabel("Prix réels (y_test)")
# plt.title("titre")
# plt.legend()
# plt.grid(True, linestyle=":", alpha=0.6)
plt.scatter( # plt.show()
predictions,
y_actual,
alpha=0.5,
c="royalblue",
edgecolors="k",
label="Vins",
)
mn = min(predictions.min(), y_actual.min())
mx = max(predictions.max(), y_actual.max())
plt.plot(
[mn, mx],
[mn, mx],
color="red",
linestyle="--",
lw=2,
label="Prédiction Parfaite",
)
plt.xlabel("Prix estimés (estim_LR)")
plt.ylabel("Prix réels (y_test)")
plt.title("titre")
plt.legend()
plt.grid(True, linestyle=":", alpha=0.6)
plt.show()
df_vins = (
Cleaning("data.csv")
.drop_empty_appellation()
.fill_missing_scores()
.encode_appellation()
.drop_empty_price()
.getVins()
)
etude = Learning(df_vins, target="Prix")
print("--- Question 16 & 17 ---")
score_simple, estim_simple = etude.evaluate(LinearRegression())
print(f"Score R² (LR Simple) : {score_simple:.4f}")
etude.draw(estim_simple, etude.y_test)
print("\n--- Question 18 ---")
score_std, estim_std = etude.evaluate(
estimator=LinearRegression(), pretreatment=StandardScaler()
)
print(f"Score R² (Standardisation + LR) : {score_std:.4f}")
etude.draw(estim_std, etude.y_test)

View File

@@ -490,11 +490,12 @@ class Scraper:
savestate((page, cache)) savestate((page, cache))
def main() -> None: def main(filename: str | None = None, suburl: str | None = None) -> None:
if len(argv) != 3: if filename is None or suburl is None:
raise ValueError(f"{argv[0]} <filename> <sous-url>") if len(argv) != 3:
filename = argv[1] raise ValueError(f"Usage: python {argv[0]} <filename> <sous-url>")
suburl = argv[2] filename = argv[1]
suburl = argv[2]
scraper: Scraper = Scraper() scraper: Scraper = Scraper()
scraper.getvins(suburl, filename) scraper.getvins(suburl, filename)