Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import joblib
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
# Load the RandomForest model
|
6 |
+
model = joblib.load('random_forest_model.pkl') # Update with the actual path
|
7 |
+
# Define a function for classification
|
8 |
+
def classify(features):
|
9 |
+
# Convert the input features to a 2D numpy array
|
10 |
+
features_array = np.array([features])
|
11 |
+
# Make a prediction
|
12 |
+
prediction = model.predict(features_array)
|
13 |
+
return f"Predicted Age Category: {prediction[0]}"
|
14 |
+
|
15 |
+
# Create the Gradio interface
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn=classify,
|
18 |
+
inputs=[
|
19 |
+
gr.Slider(minimum=0, maximum=100, default=50, label=f"Feature {i+1}") for i in range(15)
|
20 |
+
],
|
21 |
+
outputs="text",
|
22 |
+
title="Age Classification",
|
23 |
+
description="Enter the 15 features to classify the age category."
|
24 |
+
)
|
25 |
+
|
26 |
+
# Launch the interface
|
27 |
+
iface.launch()
|