Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
mmourafiq committed Sep 3, 2020
1 parent c3ed087 commit e3b84f4
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 0 deletions.
57 changes: 57 additions & 0 deletions in_cluster/sklearn/iris/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import streamlit as st
import pandas as pd
import joblib
import argparse

from PIL import Image


def load_model(model_path: str):
model = open(model_path, "rb")
return joblib.load(model)


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'--model-path',
type=str,
)
args = parser.parse_args()

setosa = Image.open("images/iris-setosa.png")
versicolor = Image.open("images/iris-versicolor.png")
virginica = Image.open("images/iris-virginica.png")
classifier = load_model(args.model_path)
print(classifier)

st.title("Iris flower species Classification")
st.sidebar.title("Features")
parameter_list = [
"Sepal length (cm)",
"Sepal Width (cm)",
"Petal length (cm)",
"Petal Width (cm)"
]
sliders = []
for parameter, parameter_df in zip(parameter_list, ['5.2', '3.2', '4.2', '1.2']):
values = st.sidebar.slider(
label=parameter,
key=parameter,
value=float(parameter_df),
min_value=0.0,
max_value=8.0,
step=0.1
)
sliders.append(values)

input_variables = pd.DataFrame([sliders], columns=parameter_list)

prediction = classifier.predict(input_variables)
if prediction == 0:
st.image(setosa)
elif prediction == 1:
st.image(versicolor)
else:
st.image(virginica)

19 changes: 19 additions & 0 deletions in_cluster/sklearn/iris/hyper-polyaxonfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 1.1
kind: operation
matrix:
kind: random
numRuns: 15
params:
n_neighbors:
kind: range
value: "3:50:5"
leaf_size:
kind: choice
value: [5, 10, 20, 30]
metric:
kind: pchoice
value: [[minkowski, 0.8], [euclidean, 0.2]]
test_size:
kind: choice
value: [0.2, 0.3, 0.4]
urlRef: https://raw.githubusercontent.com/polyaxon/polyaxon-examples/master/in_cluster/sklearn/iris/polyaxonfile.yml
Binary file added in_cluster/sklearn/iris/images/iris-setosa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added in_cluster/sklearn/iris/images/iris-virginica.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions in_cluster/sklearn/iris/streamlit-polyaxonfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 1.1
kind: component
name: iris-classification
tags: ["streamlit", "app"]

inputs:
- name: uuid
isOptional: true
type: str

run:
kind: service
ports: [8501]
rewritePath: true
init:
- git: {"url": "https://github.com/polyaxon/polyaxon-examples"}
- artifacts: {"files": ["{{ uuid }}/assets/model/iris-model.joblib"]}
container:
image: polyaxon/polyaxon-contrib
workingDir: "{{ globals.artifacts_path }}/polyaxon-examples/in_cluster/sklearn/iris"
command: [sh, -c]
args: ["streamlit run app.py -- --model-path={{ globals.artifacts_path }}/{{ uuid }}/assets/model/iris-model.joblib"]

0 comments on commit e3b84f4

Please sign in to comment.