maty0505 commited on
Commit
c080dee
1 Parent(s): 4c079b5

upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +56 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from sklearn.datasets import load_iris
4
+ from sklearn.ensemble import RandomForestClassifier
5
+
6
+ # ヘッダー
7
+ st.title("Iris Flower Prediction App")
8
+
9
+ # 説明
10
+ st.write("""
11
+ This app predicts the **Iris flower** type!
12
+ """)
13
+
14
+ # サイドバーに入力フィールドを作成
15
+ st.sidebar.header('User Input Parameters')
16
+
17
+ def user_input_features():
18
+ sepal_length = st.sidebar.slider('Sepal length', 4.3, 7.9, 5.4)
19
+ sepal_width = st.sidebar.slider('Sepal width', 2.0, 4.4, 3.4)
20
+ petal_length = st.sidebar.slider('Petal length', 1.0, 6.9, 1.3)
21
+ petal_width = st.sidebar.slider('Petal width', 0.1, 2.5, 0.2)
22
+ data = {'sepal_length': sepal_length,
23
+ 'sepal_width': sepal_width,
24
+ 'petal_length': petal_length,
25
+ 'petal_width': petal_width}
26
+ features = pd.DataFrame(data, index=[0])
27
+ return features
28
+
29
+ df = user_input_features()
30
+
31
+ # 入力パラメータの表示
32
+ st.subheader('User Input parameters')
33
+ st.write(df)
34
+
35
+ # Irisデータセットの読み込み
36
+ iris = load_iris()
37
+ X = iris.data
38
+ Y = iris.target
39
+
40
+ # ランダムフォレスト分類器の学習
41
+ clf = RandomForestClassifier()
42
+ clf.fit(X, Y)
43
+
44
+ # 予測の表示
45
+ prediction = clf.predict(df)
46
+ prediction_proba = clf.predict_proba(df)
47
+
48
+ st.subheader('Class labels and their corresponding index number')
49
+ st.write(iris.target_names)
50
+
51
+ st.subheader('Prediction')
52
+ st.write(iris.target_names[prediction])
53
+
54
+ st.subheader('Prediction Probability')
55
+ st.write(prediction_proba)
56
+
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ scikit-learn
3
+ pandas
4
+