ariefrahmansyah commited on
Commit
3c4e048
·
0 Parent(s):

first commit

Browse files
Files changed (4) hide show
  1. iris_sklearn.py +18 -0
  2. model.pkl +0 -0
  3. requirements.txt +3 -0
  4. train.py +16 -0
iris_sklearn.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+
3
+ import streamlit as st
4
+
5
+ model = pickle.load(open("model.pkl", "rb"))
6
+ target_names = ["setosa", "versicolor", "virginica"]
7
+
8
+ st.title("Iris Classifier 🌺")
9
+
10
+ sepal_length = st.number_input("Sepal length", key="sepal_length")
11
+ sepal_width = st.number_input("Sepal width", key="sepal_width")
12
+ petal_length = st.number_input("Petal length", key="petal_length")
13
+ petal_width = st.number_input("Petal width", key="petal_width")
14
+
15
+ if st.button("Predict"):
16
+ prediction = model.predict([[sepal_length, sepal_width, petal_length, petal_width]])
17
+ st.write(f"Prediction: {prediction[0]}")
18
+ st.write(f"Predicted target name: {target_names[prediction[0]]}")
model.pkl ADDED
Binary file (859 Bytes). View file
 
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ joblib
2
+ scikit-learn
3
+ streamlit
train.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pickle import dump
2
+
3
+ from sklearn import datasets
4
+ from sklearn.linear_model import LogisticRegression
5
+
6
+ # import some data to play with
7
+ iris = datasets.load_iris()
8
+ X = iris.data
9
+ Y = iris.target
10
+
11
+ logreg = LogisticRegression(C=1e5)
12
+ logreg.fit(X, Y)
13
+
14
+
15
+ with open("model.pkl", "wb") as f:
16
+ dump(logreg, f, protocol=5)