File size: 946 Bytes
9e51bf3
 
 
 
 
 
718bc35
9e51bf3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b23f55
 
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
import numpy as np
import gradio as gr
from sklearn.tree import DecisionTreeRegressor
import pickle
# from joblib import load

tree_model = pickle.load(open('tree_model.pkl', 'rb'))
# tree_model = load('tree_model.joblib')


def predict(IW, IF, VW, FP):
    params = [[float(IW), float(IF), float(VW), float(FP)]]
    prediction = np.round(tree_model.predict(params), 2)
    depth, width = prediction[0]
    print(depth, width)
    return depth, width

input1 = gr.inputs.Slider(minimum=0, maximum=100, label="Input 1")
input2 = gr.inputs.Slider(minimum=0, maximum=100, label="Input 2")
input3 = gr.inputs.Slider(minimum=0, maximum=100, label="Input 3")
input4 = gr.inputs.Slider(minimum=0, maximum=100, label="Input 4")

output1 = gr.outputs.Textbox(label="Output")
output2 = gr.outputs.Textbox(label="Output")
interface = gr.Interface(fn=predict, inputs=[input1, input2, input3, input4], outputs=[output1, output2])
interface.launch(share=True)