File size: 1,060 Bytes
a4753d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json
import requests
import streamlit as st

# Set the title of the app
st.title("Medical Prediction Model")

# Instruction text
st.write("Enter 32 features for prediction:")

# Create 32 input fields for user input
inputs = []
for i in range(32):
    value = st.number_input(f"Feature {i + 1}", min_value=0, step=1)
    inputs.append(value)

# Button to make prediction
if st.button("Predict"):
    # Prepare the data for the request
    input_data = {"features": inputs}
    
    # Set the URL for your FastAPI backend
    url = "http://localhost:8501/predict"  # Replace with your actual URL if deployed

    # Make a POST request
    response = requests.post(url, json=input_data)  # Send the wrapped input_data
    
    # Check the response status code
    if response.status_code == 200:
        # Get the JSON response
        prediction = response.json()
        # Display the prediction results
        st.success("Prediction Results:")
        st.json(prediction)
    else:
        st.error(f"Error: {response.status_code} - {response.text}")