Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,200 changes: 801 additions & 399 deletions Dataset/Allergen_Status_of_Food_Products.csv

Large diffs are not rendered by default.

1,203 changes: 803 additions & 400 deletions Dataset/Cleaned_Allergen_Status.csv

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions scripts/Model training and testing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "3c55ee87-71d5-43f3-8bc4-46fb8d67f884",
"metadata": {},
"outputs": [
Expand All @@ -33,7 +33,7 @@
"import pandas as pd\n",
"\n",
"# Load the saved model\n",
"model = joblib.load(\"C:/Users/Akshi/FoodAllergyDetection/models/best_decision_tree_model.pkl\")\n",
"model = joblib.load(\"C:/Users/Akshi/SafeBite_Infosys_Internship_Oct2024/models/best_decision_tree_model.pkl\")\n",
"\n",
"# Load the unseen data\n",
"unseen_data = pd.read_csv(\"sample.csv\")\n",
Expand All @@ -43,15 +43,15 @@
"\n",
"# Save predictions to CSV\n",
"unseen_data['Predictions'] = predictions\n",
"unseen_data.to_csv(\"C:/Users/Akshi/FoodAllergyDetection/Predictions12.csv\", index=False)\n",
"unseen_data.to_csv(\"C:/Users/Akshi/SafeBite_Infosys_Internship_Oct2024/scripts/Predictions12.csv\", index=False)\n",
"\n",
"\n",
"print(\"Predictions have been saved to Predictions12.csv\")\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"id": "cd7011ba-e6ac-4d76-8f38-73f164ac6606",
"metadata": {},
"outputs": [
Expand Down
36 changes: 25 additions & 11 deletions scripts/Predictions12.csv
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
Food Product,Main Ingredient,Sweetener,Fat/Oil,Seasoning,Allergens,Price ($),Customer rating (Out of 5),Predictions
Blueberry Protein Bar,Blueberries,Honey,Almond oil,Vanilla extract,Tree nuts,2.99,4.2,1
Mango Chia Pudding,Mango,Coconut sugar,Coconut milk,Cardamom,Coconut,4.49,4.5,1
Beetroot Chips,Beetroot,,Olive oil,Sea salt,,3.25,3.8,0
Pumpkin Spice Muffin,Pumpkin,Maple syrup,Butter,"Cinnamon, Nutmeg","Wheat, Dairy",5.75,4.7,1
Lentil Soup,Lentils,,Olive oil,Herbs de Provence,,4.0,4.0,0
Quinoa Sushi Roll,Quinoa,,Avocado oil,Soy sauce,Soy,6.5,4.6,1
Turmeric Latte,Turmeric,Date syrup,Coconut oil,"Ginger, Black pepper",,3.75,4.3,0
Seaweed Snack,Seaweed,,Sesame oil,Nori seasoning,,2.5,3.9,0
Hazelnut Milkshake,Hazelnuts,Agave syrup,Hazelnut oil,Cocoa powder,Tree nuts,5.25,4.8,1
Spicy Black Bean Wrap,Black Beans,,,"Hot sauce, Lime",,6.0,4.1,0
<<<<<<< HEAD
Food Product,Main Ingredient,Sweetener,Fat/Oil,Seasoning,Allergens,Price ($),Customer rating (Out of 5),Predictions
Blueberry Protein Bar,Blueberries,Honey,Almond oil,Vanilla extract,Tree nuts,2.99,4.2,1
Mango Chia Pudding,Mango,Coconut sugar,Coconut milk,Cardamom,Coconut,4.49,4.5,1
Beetroot Chips,Beetroot,,Olive oil,Sea salt,,3.25,3.8,0
Pumpkin Spice Muffin,Pumpkin,Maple syrup,Butter,"Cinnamon, Nutmeg","Wheat, Dairy",5.75,4.7,1
Lentil Soup,Lentils,,Olive oil,Herbs de Provence,,4.0,4.0,0
Quinoa Sushi Roll,Quinoa,,Avocado oil,Soy sauce,Soy,6.5,4.6,1
Turmeric Latte,Turmeric,Date syrup,Coconut oil,"Ginger, Black pepper",,3.75,4.3,0
Seaweed Snack,Seaweed,,Sesame oil,Nori seasoning,,2.5,3.9,0
Hazelnut Milkshake,Hazelnuts,Agave syrup,Hazelnut oil,Cocoa powder,Tree nuts,5.25,4.8,1
Spicy Black Bean Wrap,Black Beans,,,"Hot sauce, Lime",,6.0,4.1,0
=======
Food Product,Main Ingredient,Sweetener,Fat/Oil,Seasoning,Allergens,Price ($),Customer rating (Out of 5),Predictions
Blueberry Protein Bar,Blueberries,Honey,Almond oil,Vanilla extract,Tree nuts,2.99,4.2,1
Mango Chia Pudding,Mango,Coconut sugar,Coconut milk,Cardamom,Coconut,4.49,4.5,1
Beetroot Chips,Beetroot,,Olive oil,Sea salt,,3.25,3.8,0
Pumpkin Spice Muffin,Pumpkin,Maple syrup,Butter,"Cinnamon, Nutmeg","Wheat, Dairy",5.75,4.7,1
Lentil Soup,Lentils,,Olive oil,Herbs de Provence,,4.0,4.0,0
Quinoa Sushi Roll,Quinoa,,Avocado oil,Soy sauce,Soy,6.5,4.6,1
Turmeric Latte,Turmeric,Date syrup,Coconut oil,"Ginger, Black pepper",,3.75,4.3,0
Seaweed Snack,Seaweed,,Sesame oil,Nori seasoning,,2.5,3.9,0
Hazelnut Milkshake,Hazelnuts,Agave syrup,Hazelnut oil,Cocoa powder,Tree nuts,5.25,4.8,1
Spicy Black Bean Wrap,Black Beans,,,"Hot sauce, Lime",,6.0,4.1,0
>>>>>>> cd4c9fce709b200dce5d8728f7cbc560803e0d0c
17 changes: 14 additions & 3 deletions scripts/flask_api.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
from flask import Flask, request, jsonify
import joblib
import pandas as pd
import os

app = Flask(__name__)

# Load pre-trained model
model_path = "C:/Users/Akshi/FoodAllergyDetection/models/best_decision_tree_model.pkl" # Update with the correct model path


# Get the absolute path to the 'models' directory
model_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'models', 'best_decision_tree_model.pkl')

# Now load the model
model = joblib.load(model_path)





@app.route('/')
def home():
return "Food Allergen Prediction API is running!"
Expand Down Expand Up @@ -37,4 +46,6 @@ def predict():
return jsonify({"error": f"An error occurred: {e}"}), 500

if __name__ == "__main__":
app.run(debug=True)
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port, debug=True)

132 changes: 132 additions & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
altair==5.4.1
anyio==4.6.2.post1
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==2.4.1
async-lru==2.0.4
attrs==24.2.0
babel==2.16.0
beautifulsoup4==4.12.3
bleach==6.2.0
blinker==1.9.0
cachetools==5.5.0
category-encoders==2.6.4
certifi==2024.8.30
cffi==1.17.1
charset-normalizer==3.4.0
click==8.1.7
colorama==0.4.6
comm==0.2.2
contourpy==1.3.1
cycler==0.12.1
debugpy==1.8.9
decorator==5.1.1
defusedxml==0.7.1
executing==2.1.0
fastjsonschema==2.20.0
Flask==3.1.0
Flask-Cors==5.0.0
fonttools==4.55.0
fqdn==1.5.1
gitdb==4.0.11
GitPython==3.1.43
h11==0.14.0
httpcore==1.0.7
httpx==0.27.2
idna==3.10
ipykernel==6.29.5
ipython==8.29.0
isoduration==20.11.0
itsdangerous==2.2.0
jedi==0.19.2
Jinja2==3.1.4
joblib==1.4.2
json5==0.9.28
jsonpointer==3.0.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter-events==0.10.0
jupyter-lsp==2.2.5
jupyter_client==8.6.3
jupyter_core==5.7.2
jupyter_server==2.14.2
jupyter_server_terminals==0.5.3
jupyterlab==4.2.6
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.3
kiwisolver==1.4.7
markdown-it-py==3.0.0
MarkupSafe==3.0.2
matplotlib==3.9.2
matplotlib-inline==0.1.7
mdurl==0.1.2
mistune==3.0.2
narwhals==1.14.1
nbclient==0.10.0
nbconvert==7.16.4
nbformat==5.10.4
nest-asyncio==1.6.0
notebook==7.2.2
notebook_shim==0.2.4
numpy==2.1.3
overrides==7.7.0
packaging==24.2
pandas==2.2.3
pandocfilters==1.5.1
parso==0.8.4
patsy==1.0.1
pillow==11.0.0
platformdirs==4.3.6
prometheus_client==0.21.0
prompt_toolkit==3.0.48
protobuf==5.28.3
psutil==6.1.0
pure_eval==0.2.3
pyarrow==18.0.0
pycparser==2.22
pydeck==0.9.1
Pygments==2.18.0
pyparsing==3.2.0
python-dateutil==2.9.0.post0
python-json-logger==2.0.7
pytz==2024.2
pywin32==308; platform_system == "Windows"
PyYAML==6.0.2
pyzmq==26.2.0
referencing==0.35.1
requests==2.32.3
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.9.4
rpds-py==0.21.0
scikit-learn==1.5.2
scipy==1.14.1
seaborn==0.13.2
Send2Trash==1.8.3
setuptools==75.6.0
six==1.16.0
smmap==5.0.1
sniffio==1.3.1
soupsieve==2.6
stack-data==0.6.3
statsmodels==0.14.4
streamlit==1.40.1
tenacity==9.0.0
terminado==0.18.1
threadpoolctl==3.5.0
tinycss2==1.4.0
toml==0.10.2
tornado==6.4.2
traitlets==5.14.3
types-python-dateutil==2.9.0.20241003
typing_extensions==4.12.2
tzdata==2024.2
uri-template==1.3.0
urllib3==2.2.3
watchdog==6.0.0
wcwidth==0.2.13
webcolors==24.11.1
webencodings==0.5.1
websocket-client==1.8.0
Werkzeug==3.1.3