Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
|
|
3 |
import numpy as np
|
4 |
|
5 |
# Load the saved Random Forest model
|
6 |
-
model = joblib.load('
|
7 |
|
8 |
# Define the feature names (as per your dataset)
|
9 |
feature_names = [
|
@@ -17,9 +17,25 @@ feature_names = [
|
|
17 |
]
|
18 |
|
19 |
# Define the prediction function
|
20 |
-
def predict(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
# Create a numpy array from the input features
|
22 |
-
input_data = np.array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
# Make a prediction
|
25 |
prediction = model.predict(input_data)[0]
|
@@ -35,7 +51,29 @@ def predict(*args):
|
|
35 |
return "Unknown"
|
36 |
|
37 |
# Create a Gradio interface
|
38 |
-
inputs = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
outputs = gr.outputs.Textbox(label="Prediction")
|
40 |
|
41 |
# Launch the Gradio app
|
|
|
3 |
import numpy as np
|
4 |
|
5 |
# Load the saved Random Forest model
|
6 |
+
model = joblib.load('random_forest_model.pkl')
|
7 |
|
8 |
# Define the feature names (as per your dataset)
|
9 |
feature_names = [
|
|
|
17 |
]
|
18 |
|
19 |
# Define the prediction function
|
20 |
+
def predict(
|
21 |
+
marital_status, application_mode, application_order, course,
|
22 |
+
attendance, previous_qualification, nationality,
|
23 |
+
mother_qualification, mother_occupation, displaced,
|
24 |
+
special_needs, debtor, tuition_fees,
|
25 |
+
gender, scholarship_holder, curricular_units_credited,
|
26 |
+
curricular_units_without_evaluations, unemployment_rate,
|
27 |
+
inflation_rate, gdp
|
28 |
+
):
|
29 |
# Create a numpy array from the input features
|
30 |
+
input_data = np.array([
|
31 |
+
marital_status, application_mode, application_order, course,
|
32 |
+
attendance, previous_qualification, nationality,
|
33 |
+
mother_qualification, mother_occupation, displaced,
|
34 |
+
special_needs, debtor, tuition_fees,
|
35 |
+
gender, scholarship_holder, curricular_units_credited,
|
36 |
+
curricular_units_without_evaluations, unemployment_rate,
|
37 |
+
inflation_rate, gdp
|
38 |
+
]).reshape(1, -1)
|
39 |
|
40 |
# Make a prediction
|
41 |
prediction = model.predict(input_data)[0]
|
|
|
51 |
return "Unknown"
|
52 |
|
53 |
# Create a Gradio interface
|
54 |
+
inputs = [
|
55 |
+
gr.inputs.Number(label="Marital status"),
|
56 |
+
gr.inputs.Number(label="Application mode"),
|
57 |
+
gr.inputs.Number(label="Application order"),
|
58 |
+
gr.inputs.Number(label="Course"),
|
59 |
+
gr.inputs.Number(label="Daytime/evening attendance"),
|
60 |
+
gr.inputs.Number(label="Previous qualification"),
|
61 |
+
gr.inputs.Number(label="Nacionality"),
|
62 |
+
gr.inputs.Number(label="Mother's qualification"),
|
63 |
+
gr.inputs.Number(label="Mother's occupation"),
|
64 |
+
gr.inputs.Number(label="Displaced"),
|
65 |
+
gr.inputs.Number(label="Educational special needs"),
|
66 |
+
gr.inputs.Number(label="Debtor"),
|
67 |
+
gr.inputs.Number(label="Tuition fees up to date"),
|
68 |
+
gr.inputs.Number(label="Gender"),
|
69 |
+
gr.inputs.Number(label="Scholarship holder"),
|
70 |
+
gr.inputs.Number(label="Curricular units 1st sem (credited)"),
|
71 |
+
gr.inputs.Number(label="Curricular units 1st sem (without evaluations)"),
|
72 |
+
gr.inputs.Number(label="Unemployment rate"),
|
73 |
+
gr.inputs.Number(label="Inflation rate"),
|
74 |
+
gr.inputs.Number(label="GDP"),
|
75 |
+
]
|
76 |
+
|
77 |
outputs = gr.outputs.Textbox(label="Prediction")
|
78 |
|
79 |
# Launch the Gradio app
|