pgurazada1 commited on
Commit
ce32751
1 Parent(s): 7940dfd

infereence script

Browse files
Files changed (1) hide show
  1. inference.py +36 -0
inference.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from sklearn.datasets import fetch_openml
2
+ from sklearn.model_selection import train_test_split
3
+
4
+ from gradio_client import Client
5
+
6
+ client = Client("pgurazada1/diamond-price-predictor")
7
+
8
+ dataset = fetch_openml(data_id=43355, as_frame=True, parser='auto')
9
+
10
+ diamond_prices = dataset.data
11
+
12
+ target = ['price']
13
+ numeric_features = ['carat']
14
+ categorical_features = ['shape', 'cut', 'color', 'clarity', 'report', 'type']
15
+
16
+ X = diamond_prices.drop(columns=target)
17
+ y = diamond_prices[target]
18
+
19
+ Xtrain, Xtest, ytrain, ytest = train_test_split(
20
+ X, y,
21
+ test_size=0.2,
22
+ random_state=42
23
+ )
24
+
25
+ result = client.predict(
26
+ 3, # float in 'Carat' Number component
27
+ "Round", # Literal['Round', 'Princess', 'Emerald', 'Asscher', 'Cushion', 'Radiant', 'Oval', 'Pear', 'Marquise'] in 'Shape' Dropdown component
28
+ "Ideal", # Literal['Ideal', 'Premium', 'Very Good', 'Good', 'Fair'] in 'Cut' Dropdown component
29
+ "D", # Literal['D', 'E', 'F', 'G', 'H', 'I', 'J'] in 'Color' Dropdown component
30
+ "IF", # Literal['IF', 'VVS1', 'VVS2', 'VS1', 'VS2', 'SI1', 'SI2', 'I1'] in 'Clarity' Dropdown component
31
+ "GIA", # Literal['GIA', 'IGI', 'HRD', 'AGS'] in 'Report' Dropdown component
32
+ "Natural", # Literal['Natural', 'Lab Grown'] in 'Type' Dropdown component
33
+ api_name="/predict"
34
+ )
35
+
36
+ print(result)