pushpikaLiyanagama
commited on
Commit
•
4277877
1
Parent(s):
50f3b8d
Update app.py
Browse files
app.py
CHANGED
@@ -13,29 +13,22 @@ models = {
|
|
13 |
|
14 |
# Define the prediction function
|
15 |
def predict(user_input):
|
16 |
-
# Ensure the input is in the same order as your model expects
|
17 |
user_input_array = np.array(user_input).reshape(1, -1)
|
18 |
-
|
19 |
-
# Scale the input using the saved scaler
|
20 |
user_input_scaled = scaler.transform(user_input_array)
|
21 |
-
|
22 |
-
# Predict outcomes for all target variables
|
23 |
-
predictions = {}
|
24 |
-
for target, model in models.items():
|
25 |
-
prediction = model.predict(user_input_scaled)
|
26 |
-
predictions[target] = prediction[0]
|
27 |
-
|
28 |
return predictions
|
29 |
|
30 |
-
# Define
|
31 |
-
interface = gr.Interface(
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
39 |
|
40 |
-
#
|
41 |
-
interface
|
|
|
13 |
|
14 |
# Define the prediction function
|
15 |
def predict(user_input):
|
|
|
16 |
user_input_array = np.array(user_input).reshape(1, -1)
|
|
|
|
|
17 |
user_input_scaled = scaler.transform(user_input_array)
|
18 |
+
predictions = {target: model.predict(user_input_scaled)[0] for target, model in models.items()}
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
return predictions
|
20 |
|
21 |
+
# Define the interface
|
22 |
+
interface = gr.Interface(
|
23 |
+
fn=predict,
|
24 |
+
inputs=gr.Dataframe(type="numpy", row_count=1, col_count=12,
|
25 |
+
headers=["course overview", "reading file", "abstract materiale",
|
26 |
+
"concrete material", "visual materials", "self-assessment",
|
27 |
+
"exercises submit", "quiz submitted", "playing", "paused",
|
28 |
+
"unstarted", "buffering"]),
|
29 |
+
outputs=gr.JSON(),
|
30 |
+
live=True
|
31 |
+
)
|
32 |
|
33 |
+
# Define the callable object for inference
|
34 |
+
model = interface
|