diff --git a/build/tweak_markdown.py b/build/tweak_markdown.py index fc1aaa9e0..442560ae1 100644 --- a/build/tweak_markdown.py +++ b/build/tweak_markdown.py @@ -32,10 +32,11 @@ def clean_write_file(fl): print(f"File: {fl}") add_text = '\n\n\n' yaml, text = content.split('---\n', 2)[1:] + incipit = "Ce contenu accompagne le cours [Python pour la data science](https://pythonds.linogaliana.fr/) de l'ENSAE. \n" if re.search("plotly: true", yaml) is not None: print(f"Tweaking {fl} using YAML header") - content = "---\n"+ yaml + "---\n" \ - + add_text+"\n"+text + content = "---\n" + yaml + "---\n" \ + + "\n" + incipit + add_text + "\n" + text else: print(f"File {fl}: nothing to do") if re.search( diff --git a/content/course/manipulation/04a_webscraping_TP/index.qmd b/content/course/manipulation/04a_webscraping_TP/index.qmd index 1a2ffeee4..5386c7eb0 100644 --- a/content/course/manipulation/04a_webscraping_TP/index.qmd +++ b/content/course/manipulation/04a_webscraping_TP/index.qmd @@ -693,13 +693,11 @@ m.fit_bounds([sw, ne]) La carte obtenue doit ressembler à la suivante: -{{{< rawhtml >}}} ```{python} -#| echo : false +#| eval : false # Afficher la carte m ``` -{{{< /rawhtml >}}} # Récupérer des informations sur les pokemons diff --git a/content/course/manipulation/04c_API_TP/index.qmd b/content/course/manipulation/04c_API_TP/index.qmd index 2b0191e8c..23dfa5621 100644 --- a/content/course/manipulation/04c_API_TP/index.qmd +++ b/content/course/manipulation/04c_API_TP/index.qmd @@ -39,6 +39,10 @@ print_badges("content/course/manipulation/04c_API_TP.qmd") ``` ::: + + +__La partie utilisant l'API DVF n'est plus à jour, elle sera mise à jour prochainement__ + # Introduction : Qu'est-ce qu'une API ? ## Définition @@ -278,13 +282,12 @@ def interactive_map_dpe(dpe): m = interactive_map_dpe(dpe) ``` -{{{< rawhtml >}}} ```{python} -#| echo : false +#| echo : true +#| eval: false # Afficher la carte m ``` -{{{< /rawhtml >}}} On remarque un problème dans les données: un logement qui n'a rien à voir avec les autres. Il faudrait donc idéalement @@ -328,13 +331,12 @@ dpe_geo_filter = get_dpe_from_url(url_api) m_geo_filter = interactive_map_dpe(dpe) ``` -{{{< rawhtml >}}} ```{python} -#| echo : false +#| echo : true +#| eval: false # Afficher la carte m_geo_filter ``` -{{{< /rawhtml >}}} ## Un catalogue incomplet d'API existantes @@ -411,6 +413,7 @@ groupes par exemple ```{python} #| echo: false #| include: false +#| eval: false # Question 1 import json @@ -428,6 +431,7 @@ ressembler au `DataFrame` suivant: ```{python} #| echo: false +#| eval: false # Question 2 maisons = requests.get("http://api.cquest.org/dvf?code_commune=29168&type_local=Maison").json() @@ -437,6 +441,7 @@ pd.json_normalize(maisons["resultats"]) ```{python} #| echo: false +#| eval: false # Question 3 #!pip install geopandas @@ -450,6 +455,7 @@ L'histogramme des prix de vente (question 4) aura l'aspect suivant: ```{python} #| echo: false #| include: false +#| eval: false # Question 4 p = ventes["valeur_fonciere"].plot(kind = "hist") @@ -466,6 +472,8 @@ convertir en objet `geopandas`. ```{python} +#| eval: false + ventes = ventes.dropna(subset = ['lat','lon']) ventes = gpd.GeoDataFrame(ventes, geometry=gpd.points_from_xy(ventes.lon, ventes.lat)) ventes @@ -477,6 +485,7 @@ sa représentation avec `folium` ([voir la doc `geopandas` à ce propos](https://geopandas.readthedocs.io/en/latest/gallery/polygon_plotting_with_folium.html#Add-polygons-to-map)): ```{python} +#| eval: false geo_j = plgf.to_json() ``` @@ -485,6 +494,7 @@ le comprendre et pas uniquement de l'exécuter). ```{python} #| output: hide +#| eval: false import folium import numpy as np @@ -515,18 +525,11 @@ m.fit_bounds([sw, ne]) ```{python} -#| eval : false -# Afficher la carte -m -``` - -{{{< rawhtml >}}} -```{python} -#| echo : false +#| echo : true +#| eval: false # Afficher la carte m ``` -{{{< /rawhtml >}}} @@ -748,13 +751,12 @@ m.fit_bounds([sw, ne]) Ce qui permet d'obtenir la carte: -{{{< rawhtml >}}} ```{python} -#| echo : false +#| echo : true +#| eval: false # Afficher la carte m ``` -{{{< /rawhtml >}}} Vous pouvez aller plus loin avec l'exercice suivant. Celui-ci nécessite une fonction pour créer un cercle autour d'un point (source [ici](https://gis.stackexchange.com/questions/289044/creating-buffer-circle-x-kilometers-from-point-using-python/289923)), diff --git a/content/course/modelisation/6_pipeline/index.qmd b/content/course/modelisation/6_pipeline/index.qmd index 9c9c887a9..3e23b2553 100644 --- a/content/course/modelisation/6_pipeline/index.qmd +++ b/content/course/modelisation/6_pipeline/index.qmd @@ -142,15 +142,12 @@ set_config(display='diagram') pipe ~~~ -{{{< rawhtml >}}} - ```{python} -#| output: asis +#| eval: false #| echo: false print(estimator_html_repr(pipe)) ``` -{{{< /rawhtml >}}} Au sein d'une étape de *pipeline*, les paramètres d'un estimateur sont accessibles avec la notation `__`. @@ -165,15 +162,12 @@ param_grid = {"reduce_dim__n_components":[2, 5, 10], "clf__C":[0.1, 10, 100]} grid_search = GridSearchCV(pipe, param_grid=param_grid) ``` -{{{< rawhtml >}}} - ```{python} -#| output: asis +#| eval: asis #| echo: false print(estimator_html_repr(grid_search)) ``` -{{{< /rawhtml >}}} ## Données utilisées @@ -396,15 +390,12 @@ ce _pipeline_ opère: pipe ~~~ -{{{< rawhtml >}}} - ```{python} -#| output: asis +#| eval: asis #| echo: false print(estimator_html_repr(pipe)) ``` -{{{< /rawhtml >}}} Maintenant, il ne reste plus qu'à estimer notre modèle sur l'ensemble @@ -615,16 +606,12 @@ end_time = time.time() print("Elapsed time : {} seconds", int(end_time - start_time)) ``` -{{{< rawhtml >}}} - ```{python} -#| output: asis +#| eval: false #| echo: false print(estimator_html_repr(grid_search)) ``` -{{{< /rawhtml >}}} - ```{python} #| echo: false print("Elapsed time : {} seconds", int(end_time - start_time)) @@ -644,15 +631,12 @@ grid_search.best_estimator_ ~~~ -{{{< rawhtml >}}} - ```{python} -#| output: asis +#| eval: false #| echo: false print(estimator_html_repr(grid_search.best_estimator_)) ``` -{{{< /rawhtml >}}} Toutes les performances sur les ensembles d'échantillons et de test sur la grille d'hyperparamètres sont disponibles dans l'attribut: @@ -970,15 +954,12 @@ pipe2 = Pipeline([ ]) ``` -{{{< rawhtml >}}} - ```{python} -#| output: asis +#| eval: false #| echo: false print(estimator_html_repr(pipe2)) ``` -{{{< /rawhtml >}}} ```{python} preprocessor = ColumnTransformer( @@ -990,15 +971,12 @@ pipe3 = Pipeline(steps=[('preprocessor', preprocessor), ('randomforest', regr)]) ``` -{{{< rawhtml >}}} - ```{python} -#| output: asis +#| eval: false #| echo: false print(estimator_html_repr(pipe3)) ``` -{{{< /rawhtml >}}} # Références diff --git a/content/course/visualisation/maps/index.qmd b/content/course/visualisation/maps/index.qmd index 1f4d0364b..fdc183504 100644 --- a/content/course/visualisation/maps/index.qmd +++ b/content/course/visualisation/maps/index.qmd @@ -44,14 +44,15 @@ print_badges("content/course/visualisation/maps.qmd") ::: + La pratique de la cartographie se fera, dans ce cours, en répliquant des cartes qu'on peut trouver sur la page de l'*open-data* de la ville de Paris [ici](https://opendata.paris.fr/explore/dataset/comptage-velo-donnees-compteurs/information/?disjunctive.id_compteur&disjunctive.nom_compteur&disjunctive.id&disjunctive.name). ::: {.cell .markdown} ```{=html} -