File size: 1,168 Bytes
32fe9c6
 
 
 
827611e
32fe9c6
 
 
 
 
 
 
 
 
 
 
827611e
 
 
32fe9c6
 
 
a49d9c6
32fe9c6
 
 
 
a49d9c6
32fe9c6
 
 
 
45aa422
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
import sklearn
import gradio as gr
import joblib
import pandas as pd
import datasets

pipe = joblib.load("./model.pkl")

title = "Supersoaker Defective Product Prediction"
description = "This model predicts Supersoaker production line failures. Drag and drop any slice from dataset or edit values as you wish in below dataframe component."


with open("./config.json") as f:
    config_dict = eval(f.read())
headers = config_dict["sklearn"]["columns"]

df = datasets.load_dataset("merve/supersoaker-failures")
df = df["train"].to_pandas()
df.dropna(axis=0, inplace=True)



inputs = [gr.Dataframe(headers = headers, row_count = (2, "dynamic"), col_count=(24,"dynamic"), label="Input Data", interactive=1)]
outputs = [gr.Dataframe(row_count = (2, "dynamic"), col_count=(1, "fixed"), label="Predictions", headers=["Failures"])]


def infer(inputs):
    data = pd.DataFrame(inputs, columns=headers)
    predictions = pipe.predict(inputs)
    return pd.DataFrame(predictions, columns=["results"])

gr.Interface(infer, inputs = inputs, outputs = outputs, title = title,
            description = description, examples=[df.head(3)], cache_examples=False).launch(debug=True)