Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
aorellanat committed Dec 13, 2024
2 parents 84bd118 + 6dc54ef commit 9a75008
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 217 deletions.
219 changes: 11 additions & 208 deletions docs/_includes/plotly/rq1_metrics.html

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/_includes/plotly/tropes_boxplot.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div> <script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
<script charset="utf-8" src="https://cdn.plot.ly/plotly-2.35.2.min.js"></script> <div id="d17c16f2-0337-4d51-bfc9-739d36f06f60" class="plotly-graph-div" style="height:100%; width:100%;"></div> <script type="text/javascript"> window.PLOTLYENV=window.PLOTLYENV || {}; if (document.getElementById("d17c16f2-0337-4d51-bfc9-739d36f06f60")) { Plotly.newPlot( "d17c16f2-0337-4d51-bfc9-739d36f06f60", [{"alignmentgroup":"True","hovertemplate":"trope=%{y}\u003cbr\u003evote_average=%{x}\u003cextra\u003e\u003c\u002fextra\u003e","legendgroup":"NarrowParody","marker":{"color":"#636efa"},"name":"NarrowParody","notched":false,"offsetgroup":"NarrowParody","orientation":"h","showlegend":true,"x":[8.512,7.04,6.204,6.6,6.345,6.665,7.057,4.031,6.368,3.894,3.894,3.23,3.23,4.153,5.361,5.361,4.897],"x0":" ","xaxis":"x","y":["NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody","NarrowParody"],"y0":" ","yaxis":"y","type":"box"},{"alignmentgroup":"True","hovertemplate":"trope=%{y}\u003cbr\u003evote_average=%{x}\u003cextra\u003e\u003c\u002fextra\u003e","legendgroup":"LadyLand","marker":{"color":"#EF553B"},"name":"LadyLand","notched":false,"offsetgroup":"LadyLand","orientation":"h","showlegend":true,"x":[8.206,4.3,4.3,5.127,5.127,5.141,6.039,6.039,6.184,6.691,5.7,5.032,5.032,4.577,3.455,3.118],"x0":" ","xaxis":"x","y":["LadyLand","LadyLand","LadyLand","LadyLand","LadyLand","LadyLand","LadyLand","LadyLand","LadyLand","LadyLand","LadyLand","LadyLand","LadyLand","LadyLand","LadyLand","LadyLand"],"y0":" ","yaxis":"y","type":"box"},{"alignmentgroup":"True","hovertemplate":"trope=%{y}\u003cbr\u003evote_average=%{x}\u003cextra\u003e\u003c\u002fextra\u003e","legendgroup":"SnarkBait","marker":{"color":"#00cc96"},"name":"SnarkBait","notched":false,"offsetgroup":"SnarkBait","orientation":"h","showlegend":true,"x":[7.777,6.254,6.254,6.406,5.191,7.041,4.662,5.605,5.767,5.768,7.911,4.3,4.515,6.956,3.228,3.228,4.029,3.888,5.1,3.702,5.6,5.333],"x0":" ","xaxis":"x","y":["SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait","SnarkBait"],"y0":" ","yaxis":"y","type":"box"},{"alignmentgroup":"True","hovertemplate":"trope=%{y}\u003cbr\u003evote_average=%{x}\u003cextra\u003e\u003c\u002fextra\u003e","legendgroup":"ArtisticLicenseNuclearPhysics","marker":{"color":"#ab63fa"},"name":"ArtisticLicenseNuclearPhysics","notched":false,"offsetgroup":"ArtisticLicenseNuclearPhysics","orientation":"h","showlegend":true,"x":[7.777,7.925,6.341,6.04,5.572,6.026,6.175,5.127,6.478,4.21,7.133,3.75,3.75,2.256,4.4,3.1],"x0":" ","xaxis":"x","y":["ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics","ArtisticLicenseNuclearPhysics"],"y0":" ","yaxis":"y","type":"box"},{"alignmentgroup":"True","hovertemplate":"trope=%{y}\u003cbr\u003evote_average=%{x}\u003cextra\u003e\u003c\u002fextra\u003e","legendgroup":"VoodooShark","marker":{"color":"#FFA15A"},"name":"VoodooShark","notched":false,"offsetgroup":"VoodooShark","orientation":"h","showlegend":true,"x":[6.928,6.869,7.606,6.126,5.5,5.605,6.216,6.216,5.415,4.052,4.052,4.716,4.716,3.228,4.824,4.824,4.774,3.512,5.976,2.893,4.34],"x0":" ","xaxis":"x","y":["VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark","VoodooShark"],"y0":" ","yaxis":"y","type":"box"},{"alignmentgroup":"True","hovertemplate":"trope=%{y}\u003cbr\u003evote_average=%{x}\u003cextra\u003e\u003c\u002fextra\u003e","legendgroup":"MonsterMisogyny","marker":{"color":"#19d3f3"},"name":"MonsterMisogyny","notched":false,"offsetgroup":"MonsterMisogyny","orientation":"h","showlegend":true,"x":[8.3,7.562,7.307,4.031,3.894,3.23,7.6,5.442,5.8,5.219,4.696,4.955,4.955,2.256,4.743,4.743,2.7],"x0":" ","xaxis":"x","y":["MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny","MonsterMisogyny"],"y0":" ","yaxis":"y","type":"box"},{"alignmentgroup":"True","hovertemplate":"trope=%{y}\u003cbr\u003evote_average=%{x}\u003cextra\u003e\u003c\u002fextra\u003e","legendgroup":"OurDemonsAreDifferent","marker":{"color":"#FF6692"},"name":"OurDemonsAreDifferent","notched":false,"offsetgroup":"OurDemonsAreDifferent","orientation":"h","showlegend":true,"x":[8.147,7.841,7.321,6.29,5.297,5.948,5.948,4.265,7.042,3.419,3.419,4.714,4.714,4.704,3.6,3.6],"x0":" ","xaxis":"x","y":["OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent","OurDemonsAreDifferent"],"y0":" ","yaxis":"y","type":"box"},{"alignmentgroup":"True","hovertemplate":"trope=%{y}\u003cbr\u003evote_average=%{x}\u003cextra\u003e\u003c\u002fextra\u003e","legendgroup":"XtremeKoolLetterz","marker":{"color":"#B6E880"},"name":"XtremeKoolLetterz","notched":false,"offsetgroup":"XtremeKoolLetterz","orientation":"h","showlegend":true,"x":[7.3,7.284,6.0,6.14,7.443,4.515,5.209,5.9,5.9,6.624,5.005,5.005,6.542,4.911,2.8,1.0,1.0],"x0":" ","xaxis":"x","y":["XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz","XtremeKoolLetterz"],"y0":" ","yaxis":"y","type":"box"},{"alignmentgroup":"True","hovertemplate":"trope=%{y}\u003cbr\u003evote_average=%{x}\u003cextra\u003e\u003c\u002fextra\u003e","legendgroup":"NotScreenedForCritics","marker":{"color":"#FF97FF"},"name":"NotScreenedForCritics","notched":false,"offsetgroup":"NotScreenedForCritics","orientation":"h","showlegend":true,"x":[5.609,8.015,5.738,5.822,6.04,6.097,4.577,5.795,6.122,6.317,6.219,5.415,5.491,4.031,3.894,4.3,3.23,5.837,5.369,5.279,4.379,4.34,4.385,4.824,6.195,4.296,4.262],"x0":" ","xaxis":"x","y":["NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics","NotScreenedForCritics"],"y0":" ","yaxis":"y","type":"box"},{"alignmentgroup":"True","hovertemplate":"trope=%{y}\u003cbr\u003evote_average=%{x}\u003cextra\u003e\u003c\u002fextra\u003e","legendgroup":"Slurpasaur","marker":{"color":"#FECB52"},"name":"Slurpasaur","notched":false,"offsetgroup":"Slurpasaur","orientation":"h","showlegend":true,"x":[6.944,6.711,6.711,6.809,5.481,5.899,6.64,6.039,6.039,4.368,4.476,4.3,4.3,5.784,4.577,1.857,1.857,3.632],"x0":" ","xaxis":"x","y":["Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur","Slurpasaur"],"y0":" ","yaxis":"y","type":"box"}], {"template":{"data":{"histogram2dcontour":[{"type":"histogram2dcontour","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.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.0,"#f0f921"]]}],"choropleth":[{"type":"choropleth","colorbar":{"outlinewidth":0,"ticks":""}}],"histogram2d":[{"type":"histogram2d","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.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.0,"#f0f921"]]}],"heatmap":[{"type":"heatmap","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.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.0,"#f0f921"]]}],"heatmapgl":[{"type":"heatmapgl","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.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.0,"#f0f921"]]}],"contourcarpet":[{"type":"contourcarpet","colorbar":{"outlinewidth":0,"ticks":""}}],"contour":[{"type":"contour","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.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.0,"#f0f921"]]}],"surface":[{"type":"surface","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.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.0,"#f0f921"]]}],"mesh3d":[{"type":"mesh3d","colorbar":{"outlinewidth":0,"ticks":""}}],"scatter":[{"fillpattern":{"fillmode":"overlay","size":10,"solidity":0.2},"type":"scatter"}],"parcoords":[{"type":"parcoords","line":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterpolargl":[{"type":"scatterpolargl","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"bar":[{"error_x":{"color":"#2a3f5f"},"error_y":{"color":"#2a3f5f"},"marker":{"line":{"color":"white","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"scattergeo":[{"type":"scattergeo","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterpolar":[{"type":"scatterpolar","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"scattergl":[{"type":"scattergl","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatter3d":[{"type":"scatter3d","line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattermapbox":[{"type":"scattermapbox","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterternary":[{"type":"scatterternary","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattercarpet":[{"type":"scattercarpet","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"carpet":[{"aaxis":{"endlinecolor":"#2a3f5f","gridcolor":"#C8D4E3","linecolor":"#C8D4E3","minorgridcolor":"#C8D4E3","startlinecolor":"#2a3f5f"},"baxis":{"endlinecolor":"#2a3f5f","gridcolor":"#C8D4E3","linecolor":"#C8D4E3","minorgridcolor":"#C8D4E3","startlinecolor":"#2a3f5f"},"type":"carpet"}],"table":[{"cells":{"fill":{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":{"color":"#C8D4E3"},"line":{"color":"white"}},"type":"table"}],"barpolar":[{"marker":{"line":{"color":"white","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"pie":[{"automargin":true,"type":"pie"}]},"layout":{"autotypenumbers":"strict","colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f","size":14,"family":"Arial"},"hovermode":"closest","hoverlabel":{"align":"left"},"paper_bgcolor":"white","plot_bgcolor":"white","polar":{"bgcolor":"white","angularaxis":{"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":""},"radialaxis":{"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":""}},"ternary":{"bgcolor":"white","aaxis":{"gridcolor":"#DFE8F3","linecolor":"#A2B1C6","ticks":""},"baxis":{"gridcolor":"#DFE8F3","linecolor":"#A2B1C6","ticks":""},"caxis":{"gridcolor":"#DFE8F3","linecolor":"#A2B1C6","ticks":""}},"coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"sequential":[[0.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.0,"#f0f921"]],"sequentialminus":[[0.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.0,"#f0f921"]],"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"]]},"xaxis":{"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":"","title":{"standoff":15},"zerolinecolor":"#EBF0F8","automargin":true,"zerolinewidth":2},"yaxis":{"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":"","title":{"standoff":15},"zerolinecolor":"#EBF0F8","automargin":true,"zerolinewidth":2},"scene":{"xaxis":{"backgroundcolor":"white","gridcolor":"#DFE8F3","linecolor":"#EBF0F8","showbackground":true,"ticks":"","zerolinecolor":"#EBF0F8","gridwidth":2},"yaxis":{"backgroundcolor":"white","gridcolor":"#DFE8F3","linecolor":"#EBF0F8","showbackground":true,"ticks":"","zerolinecolor":"#EBF0F8","gridwidth":2},"zaxis":{"backgroundcolor":"white","gridcolor":"#DFE8F3","linecolor":"#EBF0F8","showbackground":true,"ticks":"","zerolinecolor":"#EBF0F8","gridwidth":2}},"shapedefaults":{"line":{"color":"#2a3f5f"}},"annotationdefaults":{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"geo":{"bgcolor":"white","landcolor":"white","subunitcolor":"#C8D4E3","showland":true,"showlakes":true,"lakecolor":"white"},"title":{"x":0.05},"mapbox":{"style":"light"}}},"xaxis":{"anchor":"y","domain":[0.0,1.0],"title":{"text":"vote_average"}},"yaxis":{"anchor":"x","domain":[0.0,1.0],"title":{"text":"trope"},"categoryorder":"array","categoryarray":["Slurpasaur","NotScreenedForCritics","XtremeKoolLetterz","OurDemonsAreDifferent","MonsterMisogyny","VoodooShark","ArtisticLicenseNuclearPhysics","SnarkBait","LadyLand","NarrowParody"]},"legend":{"title":{"text":"trope"},"tracegroupgap":0},"title":{"text":"Top 10 tropes with lowest average rating"},"boxmode":"overlay"}, {"responsive": true} ) }; </script> </div>
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ This project is part of the Applied Data Analysis course at EPFL. We've analyzed
*Interactive visualization of trope combinations and their impact on ratings*

<div class="plotly-visualization">
{% include plotly/rq6_tropes.html %}
{% include plotly/tropes_boxplot.html %}
</div>

## Want to Know More?
Expand Down
32 changes: 24 additions & 8 deletions src/utils/get_metrics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -142,23 +142,39 @@
"# Compute ROI\n",
"df['ROI'] = df['profit'] / df['budget']\n",
"\n",
"# Optional: Handle extreme ROI values if necessary\n",
"# For example, limit ROI to a reasonable range\n",
"# df = df[df['ROI'].between(-1, 5)]\n",
"# ------------------------ #\n",
"# 5. Remove Outliers\n",
"# ------------------------ #\n",
"\n",
"# Define a function to remove outliers using IQR method\n",
"def remove_outliers_iqr(data, col):\n",
" Q1 = data[col].quantile(0.25) # First quartile\n",
" Q3 = data[col].quantile(0.75) # Third quartile\n",
" IQR = Q3 - Q1 # Interquartile range\n",
" lower_bound = Q1 - 1.5 * IQR\n",
" upper_bound = Q3 + 1.5 * IQR\n",
" return data[(data[col] >= lower_bound) & (data[col] <= upper_bound)]\n",
"\n",
"# Remove outliers for relevant columns\n",
"columns_to_check = ['vote_average', 'revenue', 'ROI']\n",
"for col in columns_to_check:\n",
" before = df.shape[0]\n",
" df = remove_outliers_iqr(df, col)\n",
" after = df.shape[0]\n",
" print(f\"\\nAfter removing outliers in '{col}': {before - after} rows removed, remaining {after} rows\")\n",
"\n",
"# ------------------------ #\n",
"# 5. Save Processed Data as JSON\n",
"# 6. Save Processed Data as JSON\n",
"# ------------------------ #\n",
"\n",
"# Convert DataFrame to dictionary\n",
"processed_data = df.to_dict(orient='records')\n",
"\n",
"# Save to 'metrics.json'\n",
"with open('metrics.json', 'w') as f:\n",
"with open('../../docs/assets/data/metrics.json', 'w') as f:\n",
" json.dump(processed_data, f, indent=2)\n",
"\n",
"print(\"\\nProcessing complete. 'metrics.json' has been created.\")\n",
"\n"
"print(\"\\nProcessing complete. 'metrics.json' has been created.\")"
]
}
],
Expand Down
Loading

0 comments on commit 9a75008

Please sign in to comment.