Spaces:
Sleeping
Sleeping
Jhun Brian Andam commited on
Commit ·
a317d5e
1
Parent(s): eb8cab0
Add app files
Browse filesFiles changed (12)
- DockerfileAdded+10
- README.mdDeleted-10
- __pycache__/iris_model.cpython-311.pycAdded
- __pycache__/iris_model.cpython-37.pycAdded
- __pycache__/iris_model.cpython-39.pycAdded
- app.pyAdded+28
- iris_model.pyAdded+18
- requirements.txtAdded+8
- static/Kosaciec_szczecinkowaty_Iris_setosa.jpgAdded
- static/css/iris.cssAdded+17
- static/iris-flowers.jpgAdded
- templates/index.htmlAdded+99
12345678910FROM python:3.9.18-slim
WORKDIR / C:\Users\acer\Desktop\Brian\2nd Semester\CLEAN_ENVIRONMENT\iris_clf
COPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "-m", "flask", "run", "--host=0.0.0.0", "--port=7860"]12345678910---title: Iris Dockeremoji: 📈colorFrom: greencolorTo: bluesdk: dockerpinned: false---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference12345678910111213141516171819202122232425262728from flask import Flask, render_template, requestimport iris_modelapp = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def basic(): if request.method == 'POST': sepal_length = request.form['sepallength'] sepal_width = request.form['petalwidth'] petal_length = request.form['petallength'] petal_width = request.form['petalwidth'] y_pred = [[sepal_length, sepal_width, petal_length, petal_width]] trained_model = iris_model.training_model() prediction_value = trained_model.predict(y_pred) setosa = 'The flower is classified as Setosa' versicolor = 'The flower is classified as Versicolor' virginica = 'The flower is classified as Virginica' if prediction_value == 0: return render_template('index.html', setosa=setosa) elif prediction_value == 1: return render_template('index.html', versicolor=versicolor) else: return render_template('index.html', virginica=virginica) return render_template('index.html')
if __name__ == '__main__': app.run(host="0.0.0.0", port=7860)123456789101112131415161718import pandas as pd from sklearn.datasets import load_irisdata = load_iris()# print(data.DESCR)
X = pd.DataFrame(data.data, columns=(data.feature_names))y = pd.DataFrame(data.target, columns=['Target'])
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=1, test_size=0.3)
from sklearn.tree import DecisionTreeClassifier
def training_model(): model = DecisionTreeClassifier() trained_model = model.fit(X_train, y_train) return trained_model12345678scikit-learn==1.0numpy==1.19.5pandas==1.3.4matplotlib==3.4.3seaborn==0.11.2scipy==1.7.1joblib==1.1.0flask==3.0.21234567891011121314151617html { font-size: 14px;}@media (min-width: 768px) { html { font-size: 16px; }}
.container { max-width: 960px;}
.card-deck .card { min-width: 220px;}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Iris Project</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"> <style> .bd-placeholder-img { font-size: 1.125rem; text-anchor: middle; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
body { background-image: url('../static/iris-flowers.jpg'); }
@media (min-width: 768px) { .bd-placeholder-img-lg { font-size: 3.5rem; } } </style> <!-- Custom styles for this template --> <link href="../static/css/iris.css" rel="stylesheet"> </head> <body> <div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-dark text-white border-bottom shadow-sm"> <h5 class="my-0 mr-md-auto font-weight-normal">Project IRIS Classification</h5> </div>
<div class="container p-3 my-3 bg-secondary text-white"> {% if setosa %} <div class="alert alert-primary">{{setosa}}</div> {% elif versicolor %} <div class="alert alert-primary">{{versicolor}}</div> {% elif virginica %} <div class="alert alert-primary">{{virginica}}</div> {% endif %} <form class="form-group" action="/" method="POST"> <label for="sepallength">Sepal Length :</label> <input class="form-control" type="number" name="sepallength"> <label for="sepalwidth">Sepal Width :</label> <input class="form-control" type="number" name="sepalwidth"> <label for="petallength">Petal Length :</label> <input class="form-control" type="number" name="petallength"> <label for="petalwidth">Petal Width :</label> <input class="form-control" type="number" name="petalwidth"> </br> <button class="btn btn-dark" type="submit" name="submit">Submit</button> </form> </div>
<div class="container"> <div class="card-deck mb-3 text-center"> <div class="card mb-4 shadow-sm"> <div class="card-header"> <h4 class="my-0 font-weight-normal">Setosa</h4> </div> <div class="card-body"> <ul class="list-unstyled mt-3 mb-4"> <li>Iris setosa, is a species in the genus Iris, it is also in the subgenus Limniris and in the series Tripetalae. It is a rhizomatous perennial from a wide range across the Arctic sea, including Alaska, Maine, Canada, Russia, northeastern Asia, China, Korea and southwards to Japan.</li> </ul> </div> </div> <div class="card mb-4 shadow-sm"> <div class="card-header"> <h4 class="my-0 font-weight-normal">Virginica</h4> </div> <div class="card-body"> <ul class="list-unstyled mt-3 mb-4"> <li>Iris virginica, with the common name Virginia iris, is a perennial species of flowering plant, native to eastern North America. It is common along the coastal plain from Florida to Georgia in the Southeastern United States.</li> </ul> </div> </div> <div class="card mb-4 shadow-sm"> <div class="card-header"> <h4 class="my-0 font-weight-normal">Versicolor</h4> </div> <div class="card-body"> <ul class="list-unstyled mt-3 mb-4"> <li>Iris versicolor is also commonly known as the blue flag, harlequin blueflag, larger blue flag, northern blue flag, and poison flag, plus other variations of these names, and in Britain and Ireland as purple iris. It is a species of Iris native to North America, in the Eastern United States and Eastern Canada.</li> </ul> </div> </div> </div>
</div></body></html>DockerfileAdded+10
README.mdDeleted-10
__pycache__/iris_model.cpython-311.pycAdded
__pycache__/iris_model.cpython-37.pycAdded
__pycache__/iris_model.cpython-39.pycAdded
app.pyAdded+28
iris_model.pyAdded+18
requirements.txtAdded+8
static/Kosaciec_szczecinkowaty_Iris_setosa.jpgAdded

static/css/iris.cssAdded+17
static/iris-flowers.jpgAdded

templates/index.htmlAdded+99