CoolFace
Apppublic

Oceane22/Mapping

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py44 linesDownload Raw Back to root
1import streamlit as st2import pandas as pd3from sklearn import datasets4from sklearn.ensemble import RandomForestClassifier5 6st.title('Iris Flower Prediction App')7 8iris = datasets.load_iris()9X = iris.data10y = iris.target11 12clf = RandomForestClassifier()13clf.fit(X,y)14 15st.sidebar.header('User Input Parameters')16 17def user_input_features():18    sepal_length = st.sidebar.slider('Sepal length',4.3,8.0,5.0)19    sepal_width = st.sidebar.slider('Sepal length',2.0,4.4,3.4)20    pepal_length = st.sidebar.slider('Sepal length',1.0,6.9,1.3)21    petal_width= st.sidebar.slider('Sepal length',0.1,2.5,0.2)22    data ={'sepal_length':sepal_length,23           'sepal_width':sepal_width,24           'petal_length':pepal_length,25           'petal_width':petal_width}26    features = pd.DataFrame(data,index=[0])27    return features28 29 30df = user_input_features()31st.subheader('User Input Parameters')32st.write(df)33 34prediction = clf.predict(df)35prediction_proba = clf.predict_proba(df)36 37st.subheader('Class names and corresponding numbers')38st.write(iris.target_names)39 40st.subheader('Prediction')41st.write(iris.target_names[prediction])42 43st.subheader('Prediction Probability')44st.write(prediction_proba )