diff --git a/M2/Machine Learning/TP_3/2025_TP_3_M2_ISF.ipynb b/M2/Machine Learning/TP_3/2025_TP_3_M2_ISF.ipynb index c690af1..e894875 100644 --- a/M2/Machine Learning/TP_3/2025_TP_3_M2_ISF.ipynb +++ b/M2/Machine Learning/TP_3/2025_TP_3_M2_ISF.ipynb @@ -1173,258 +1173,942 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": null, "id": "c39e2ad0", "metadata": {}, "outputs": [ { "data": { - "application/vnd.microsoft.datawrangler.viewer.v0+json": { - "columns": [ + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ { - "name": "index", - "rawType": "int64", - "type": "integer" - }, - { - "name": "CONTRAT_ANCIENNETE", - "rawType": "object", - "type": "string" - }, - { - "name": "FREQUENCE_PAIEMENT_COTISATION", - "rawType": "object", - "type": "string" - }, - { - "name": "GROUPE_KM", - "rawType": "object", - "type": "string" - }, - { - "name": "ZONE_RISQUE", - "rawType": "object", - "type": "string" - }, - { - "name": "GENRE", - "rawType": "object", - "type": "string" - }, - { - "name": "DEUXIEME_CONDUCTEUR", - "rawType": "object", - "type": "unknown" - }, - { - "name": "ENERGIE", - "rawType": "object", - "type": "string" - }, - { - "name": "EQUIPEMENT_SECURITE", - "rawType": "object", - "type": "string" - }, - { - "name": "VALEUR_DU_BIEN", - "rawType": "object", - "type": "string" + "coloraxis": "coloraxis", + "hovertemplate": "x: %{x}
y: %{y}
color: %{z}", + "name": "0", + "texttemplate": "%{z:.2f}", + "type": "heatmap", + "x": [ + "CONTRAT_ANCIENNETE", + "FREQUENCE_PAIEMENT_COTISATION", + "GROUPE_KM", + "ZONE_RISQUE", + "GENRE", + "DEUXIEME_CONDUCTEUR", + "ENERGIE", + "EQUIPEMENT_SECURITE", + "VALEUR_DU_BIEN" + ], + "xaxis": "x", + "y": [ + "CONTRAT_ANCIENNETE", + "FREQUENCE_PAIEMENT_COTISATION", + "GROUPE_KM", + "ZONE_RISQUE", + "GENRE", + "DEUXIEME_CONDUCTEUR", + "ENERGIE", + "EQUIPEMENT_SECURITE", + "VALEUR_DU_BIEN" + ], + "yaxis": "y", + "z": { + "bdata": "AAAAAAAA8D8AAAAAAAAAACoCGzzITrA/jS6+t390sj/aAKYMJa2eP5RMqUS3uZs/ytNpsBVXkz8AAAAAAAAAAJsekiMPM4I/AAAAAAAAAAAAAAAAAADwPwAAAAAAAAAAAAAAAAAAAABgNwyfFOK3Px3tLvtk1qI/VTS7w965nj/DbHQwNU6sP6xOyIjBVMQ/KwIbPMhOsD8AAAAAAAAAAAAAAAAAAPA/JGwWgOwjwz/Y12crRVC2P1AU8aUpk3Y/tZ25v8HgyT9++YWBDBq6PxMKBP1KAMk/ki6+t390sj8AAAAAAAAAACNsFoDsI8M/AAAAAAAA8D8AAAAAAAAAAOzpAHMW1bU/OToUIB5twT+gpoD1ZjrEP/5ATjN+vpg/0gCmDCWtnj9gNwyfFOK3P9jXZytFULY/AAAAAAAAAAAAAAAAAADwPwAAAAAAAAAA2p0N4q1bwz/UsLoqS0u5PxFqf8IHB9E/lEypRLe5mz8d7S77ZNaiP1AU8aUpk3Y/7OkAcxbVtT8AAAAAAAAAAAAAAAAAAPA/AAAAAAAAAAAAAAAAAAAAAOYlMsJ0brs/ytNpsBVXkz9RNLvD3rmeP7edub/B4Mk/OjoUIB5twT/anQ3irVvDPwAAAAAAAAAAAAAAAAAA8D8nEbUEUmnAP+SA2g/TvNE/AAAAAAAAAADDbHQwNU6sP335hYEMGro/oKaA9WY6xD/UsLoqS0u5PwAAAAAAAAAAJxG1BFJpwD8AAAAAAADwP+fmCf6XRco/mx6SIw8zgj+rTsiIwVTEPxIKBP1KAMk//kBOM36+mD8Ran/CBwfRP+YlMsJ0brs/5YDaD9O80T/n5gn+l0XKPwAAAAAAAPA/", + "dtype": "f8", + "shape": "9, 9" + } } ], - "ref": "089d2df2-1504-4d62-9804-f974629bdaaa", - "rows": [ - [ - "10", - "(0,1]", - "MENSUEL", - "[0;20000[", - "C", - "M", - "False", - "ESSENCE", - "VRAI", - "[15000;20000[" - ], - [ - "34", - "(-1,0]", - "MENSUEL", - "[20000;40000[", - "C", - "M", - "True", - "AUTRE", - "FAUX", - "[35000;99999[" - ], - [ - "36", - "(-1,0]", - "MENSUEL", - "[20000;40000[", - "L", - "M", - "False", - "ESSENCE", - "VRAI", - "[0;10000[" - ], - [ - "78", - "(-1,0]", - "MENSUEL", - "[20000;40000[", - "B", - "M", - "False", - "DIESEL", - "FAUX", - "[15000;20000[" - ], - [ - "89", - "(1,2]", - "MENSUEL", - "[20000;40000[", - "C", - "M", - "False", - "ESSENCE", - "FAUX", - "[25000;35000[" - ] - ], - "shape": { - "columns": 9, - "rows": 5 + "layout": { + "coloraxis": { + "colorscale": [ + [ + 0, + "rgb(5,48,97)" + ], + [ + 0.1, + "rgb(33,102,172)" + ], + [ + 0.2, + "rgb(67,147,195)" + ], + [ + 0.3, + "rgb(146,197,222)" + ], + [ + 0.4, + "rgb(209,229,240)" + ], + [ + 0.5, + "rgb(247,247,247)" + ], + [ + 0.6, + "rgb(253,219,199)" + ], + [ + 0.7, + "rgb(244,165,130)" + ], + [ + 0.8, + "rgb(214,96,77)" + ], + [ + 0.9, + "rgb(178,24,43)" + ], + [ + 1, + "rgb(103,0,31)" + ] + ] + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermap": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermap" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Matrice de corrélation des variables catégorielles (V de Cramér)" + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 1 + ] + }, + "yaxis": { + "anchor": "x", + "autorange": "reversed", + "domain": [ + 0, + 1 + ] + } } - }, - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
CONTRAT_ANCIENNETEFREQUENCE_PAIEMENT_COTISATIONGROUPE_KMZONE_RISQUEGENREDEUXIEME_CONDUCTEURENERGIEEQUIPEMENT_SECURITEVALEUR_DU_BIEN
10(0,1]MENSUEL[0;20000[CMFalseESSENCEVRAI[15000;20000[
34(-1,0]MENSUEL[20000;40000[CMTrueAUTREFAUX[35000;99999[
36(-1,0]MENSUEL[20000;40000[LMFalseESSENCEVRAI[0;10000[
78(-1,0]MENSUEL[20000;40000[BMFalseDIESELFAUX[15000;20000[
89(1,2]MENSUEL[20000;40000[CMFalseESSENCEFAUX[25000;35000[
\n", - "
" - ], - "text/plain": [ - " CONTRAT_ANCIENNETE FREQUENCE_PAIEMENT_COTISATION GROUPE_KM \\\n", - "10 (0,1] MENSUEL [0;20000[ \n", - "34 (-1,0] MENSUEL [20000;40000[ \n", - "36 (-1,0] MENSUEL [20000;40000[ \n", - "78 (-1,0] MENSUEL [20000;40000[ \n", - "89 (1,2] MENSUEL [20000;40000[ \n", - "\n", - " ZONE_RISQUE GENRE DEUXIEME_CONDUCTEUR ENERGIE EQUIPEMENT_SECURITE \\\n", - "10 C M False ESSENCE VRAI \n", - "34 C M True AUTRE FAUX \n", - "36 L M False ESSENCE VRAI \n", - "78 B M False DIESEL FAUX \n", - "89 C M False ESSENCE FAUX \n", - "\n", - " VALEUR_DU_BIEN \n", - "10 [15000;20000[ \n", - "34 [35000;99999[ \n", - "36 [0;10000[ \n", - "78 [15000;20000[ \n", - "89 [25000;35000[ " - ] + } }, - "execution_count": 31, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" } ], "source": [ - "vars_categorielles.head()" + "# Matrice de corrélation pour les variables catégorielles (V de Cramér)\n", + "def cramers_v(confusion_matrix):\n", + " \"\"\"Calcule le V de Cramér à partir d'une matrice de contingence\"\"\"\n", + " chi2 = chi2_contingency(confusion_matrix)[0]\n", + " n = confusion_matrix.sum().sum()\n", + " phi2 = chi2 / n\n", + " r, k = confusion_matrix.shape\n", + " phi2corr = max(0, phi2 - ((k-1)*(r-1))/(n-1))\n", + " rcorr = r - ((r-1)**2)/(n-1)\n", + " kcorr = k - ((k-1)**2)/(n-1)\n", + " return np.sqrt(phi2corr / min((kcorr-1), (rcorr-1)))\n", + "\n", + "# Créer la matrice de corrélation\n", + "categorical_cols = vars_categorielles.columns\n", + "n_vars = len(categorical_cols)\n", + "cramers_matrix = np.zeros((n_vars, n_vars))\n", + "\n", + "for i, col1 in enumerate(categorical_cols):\n", + " for j, col2 in enumerate(categorical_cols):\n", + " if i == j:\n", + " cramers_matrix[i, j] = 1.0\n", + " else:\n", + " confusion_matrix = pd.crosstab(vars_categorielles[col1], vars_categorielles[col2])\n", + " cramers_matrix[i, j] = cramers_v(confusion_matrix)\n", + "\n", + "# Créer le DataFrame de corrélation\n", + "correlation_cat = pd.DataFrame(cramers_matrix,\n", + " index=categorical_cols,\n", + " columns=categorical_cols)\n", + "\n", + "# Visualiser avec Plotly\n", + "fig = px.imshow(correlation_cat,\n", + " text_auto='.2f',\n", + " aspect=\"auto\",\n", + " color_continuous_scale='RdBu_r',\n", + " title='Matrice de corrélation des variables catégorielles (V de Cramér)')\n", + "fig.show()" ] }, { @@ -1447,53 +2131,901 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "id": "532ca6c4", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "Matrice de corrélation des variables numériques:\n", - " ANNEE_CTR AGE_ASSURE_PRINCIPAL ANCIENNETE_PERMIS \\\n", - "ANNEE_CTR 1.000000 0.026613 0.040797 \n", - "AGE_ASSURE_PRINCIPAL 0.026613 1.000000 0.540899 \n", - "ANCIENNETE_PERMIS 0.040797 0.540899 1.000000 \n", - "ANNEE_CONSTRUCTION 0.387562 -0.031655 0.033320 \n", - "\n", - " ANNEE_CONSTRUCTION \n", - "ANNEE_CTR 0.387562 \n", - "AGE_ASSURE_PRINCIPAL -0.031655 \n", - "ANCIENNETE_PERMIS 0.033320 \n", - "ANNEE_CONSTRUCTION 1.000000 \n" - ] - }, - { - "ename": "ValueError", - "evalue": "\n Invalid value of type 'builtins.str' received for the 'colorscale' property of imshow\n Received value: 'coolwarm'\n\n The 'colorscale' property is a colorscale and may be\n specified as:\n - A list of colors that will be spaced evenly to create the colorscale.\n Many predefined colorscale lists are included in the sequential, diverging,\n and cyclical modules in the plotly.colors package.\n - A list of 2-element lists where the first element is the\n normalized color level value (starting at 0 and ending at 1),\n and the second item is a valid color string.\n (e.g. [[0, 'green'], [0.5, 'red'], [1.0, 'rgb(0, 0, 255)']])\n - One of the following named colorscales:\n ['aggrnyl', 'agsunset', 'algae', 'amp', 'armyrose', 'balance',\n 'blackbody', 'bluered', 'blues', 'blugrn', 'bluyl', 'brbg',\n 'brwnyl', 'bugn', 'bupu', 'burg', 'burgyl', 'cividis', 'curl',\n 'darkmint', 'deep', 'delta', 'dense', 'earth', 'edge', 'electric',\n 'emrld', 'fall', 'geyser', 'gnbu', 'gray', 'greens', 'greys',\n 'haline', 'hot', 'hsv', 'ice', 'icefire', 'inferno', 'jet',\n 'magenta', 'magma', 'matter', 'mint', 'mrybm', 'mygbm', 'oranges',\n 'orrd', 'oryel', 'oxy', 'peach', 'phase', 'picnic', 'pinkyl',\n 'piyg', 'plasma', 'plotly3', 'portland', 'prgn', 'pubu', 'pubugn',\n 'puor', 'purd', 'purp', 'purples', 'purpor', 'rainbow', 'rdbu',\n 'rdgy', 'rdpu', 'rdylbu', 'rdylgn', 'redor', 'reds', 'solar',\n 'spectral', 'speed', 'sunset', 'sunsetdark', 'teal', 'tealgrn',\n 'tealrose', 'tempo', 'temps', 'thermal', 'tropic', 'turbid',\n 'turbo', 'twilight', 'viridis', 'ylgn', 'ylgnbu', 'ylorbr',\n 'ylorrd'].\n Appending '_r' to a named colorscale reverses it.\n", - "output_type": "error", - "traceback": [ - "\u001b[31m---------------------------------------------------------------------------\u001b[39m", - "\u001b[31mValueError\u001b[39m Traceback (most recent call last)", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[32]\u001b[39m\u001b[32m, line 6\u001b[39m\n\u001b[32m 3\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33m\"\u001b[39m\u001b[33mMatrice de corrélation des variables numériques:\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 4\u001b[39m \u001b[38;5;28mprint\u001b[39m(correlation_matrix)\n\u001b[32m----> \u001b[39m\u001b[32m6\u001b[39m fig = \u001b[43mpx\u001b[49m\u001b[43m.\u001b[49m\u001b[43mimshow\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 7\u001b[39m \u001b[43m \u001b[49m\u001b[43mcorrelation_matrix\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtext_auto\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcolor_continuous_scale\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mcoolwarm\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maspect\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mauto\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\n\u001b[32m 8\u001b[39m \u001b[43m)\u001b[49m\n\u001b[32m 9\u001b[39m fig.update_layout(title=\u001b[33m\"\u001b[39m\u001b[33mMatrice de corrélation des variables numériques\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 10\u001b[39m fig.show()\n", - "\u001b[36mFile \u001b[39m\u001b[32m~/Workspace/studies/.venv/lib/python3.13/site-packages/plotly/express/_imshow.py:423\u001b[39m, in \u001b[36mimshow\u001b[39m\u001b[34m(img, zmin, zmax, origin, labels, x, y, animation_frame, facet_col, facet_col_wrap, facet_col_spacing, facet_row_spacing, color_continuous_scale, color_continuous_midpoint, range_color, title, template, width, height, aspect, contrast_rescaling, binary_string, binary_backend, binary_compression_level, binary_format, text_auto)\u001b[39m\n\u001b[32m 420\u001b[39m layout[\u001b[33m\"\u001b[39m\u001b[33myaxis\u001b[39m\u001b[33m\"\u001b[39m][\u001b[33m\"\u001b[39m\u001b[33mconstrain\u001b[39m\u001b[33m\"\u001b[39m] = \u001b[33m\"\u001b[39m\u001b[33mdomain\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 421\u001b[39m colorscale_validator = ColorscaleValidator(\u001b[33m\"\u001b[39m\u001b[33mcolorscale\u001b[39m\u001b[33m\"\u001b[39m, \u001b[33m\"\u001b[39m\u001b[33mimshow\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m 422\u001b[39m layout[\u001b[33m\"\u001b[39m\u001b[33mcoloraxis1\u001b[39m\u001b[33m\"\u001b[39m] = \u001b[38;5;28mdict\u001b[39m(\n\u001b[32m--> \u001b[39m\u001b[32m423\u001b[39m colorscale=\u001b[43mcolorscale_validator\u001b[49m\u001b[43m.\u001b[49m\u001b[43mvalidate_coerce\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 424\u001b[39m \u001b[43m \u001b[49m\u001b[43margs\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mcolor_continuous_scale\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\n\u001b[32m 425\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m,\n\u001b[32m 426\u001b[39m cmid=color_continuous_midpoint,\n\u001b[32m 427\u001b[39m cmin=zmin,\n\u001b[32m 428\u001b[39m cmax=zmax,\n\u001b[32m 429\u001b[39m )\n\u001b[32m 430\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m labels[\u001b[33m\"\u001b[39m\u001b[33mcolor\u001b[39m\u001b[33m\"\u001b[39m]:\n\u001b[32m 431\u001b[39m layout[\u001b[33m\"\u001b[39m\u001b[33mcoloraxis1\u001b[39m\u001b[33m\"\u001b[39m][\u001b[33m\"\u001b[39m\u001b[33mcolorbar\u001b[39m\u001b[33m\"\u001b[39m] = \u001b[38;5;28mdict\u001b[39m(title_text=labels[\u001b[33m\"\u001b[39m\u001b[33mcolor\u001b[39m\u001b[33m\"\u001b[39m])\n", - "\u001b[36mFile \u001b[39m\u001b[32m~/Workspace/studies/.venv/lib/python3.13/site-packages/_plotly_utils/basevalidators.py:1636\u001b[39m, in \u001b[36mColorscaleValidator.validate_coerce\u001b[39m\u001b[34m(self, v)\u001b[39m\n\u001b[32m 1631\u001b[39m v = [\n\u001b[32m 1632\u001b[39m [e[\u001b[32m0\u001b[39m], ColorValidator.perform_validate_coerce(e[\u001b[32m1\u001b[39m])] \u001b[38;5;28;01mfor\u001b[39;00m e \u001b[38;5;129;01min\u001b[39;00m v\n\u001b[32m 1633\u001b[39m ]\n\u001b[32m 1635\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m v_valid:\n\u001b[32m-> \u001b[39m\u001b[32m1636\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mraise_invalid_val\u001b[49m\u001b[43m(\u001b[49m\u001b[43mv\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1638\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m v\n", - "\u001b[36mFile \u001b[39m\u001b[32m~/Workspace/studies/.venv/lib/python3.13/site-packages/_plotly_utils/basevalidators.py:298\u001b[39m, in \u001b[36mBaseValidator.raise_invalid_val\u001b[39m\u001b[34m(self, v, inds)\u001b[39m\n\u001b[32m 295\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m inds:\n\u001b[32m 296\u001b[39m name += \u001b[33m\"\u001b[39m\u001b[33m[\u001b[39m\u001b[33m\"\u001b[39m + \u001b[38;5;28mstr\u001b[39m(i) + \u001b[33m\"\u001b[39m\u001b[33m]\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m--> \u001b[39m\u001b[32m298\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[32m 299\u001b[39m \u001b[38;5;250m \u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m 300\u001b[39m \u001b[33;03m Invalid value of type {typ} received for the '{name}' property of {pname}\u001b[39;00m\n\u001b[32m 301\u001b[39m \u001b[33;03m Received value: {v}\u001b[39;00m\n\u001b[32m 302\u001b[39m \n\u001b[32m 303\u001b[39m \u001b[33;03m{valid_clr_desc}\"\"\"\u001b[39;00m.format(\n\u001b[32m 304\u001b[39m name=name,\n\u001b[32m 305\u001b[39m pname=\u001b[38;5;28mself\u001b[39m.parent_name,\n\u001b[32m 306\u001b[39m typ=type_str(v),\n\u001b[32m 307\u001b[39m v=\u001b[38;5;28mrepr\u001b[39m(v),\n\u001b[32m 308\u001b[39m valid_clr_desc=\u001b[38;5;28mself\u001b[39m.description(),\n\u001b[32m 309\u001b[39m )\n\u001b[32m 310\u001b[39m )\n", - "\u001b[31mValueError\u001b[39m: \n Invalid value of type 'builtins.str' received for the 'colorscale' property of imshow\n Received value: 'coolwarm'\n\n The 'colorscale' property is a colorscale and may be\n specified as:\n - A list of colors that will be spaced evenly to create the colorscale.\n Many predefined colorscale lists are included in the sequential, diverging,\n and cyclical modules in the plotly.colors package.\n - A list of 2-element lists where the first element is the\n normalized color level value (starting at 0 and ending at 1),\n and the second item is a valid color string.\n (e.g. [[0, 'green'], [0.5, 'red'], [1.0, 'rgb(0, 0, 255)']])\n - One of the following named colorscales:\n ['aggrnyl', 'agsunset', 'algae', 'amp', 'armyrose', 'balance',\n 'blackbody', 'bluered', 'blues', 'blugrn', 'bluyl', 'brbg',\n 'brwnyl', 'bugn', 'bupu', 'burg', 'burgyl', 'cividis', 'curl',\n 'darkmint', 'deep', 'delta', 'dense', 'earth', 'edge', 'electric',\n 'emrld', 'fall', 'geyser', 'gnbu', 'gray', 'greens', 'greys',\n 'haline', 'hot', 'hsv', 'ice', 'icefire', 'inferno', 'jet',\n 'magenta', 'magma', 'matter', 'mint', 'mrybm', 'mygbm', 'oranges',\n 'orrd', 'oryel', 'oxy', 'peach', 'phase', 'picnic', 'pinkyl',\n 'piyg', 'plasma', 'plotly3', 'portland', 'prgn', 'pubu', 'pubugn',\n 'puor', 'purd', 'purp', 'purples', 'purpor', 'rainbow', 'rdbu',\n 'rdgy', 'rdpu', 'rdylbu', 'rdylgn', 'redor', 'reds', 'solar',\n 'spectral', 'speed', 'sunset', 'sunsetdark', 'teal', 'tealgrn',\n 'tealrose', 'tempo', 'temps', 'thermal', 'tropic', 'turbid',\n 'turbo', 'twilight', 'viridis', 'ylgn', 'ylgnbu', 'ylorbr',\n 'ylorrd'].\n Appending '_r' to a named colorscale reverses it.\n" - ] + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "coloraxis": "coloraxis", + "hovertemplate": "x: %{x}
y: %{y}
color: %{z}", + "name": "0", + "texttemplate": "%{z}", + "type": "heatmap", + "x": [ + "ANNEE_CTR", + "AGE_ASSURE_PRINCIPAL", + "ANCIENNETE_PERMIS", + "ANNEE_CONSTRUCTION" + ], + "xaxis": "x", + "y": [ + "ANNEE_CTR", + "AGE_ASSURE_PRINCIPAL", + "ANCIENNETE_PERMIS", + "ANNEE_CONSTRUCTION" + ], + "yaxis": "y", + "z": { + "bdata": "AAAAAAAA8D+ybZcEUUCbP/CBLCtO46Q/qr2Q49LN2D+ybZcEUUCbPwAAAAAAAPA/slV7SAtP4T84L73yETWgv/CBLCtO46Q/slV7SAtP4T8AAAAAAADwP0I6y25dD6E/qr2Q49LN2D84L73yETWgv0I6y25dD6E/AAAAAAAA8D8=", + "dtype": "f8", + "shape": "4, 4" + } + } + ], + "layout": { + "coloraxis": { + "colorscale": [ + [ + 0, + "rgb(5,48,97)" + ], + [ + 0.1, + "rgb(33,102,172)" + ], + [ + 0.2, + "rgb(67,147,195)" + ], + [ + 0.3, + "rgb(146,197,222)" + ], + [ + 0.4, + "rgb(209,229,240)" + ], + [ + 0.5, + "rgb(247,247,247)" + ], + [ + 0.6, + "rgb(253,219,199)" + ], + [ + 0.7, + "rgb(244,165,130)" + ], + [ + 0.8, + "rgb(214,96,77)" + ], + [ + 0.9, + "rgb(178,24,43)" + ], + [ + 1, + "rgb(103,0,31)" + ] + ] + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermap": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermap" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Matrice de corrélation des variables numériques" + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 1 + ] + }, + "yaxis": { + "anchor": "x", + "autorange": "reversed", + "domain": [ + 0, + 1 + ] + } + } + } + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ - "# Calcul des corrélations entre variables numériques\n", - "correlation_matrix = vars_numeriques.corr()\n", - "print(\"Matrice de corrélation des variables numériques:\")\n", - "print(correlation_matrix)\n", - "\n", - "fig = px.imshow(\n", - " correlation_matrix, text_auto=True, color_continuous_scale=\"coolwarm\", aspect=\"auto\"\n", - ")\n", - "fig.update_layout(title=\"Matrice de corrélation des variables numériques\")\n", + "vars_numeriques.corr()\n", + "fig = px.imshow(vars_numeriques.corr(),\n", + " text_auto=True,\n", + " aspect=\"auto\",\n", + " color_continuous_scale='RdBu_r',\n", + " title='Matrice de corrélation des variables numériques')\n", "fig.show()" ] },