# import gradio as gr # # def greet(name): # return "Hello " + name + "!!" # # demo = gr.Interface(fn=greet, inputs="text", outputs="text") # demo.launch() # import gradio as gr from sklearn.neighbors import KNeighborsClassifier import numpy as np # Training data X = np.array([[1, 2], [2, 3], [3, 1], [6, 5], [7, 7], [8, 6]]) y = np.array([0, 0, 0, 1, 1, 1]) # Training the model model = KNeighborsClassifier(n_neighbors=3) model.fit(X, y) # Define the prediction function def classify_point(x, y): prediction = model.predict([[x, y]]) return "Class " + str(prediction[0]) # Create a Gradio interface demo = gr.Interface( fn=classify_point, inputs=["number", "number"], outputs="text", description="Predict the class of a point based on its coordinates using K-Nearest Neighbors" ) # Launch the app demo.launch()