File size: 1,189 Bytes
69bc517
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from projects.ML_StudentPerformance.src.pipelines.predict_pipeline import CustomData, PredictPipeline
from pydantic import BaseModel

# Function to handle the prediction logic
def predict_student_performance(data):
    # Convert the incoming form data to a DataFrame
    pred_df = data.get_data_as_dataframe()

    # Initialize the prediction pipeline
    predict_pipeline = PredictPipeline()
    results = predict_pipeline.predict(pred_df)

    return results[0]  # Return the first prediction result

# Function to handle form data conversion
def create_custom_data(gender, ethnicity, parental_level_of_education, lunch, test_preparation_course, reading_score, writing_score):
    return CustomData(
        gender=gender,
        race_ethnicity=ethnicity,
        parental_level_of_education=parental_level_of_education,
        lunch=lunch,
        test_preparation_course=test_preparation_course,
        reading_score=float(reading_score),
        writing_score=float(writing_score)
    )

class form1(BaseModel):
    gender: str
    ethnicity: str
    parental_level_of_education: str
    lunch: str
    test_preparation_course: str
    reading_score: float
    writing_score: float