Download app.py from AbraMuhara/RandomForestAgeClassificationTDDI2024Server: direct link, hf CLI and curl.
- Browser
- Download file 795 Bytes
-
https://huggingface.co/spaces/AbraMuhara/RandomForestAgeClassificationTDDI2024Server/resolve/e76fb3a09b3a221b730e31e334d90b52234e1ac4/app.py
- Command line
-
hf download hf://spaces/AbraMuhara/RandomForestAgeClassificationTDDI2024Server@e76fb3a09b3a221b730e31e334d90b52234e1ac4/app.py
-
curl -L -o app.py https://huggingface.co/spaces/AbraMuhara/RandomForestAgeClassificationTDDI2024Server/resolve/e76fb3a09b3a221b730e31e334d90b52234e1ac4/app.py
795 Bytes
| import gradio as gr | |
| import joblib | |
| import numpy as np | |
| # Load the RandomForest model | |
| model = joblib.load('random_forest_model.pkl') # Update with the actual path | |
| # Define a function for classification | |
| def classify(features): | |
| # Convert the input features to a 2D numpy array | |
| features_array = np.array([features]) | |
| # Make a prediction | |
| prediction = model.predict(features_array) | |
| return f"Predicted Age Category: {prediction[0]}" | |
| # Create the Gradio interface | |
| iface = gr.Interface( | |
| fn=classify, | |
| inputs=[ | |
| gr.Slider(minimum=0, maximum=100, default=50, label=f"Feature {i+1}") for i in range(15) | |
| ], | |
| outputs="text", | |
| title="Age Classification", | |
| description="Enter the 15 features to classify the age category." | |
| ) | |
| # Launch the interface | |
| iface.launch() | |