import gradio as gr import joblib import numpy as np # Load the trained model model = joblib.load("iris_decision_tree.pkl") # Prediction function def predict_species(sepal_length, sepal_width, petal_length, petal_width): input_data = np.array([[sepal_length, sepal_width, petal_length, petal_width]]) prediction = model.predict(input_data)[0] species = ["setosa", "versicolor", "virginica"] return f"The predicted Iris species is: 🌸 {species[prediction]}" # Gradio interface iface = gr.Interface( fn=predict_species, inputs=[ gr.Number(label="Sepal Length (cm)"), gr.Number(label="Sepal Width (cm)"), gr.Number(label="Petal Length (cm)"), gr.Number(label="Petal Width (cm)") ], outputs=gr.Textbox(label="Prediction"), title="Iris Flower Species Predictor", description="Enter flower measurements to predict its species using a Decision Tree model." ) # Launch the app if __name__ == "__main__": iface.launch()