File size: 916 Bytes
11d3e0b
5e01faf
11d3e0b
 
 
 
f9c3a27
11d3e0b
 
5e01faf
 
11d3e0b
 
 
 
f9aba63
 
 
 
 
 
11d3e0b
f9aba63
8fa7cdc
11d3e0b
1a5b82c
11d3e0b
 
 
1a5b82c
8a2023e
11d3e0b
f9aba63
11d3e0b
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from huggingface_hub import hf_hub_download
import pickle
import gradio as gr
import numpy as np

# Download the model from Hugging Face Hub
model_path = hf_hub_download(repo_id="suryadev1/knn", filename="knn_model_pc.pkl")

# Load the model
with open(model_path, 'rb') as f:
    knn = pickle.load(f)

# Define the prediction function
def predict(input_data):
    # Convert input_data to numpy array
    input=input_data.split(' ')
    first=float(input[0])
    second=float(input[1])
    third=float(input[2])
    fourth=float(input[3])
    fifth=float(input[4])
    # Make predictions
    predictions = knn.predict([[first,second,third,fourth,fifth]])
    return predictions[0]



iface = gr.Interface(
    fn=predict,
    inputs='text',
    outputs='text',
    title="KNN Model Prediction",
    description="Enter values for each feature with spaces to get a prediction."
)

# Launch the interface
iface.launch()