CoolFace
Apppublic

AlainDeLong/End-To-End-Machine-Learning-Project

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
app.py64 linesDownload Raw Back to root
1import streamlit as st2from src.pipeline.predict_pipeline import CustomData, PredictPipeline3 4# Application title5st.set_page_config(page_title="Math Score Predictor")6st.title("Student Math Score Predictor")7st.write("This application predicts math scores based on student data.")8 9# Input form10with st.form(key="student_form"):11    gender = st.selectbox("Gender", options=["male", "female"])12    ethnicity = st.selectbox(13        "Race or Ethnicity",14        options=["group A", "group B", "group C", "group D", "group E"],15    )16    parental_education = st.selectbox(17        "Parental Level of Education",18        options=[19            "associate's degree",20            "bachelor's degree",21            "high school",22            "master's degree",23            "some college",24            "some high school",25        ],26    )27    lunch = st.selectbox("Lunch Type", options=["free/reduced", "standard"])28    test_preparation_course = st.selectbox(29        "Test Preparation Course", options=["none", "completed"]30    )31 32    reading_score = st.number_input(33        "Reading Score (out of 100)", min_value=0, max_value=100, step=134    )35    writing_score = st.number_input(36        "Writing Score (out of 100)", min_value=0, max_value=100, step=137    )38 39    # Submit button40    submit_button = st.form_submit_button("Predict Exam Scores")41 42# Process prediction when button is pressed43if submit_button:44    # Initialize data45    data = CustomData(46        gender=gender,47        race_ethnicity=ethnicity,48        parental_level_of_education=parental_education,49        lunch=lunch,50        test_preparation_course=test_preparation_course,51        reading_score=reading_score,52        writing_score=writing_score,53    )54 55    # Get data as DataFrame56    pred_df = data.get_data_as_dataframe()57 58    # Make predictions59    predict_pipeline = PredictPipeline()60    results = predict_pipeline.predict(pred_df)61 62    # Display prediction result63    st.success(f"The predicted Maths Score is {results[0]:.2f}")64