-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstreamlit_app.py
55 lines (43 loc) · 1.75 KB
/
streamlit_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# streamlit_app.py: Streamlit frontend dosyası.
import pandas as pd
import streamlit as st
import requests
# API URL'si
API_URL = "http://127.0.0.1:5000/predict"
# Sayfa başlığı
st.title('İris Tür Tahmini')
# Kullanıcıdan girişlerin alınacağı form
with st.form("prediction_form"):
st.write("Lütfen aşağıdaki değerleri girin:")
# Kullanıcı girişleri
sepal_length = st.number_input('Sepal Length', min_value=0.0, value=5.0, format="%.2f")
sepal_width = st.number_input('Sepal Width', min_value=0.0, value=3.0, format="%.2f")
petal_length = st.number_input('Petal Length', min_value=0.0, value=3.5, format="%.2f")
petal_width = st.number_input('Petal Width', min_value=0.0, value=1.0, format="%.2f")
# Form submit butonu
submitted = st.form_submit_button("Tahmin Yap")
if submitted:
# Kullanıcı girişlerini bir sözlükte topla
data = {
'sepal_length': sepal_length,
'sepal_width': sepal_width,
'petal_length': petal_length,
'petal_width': petal_width
}
# API'ye POST isteği yap
response = requests.post(API_URL, json=data)
# Yanıtı al ve göster
if response.status_code == 200:
predictions = response.json()
# Tahminleri bir pandas DataFrame'e dönüştür
predictions_df = pd.DataFrame(predictions.items(), columns=['Model', 'Tahmin'])
# DataFrame'i tablo olarak göster
st.table(predictions_df)
else:
st.error("Bir hata oluştu. API'den yanıt alınamadı.")
# Sayfa alt bilgisi
st.markdown("""
<hr>
İris Çiçeği Tür Tahmini Uygulaması<br>
Data Science ve Makine Öğrenimi Projesi
""", unsafe_allow_html=True)