|
import gradio as gr |
|
import joblib |
|
import numpy as np |
|
import pandas as pd |
|
|
|
|
|
model = joblib.load('model.joblib') |
|
unique_values = joblib.load('unique_values.joblib') |
|
brand_values = unique_values['Brand'] |
|
|
|
|
|
def predict(brand, screen_size, resolution_width, resolution_height): |
|
|
|
screen_size = float(screen_size) |
|
resolution_width = int(resolution_width) |
|
resolution_height = int(resolution_height) |
|
|
|
|
|
input_data = pd.DataFrame({ |
|
'Brand': [brand], |
|
'Screen Size': [screen_size], |
|
'Resolution (Width)': [resolution_width], |
|
'Resolution (Height)': [resolution_height] |
|
}) |
|
|
|
|
|
prediction = model.predict(input_data) |
|
|
|
return prediction[0] |
|
|
|
|
|
interface = gr.Interface( |
|
fn=predict, |
|
inputs=[ |
|
gr.Dropdown(choices=list(brand_values), label="Brand"), |
|
gr.Textbox(label="Screen Size"), |
|
gr.Textbox(label="Resolution (Width)"), |
|
gr.Textbox(label="Resolution (Height)") |
|
], |
|
outputs="text", |
|
title="Monitor Predictor", |
|
description="Enter the brand, screen size, and resolution to predict the target value." |
|
) |
|
|
|
|
|
interface.launch() |