From f9a97757299b30957cb38c18503863549287451b Mon Sep 17 00:00:00 2001 From: Giulia Menichetti Date: Sun, 5 Mar 2023 21:02:14 -0500 Subject: [PATCH] Added zip file --- Open_Food_Facts_SISection6.ipynb | 79 +++++++++++++++++--------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/Open_Food_Facts_SISection6.ipynb b/Open_Food_Facts_SISection6.ipynb index ecf8894..b8b1768 100644 --- a/Open_Food_Facts_SISection6.ipynb +++ b/Open_Food_Facts_SISection6.ipynb @@ -2,8 +2,8 @@ "cells": [ { "cell_type": "code", - "execution_count": 3, - "id": "df8dac46", + "execution_count": 12, + "id": "e18d139a", "metadata": {}, "outputs": [], "source": [ @@ -15,6 +15,7 @@ "import joblib\n", "import matplotlib\n", "import operator\n", + "from zipfile import ZipFile\n", "# Set \n", "matplotlib.rcParams['font.serif'] = 'Times New Roman'\n", "matplotlib.rcParams['font.family'] = \"serif\"\n", @@ -26,8 +27,8 @@ }, { "cell_type": "code", - "execution_count": 4, - "id": "dc2d945d", + "execution_count": 13, + "id": "e9b9cb68", "metadata": {}, "outputs": [], "source": [ @@ -39,7 +40,7 @@ }, { "cell_type": "markdown", - "id": "5ee07c54", + "id": "267994f6", "metadata": {}, "source": [ "# Load Data" @@ -47,8 +48,8 @@ }, { "cell_type": "code", - "execution_count": 5, - "id": "bd61b473", + "execution_count": 18, + "id": "4d40a822", "metadata": {}, "outputs": [], "source": [ @@ -57,8 +58,8 @@ }, { "cell_type": "code", - "execution_count": 6, - "id": "08d4a7b1", + "execution_count": 19, + "id": "58610a77", "metadata": { "scrolled": true }, @@ -472,7 +473,7 @@ "[233831 rows x 25 columns]" ] }, - "execution_count": 6, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -483,7 +484,7 @@ }, { "cell_type": "markdown", - "id": "55d99365", + "id": "60843900", "metadata": {}, "source": [ "# Missing Data in Nutrition Facts" @@ -491,8 +492,8 @@ }, { "cell_type": "code", - "execution_count": 7, - "id": "cc1321c3", + "execution_count": 20, + "id": "f077ef2b", "metadata": {}, "outputs": [ { @@ -514,7 +515,7 @@ "dtype: int64" ] }, - "execution_count": 7, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -538,7 +539,7 @@ }, { "cell_type": "markdown", - "id": "89c1573d", + "id": "f5f8f81d", "metadata": {}, "source": [ "# Keep 11 nutrients including Trans-Fats" @@ -546,8 +547,8 @@ }, { "cell_type": "code", - "execution_count": 8, - "id": "46f43497", + "execution_count": 21, + "id": "0c99130a", "metadata": {}, "outputs": [ { @@ -583,8 +584,8 @@ }, { "cell_type": "code", - "execution_count": 9, - "id": "41f05700", + "execution_count": 22, + "id": "4d1bddda", "metadata": {}, "outputs": [ { @@ -608,20 +609,22 @@ }, { "cell_type": "code", - "execution_count": 10, - "id": "ab6334c1", + "execution_count": 23, + "id": "00dd1eab", + "metadata": {}, + "outputs": [], + "source": [ + "# zip file\n", + "with ZipFile(pathdir2+'OpenFoodFacts11p_Performance.pkl.zip', 'r') as zObject:\n", + " zObject.extractall(path=pathdir2)" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "847c8adc", "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/giulia/anaconda/lib/python3.6/site-packages/sklearn/base.py:315: UserWarning: Trying to unpickle estimator DecisionTreeClassifier from version 0.23.2 when using version 0.24.2. This might lead to breaking code or invalid results. Use at your own risk.\n", - " UserWarning)\n", - "/Users/giulia/anaconda/lib/python3.6/site-packages/sklearn/base.py:315: UserWarning: Trying to unpickle estimator RandomForestClassifier from version 0.23.2 when using version 0.24.2. This might lead to breaking code or invalid results. Use at your own risk.\n", - " UserWarning)\n" - ] - }, { "name": "stdout", "output_type": "stream", @@ -647,7 +650,7 @@ }, { "cell_type": "markdown", - "id": "abe4947c", + "id": "bc3c1be8", "metadata": {}, "source": [ "# Including Additives Information" @@ -656,7 +659,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "2b98cd81", + "id": "18f4e736", "metadata": {}, "outputs": [], "source": [ @@ -668,7 +671,7 @@ { "cell_type": "code", "execution_count": 12, - "id": "d37d6468", + "id": "eca1ce17", "metadata": {}, "outputs": [ { @@ -690,7 +693,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "1c039feb", + "id": "243cdff5", "metadata": {}, "outputs": [ { @@ -710,7 +713,7 @@ }, { "cell_type": "markdown", - "id": "08a11251", + "id": "0b467541", "metadata": {}, "source": [ "# Using just the Number of Additives" @@ -719,7 +722,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "e381bf68", + "id": "7cde3081", "metadata": {}, "outputs": [ { @@ -741,7 +744,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "0ac64460", + "id": "d3efbb21", "metadata": {}, "outputs": [ {