Donlapark commited on
Commit
cee389d
1 Parent(s): 5d42b61

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +40 -0
  2. model.joblib +3 -0
  3. requirements.txt +4 -0
  4. unique_values.joblib +3 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import joblib
3
+ import numpy as np
4
+
5
+ # Load the model and unique brand values
6
+ model = joblib.load('model.joblib')
7
+ unique_values = joblib.load('unique_values.joblib')
8
+ brand_values = unique_values['Brand']
9
+
10
+ # Define the prediction function
11
+ def predict(brand, screen_size, resolution_width, resolution_height):
12
+ # Convert inputs to appropriate types
13
+ screen_size = float(screen_size)
14
+ resolution_width = int(resolution_width)
15
+ resolution_height = int(resolution_height)
16
+
17
+ # Prepare the input array for prediction
18
+ input_data = np.array([[brand, screen_size, resolution_width, resolution_height]])
19
+
20
+ # Perform the prediction
21
+ prediction = model.predict(input_data)
22
+
23
+ return prediction[0]
24
+
25
+ # Create the Gradio interface
26
+ interface = gr.Interface(
27
+ fn=predict,
28
+ inputs=[
29
+ gr.Dropdown(choices=brand_values, label="Brand"),
30
+ gr.Textbox(label="Screen Size"),
31
+ gr.Textbox(label="Resolution (Width)"),
32
+ gr.Textbox(label="Resolution (Height)")
33
+ ],
34
+ outputs="text",
35
+ title="Monitor Predictor",
36
+ description="Enter the brand, screen size, and resolution to predict the target value."
37
+ )
38
+
39
+ # Launch the app
40
+ 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