diff --git a/models/decision_tree_classifier_default_42.sav b/models/decision_tree_classifier_default_42.sav new file mode 100644 index 000000000..47a5164a5 Binary files /dev/null and b/models/decision_tree_classifier_default_42.sav differ diff --git a/src/app.py b/src/app.py index 80d7790e2..f64206fb9 100644 --- a/src/app.py +++ b/src/app.py @@ -1,4 +1,27 @@ -from utils import db_connect -engine = db_connect() +from flask import Flask, request, render_template +from pickle import load -# your code here +app = Flask(__name__) +model = load(open("/workspaces/NEW_flask/models/decision_tree_classifier_default_42.sav", "rb")) +class_dict = { + "0": "Iris setosa", + "1": "Iris versicolor", + "2": "Iris virginica" +} + +@app.route("/", methods = ["GET", "POST"]) +def index(): + if request.method == "POST": + + val1 = float(request.form["val1"]) + val2 = float(request.form["val2"]) + val3 = float(request.form["val3"]) + val4 = float(request.form["val4"]) + + data = [[val1, val2, val3, val4]] + prediction = str(model.predict(data)[0]) + pred_class = class_dict[prediction] + else: + pred_class = None + + return render_template("index.html", prediction = pred_class) \ No newline at end of file diff --git a/src/explore.ipynb b/src/explore.ipynb deleted file mode 100644 index a323483c5..000000000 --- a/src/explore.ipynb +++ /dev/null @@ -1,47 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Explore here" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.8.13 64-bit ('3.8.13')", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.13" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "110cc1dee26208153f2972f08a2ad52b6a56238dc66d48e87fb757ef2996db56" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/src/templates/index.html b/src/templates/index.html new file mode 100644 index 000000000..f78bbee8d --- /dev/null +++ b/src/templates/index.html @@ -0,0 +1,58 @@ + + +
+