Spaces:
Runtime error
Runtime error
Download app.py from Zakia/IntroMLPythonDemo: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/Zakia/IntroMLPythonDemo/resolve/main/app.py
- Command line
-
hf download hf://spaces/Zakia/IntroMLPythonDemo/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Zakia/IntroMLPythonDemo/resolve/main/app.py
1.06 kB
| # Bismillahir Rahmaanir Raheem | |
| # Almadadh Ya Gause Radi Allahu Ta'alah Anh - Ameen | |
| from joblib import load | |
| import gradio as gr | |
| # Load the trained model | |
| clf = load('iris_decision_tree_model.joblib') | |
| # Import iris dataset for target names | |
| from sklearn import datasets | |
| iris = datasets.load_iris() | |
| # Define the prediction function | |
| def predict_iris(sepal_length, sepal_width, petal_length, petal_width): | |
| prediction = clf.predict([[sepal_length, sepal_width, petal_length, petal_width]]) | |
| return iris.target_names[int(prediction[0])] | |
| # Create and launch the Gradio interface | |
| interface = gr.Interface( | |
| fn=predict_iris, | |
| inputs=["number", "number", "number", "number"], | |
| outputs="text", | |
| live=True, | |
| title="Iris Flower Model", | |
| description="An introductory example of machine learning in Python. An iris flower model trained on the iris flower dataset using the decision tree algorithm. The accuracy of the model is: 97.37%. Input the dimensions of the iris flower's sepal and petal to predict its species." | |
| ) | |
| interface.launch() | |