Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prueba #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added models/decision_tree_classifier_default_42.sav
Binary file not shown.
29 changes: 26 additions & 3 deletions src/app.py
Original file line number Diff line number Diff line change
@@ -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)
47 changes: 0 additions & 47 deletions src/explore.ipynb

This file was deleted.

58 changes: 58 additions & 0 deletions src/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<title>Iris - Model prediction</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 40px;
background-color: #f4f4f4;
}
form {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 15px rgba(0,0,0,0.1);
}
input[type="number"] {
width: 100%;
padding: 10px;
margin: 10px 0;
border-radius: 4px;
border: 1px solid #ccc;
}
input[type="submit"] {
background-color: #333;
color: #fff;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #555;
}
h3 {
margin-top: 20px;
background-color: #fff;
padding: 10px;
border-radius: 4px;
}
</style>
</head>
<body>
<h2>Introduce the values</h2>

<form action="/" method="post">
Petal width: <input type="number" step="any" name="val1" required><br><br>
Petal length: <input type="number" step="any" name="val2" required><br><br>
Sepal width: <input type="number" step="any" name="val3" required><br><br>
Sepal length: <input type="number" step="any" name="val4" required><br><br>
<input type="submit" value="Predict">
</form>

{% if prediction != None %}
<h3>Prediction: {{ prediction }}</h3>
{% endif %}
</body>
</html>
13 changes: 0 additions & 13 deletions src/utils.py

This file was deleted.