Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import joblib | |
| import numpy as np | |
| import sklearn | |
| # Load the saved model | |
| loaded_model = joblib.load('iris_model.sav') | |
| def predict_iris(sepal_length, sepal_width, petal_length, petal_width): | |
| input_data = np.array([[sepal_length, sepal_width, petal_length, petal_width]]) | |
| prediction = loaded_model.predict(input_data)[0] | |
| iris_classes = ['setosa', 'versicolor', 'virginica'] | |
| return iris_classes[prediction] | |
| iface = gr.Interface( | |
| fn=predict_iris, | |
| inputs=[ | |
| gr.Number(label="Sepal Length"), | |
| gr.Number(label="Sepal Width"), | |
| gr.Number(label="Petal Length"), | |
| gr.Number(label="Petal Width") | |
| ], | |
| outputs=gr.Textbox(label="Predicted Iris Class"), | |
| title="Iris Flower Classification", | |
| description="Enter sepal and petal measurements to predict the Iris species." | |
| ) | |
| iface.launch() |