!pip install gradio import gradio as gr import numpy as np from sklearn.datasets import load_iris from sklearn.ensemble import RandomForestClassifier # Load the Iris dataset iris = load_iris() X = iris.data y = iris.target target_names = iris.target_names # Train a RandomForestClassifier clf = RandomForestClassifier(n_estimators=100).fit(X, y) # Function to make predictions def predict_species(sepal_length, sepal_width, petal_length, petal_width): features = np.array([sepal_length, sepal_width, petal_length, petal_width]).reshape(1, -1) prediction = clf.predict(features)[0] species = target_names[prediction] return species # Create a Gradio interface iface = gr.Interface( fn=predict_species, inputs=["number", "number", "number", "number"], outputs="text", title="Iris Species Classification", description="Predict the species of an Iris flower based on its sepal and petal measurements." ) # Launch the interface iface.launch()