File tree 1 file changed +73
-0
lines changed
1 file changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ import requests
2
+ import json
3
+
4
+ # URL for the web service, should be similar to:
5
+ # 'http://8530a665-66f3-49c8-a953-b82a2d312917.eastus.azurecontainer.io/score'
6
+ scoring_uri = 'http://b5a5374b-134a-4533-840a-5d0e53e7a433.southcentralus.azurecontainer.io/score'
7
+ # If the service is authenticated, set the key or token
8
+ key = 'vaJ21LW4f1NUETdxcPZwr06QCuDP1hXZ'
9
+
10
+ # Two sets of data to score, so we get two results back
11
+ data = {"data" :
12
+ [
13
+ {
14
+ "age" : 17 ,
15
+ "campaign" : 1 ,
16
+ "cons.conf.idx" : - 46.2 ,
17
+ "cons.price.idx" : 92.893 ,
18
+ "contact" : "cellular" ,
19
+ "day_of_week" : "mon" ,
20
+ "default" : "no" ,
21
+ "duration" : 971 ,
22
+ "education" : "university.degree" ,
23
+ "emp.var.rate" : - 1.8 ,
24
+ "euribor3m" : 1.299 ,
25
+ "housing" : "yes" ,
26
+ "job" : "blue-collar" ,
27
+ "loan" : "yes" ,
28
+ "marital" : "married" ,
29
+ "month" : "may" ,
30
+ "nr.employed" : 5099.1 ,
31
+ "pdays" : 999 ,
32
+ "poutcome" : "failure" ,
33
+ "previous" : 1
34
+ },
35
+ {
36
+ "age" : 87 ,
37
+ "campaign" : 1 ,
38
+ "cons.conf.idx" : - 46.2 ,
39
+ "cons.price.idx" : 92.893 ,
40
+ "contact" : "cellular" ,
41
+ "day_of_week" : "mon" ,
42
+ "default" : "no" ,
43
+ "duration" : 471 ,
44
+ "education" : "university.degree" ,
45
+ "emp.var.rate" : - 1.8 ,
46
+ "euribor3m" : 1.299 ,
47
+ "housing" : "yes" ,
48
+ "job" : "blue-collar" ,
49
+ "loan" : "yes" ,
50
+ "marital" : "married" ,
51
+ "month" : "may" ,
52
+ "nr.employed" : 5099.1 ,
53
+ "pdays" : 999 ,
54
+ "poutcome" : "failure" ,
55
+ "previous" : 1
56
+ },
57
+ ]
58
+ }
59
+ # Convert to JSON string
60
+ input_data = json .dumps (data )
61
+ with open ("data.json" , "w" ) as _f :
62
+ _f .write (input_data )
63
+
64
+ # Set the content type
65
+ headers = {'Content-Type' : 'application/json' }
66
+ # If authentication is enabled, set the authorization header
67
+ headers ['Authorization' ] = f'Bearer { key } '
68
+
69
+ # Make the request and display the response
70
+ resp = requests .post (scoring_uri , input_data , headers = headers )
71
+ print (resp .json ())
72
+
73
+
You can’t perform that action at this time.
0 commit comments