Skip to content

Commit b3fbb90

Browse files
committed
More example updates
1 parent 7b54630 commit b3fbb90

33 files changed

+15334
-301
lines changed
Binary file not shown.
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "MLFlowModel",
3+
"description": "MLFlow Model",
4+
"scoreCodeType": "python",
5+
"trainTable": "",
6+
"trainCodeType": "Python",
7+
"algorithm": "",
8+
"function": "Classification",
9+
"targetVariable": "tensor",
10+
"targetEvent": "1",
11+
"targetLevel": "BINARY",
12+
"eventProbVar": "P_1",
13+
"modeler": "sasdemo",
14+
"tool": "Python 3",
15+
"toolVersion": "3.8.16",
16+
"properties": []
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"role": "inputVariables",
4+
"name": "inputVar.json"
5+
},
6+
{
7+
"role": "outputVariables",
8+
"name": "outputVar.json"
9+
},
10+
{
11+
"role": "score",
12+
"name": "score_MLFlowModel.py"
13+
},
14+
{
15+
"role": "scoreResource",
16+
"name": "MLFlowModel.pickle"
17+
}
18+
]
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
[
2+
{
3+
"name": "fixedacidity",
4+
"level": "interval",
5+
"type": "decimal",
6+
"length": 8
7+
},
8+
{
9+
"name": "volatileacidity",
10+
"level": "interval",
11+
"type": "decimal",
12+
"length": 8
13+
},
14+
{
15+
"name": "citricacid",
16+
"level": "interval",
17+
"type": "decimal",
18+
"length": 8
19+
},
20+
{
21+
"name": "residualsugar",
22+
"level": "interval",
23+
"type": "decimal",
24+
"length": 8
25+
},
26+
{
27+
"name": "chlorides",
28+
"level": "interval",
29+
"type": "decimal",
30+
"length": 8
31+
},
32+
{
33+
"name": "freesulfurdioxide",
34+
"level": "interval",
35+
"type": "decimal",
36+
"length": 8
37+
},
38+
{
39+
"name": "totalsulfurdioxide",
40+
"level": "interval",
41+
"type": "decimal",
42+
"length": 8
43+
},
44+
{
45+
"name": "density",
46+
"level": "interval",
47+
"type": "decimal",
48+
"length": 8
49+
},
50+
{
51+
"name": "pH",
52+
"level": "interval",
53+
"type": "decimal",
54+
"length": 8
55+
},
56+
{
57+
"name": "sulphates",
58+
"level": "interval",
59+
"type": "decimal",
60+
"length": 8
61+
},
62+
{
63+
"name": "alcohol",
64+
"level": "interval",
65+
"type": "decimal",
66+
"length": 8
67+
}
68+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{
3+
"name": "tensor",
4+
"level": "interval",
5+
"type": "decimal",
6+
"length": 8
7+
}
8+
]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import math
2+
import cloudpickle
3+
import pandas as pd
4+
import numpy as np
5+
from pathlib import Path
6+
7+
import settings
8+
9+
with open(Path(settings.pickle_path) / "MLFlowTest.pickle", "rb") as pickle_model:
10+
model = cloudpickle.load(pickle_model)
11+
12+
def score(fixedacidity, volatileacidity, citricacid, residualsugar, chlorides, freesulfurdioxide, totalsulfurdioxide, density, pH, sulphates, alcohol):
13+
"Output: tensor"
14+
15+
try:
16+
global model
17+
except NameError:
18+
with open(Path(settings.pickle_path) / "MLFlowTest.pickle", "rb") as pickle_model:
19+
model = cloudpickle.load(pickle_model)
20+
21+
input_array = pd.DataFrame([[fixedacidity, volatileacidity, citricacid, residualsugar, chlorides, freesulfurdioxide, totalsulfurdioxide, density, pH, sulphates, alcohol]],
22+
columns=["fixedacidity", "volatileacidity", "citricacid", "residualsugar", "chlorides", "freesulfurdioxide", "totalsulfurdioxide", "density", "pH", "sulphates", "alcohol"],
23+
dtype=float)
24+
prediction = model.predict(input_array)
25+
26+
# Check for numpy values and convert to a CAS readable representation
27+
if isinstance(prediction, np.ndarray):
28+
prediction = prediction.tolist()[0]
29+
30+
tensor = prediction
31+
32+
return tensor

0 commit comments

Comments
 (0)