-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3ed087
commit 8071642
Showing
6 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [streamlit, run, app.py] | ||
args: ["--", "--model-path={{ globals.artifacts_path }}/{{ uuid }}/assets/model/iris-model.joblib"] |