Datasets:

Modalities:
Text
Formats:
text
Size:
< 1K
Libraries:
Datasets
License:
jellyelly commited on
Commit
43e0e98
1 Parent(s): 8aa2bf7

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +46 -0
  2. model.joblib +3 -0
  3. requirements.txt +4 -0
  4. unique_values.joblib +3 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import joblib
3
+ import numpy as np
4
+ import pandas as pd
5
+
6
+ # Load the model and unique brand values
7
+ model = joblib.load('model.joblib')
8
+ unique_values = joblib.load('unique_values.joblib')
9
+ brand_values = unique_values['Brand']
10
+
11
+ # Define the prediction function
12
+ def predict(brand, screen_size, resolution_width, resolution_height):
13
+ # Convert inputs to appropriate types
14
+ screen_size = float(screen_size)
15
+ resolution_width = int(resolution_width)
16
+ resolution_height = int(resolution_height)
17
+
18
+ # Prepare the input array for prediction
19
+ input_data = pd.DataFrame({
20
+ 'Brand': [brand],
21
+ 'Screen Size': [screen_size],
22
+ 'Resolution (Width)': [resolution_width],
23
+ 'Resolution (Height)': [resolution_height]
24
+ })
25
+
26
+ # Perform the prediction
27
+ prediction = model.predict(input_data)
28
+
29
+ return prediction[0]
30
+
31
+ # Create the Gradio interface
32
+ interface = gr.Interface(
33
+ fn=predict,
34
+ inputs=[
35
+ gr.Dropdown(choices=list(brand_values), label="Brand"),
36
+ gr.Textbox(label="Screen Size"),
37
+ gr.Textbox(label="Resolution (Width)"),
38
+ gr.Textbox(label="Resolution (Height)")
39
+ ],
40
+ outputs="text",
41
+ title="Monitor Predictor",
42
+ description="Enter the brand, screen size, and resolution to predict the target value."
43
+ )
44
+
45
+ # Launch the app
46
+ interface.launch()
model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f3791b6924a3511c032ec93116e277ecda73f7a7e745a3c8dd170fd069dd1a62
3
+ size 165387
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ joblib
2
+ pandas
3
+ scikit-learn==1.3.2
4
+ xgboost==2.1.1
unique_values.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1fae982d906ebe09bb185149a43b296d40305dd74a80eb1c2731dd1ad1f32589
3
+ size 1203