Skip to content

Commit 8325ba7

Browse files
committed
cleanup & increment version
1 parent 8323bdd commit 8325ba7

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Unreleased
44
**Bugfixes**
55
- Fixed DS2 score code for CAS that was generated when registering a Python model.
66
- `PyMAS.score_code(dest='ESP')` corrected to `dest='EP'`
7+
- Fixed an issue where long user-defined properties prevented model registration.
78

89

910
v1.1.1 (2019-8-6)

src/sasctl/tasks.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,43 @@
2525

2626

2727
def _sklearn_to_dict(model):
28+
# As of Viya 3.4 model registration fails if character fields are longer
29+
# than 1024 characters
30+
DESC_MAXLEN = 1024
31+
32+
# As of Viya 3.4 model registration fails if user-defined properties are
33+
# longer than 512 characters.
34+
PROP_MAXLEN = 512
35+
2836
# Convert Scikit-learn values to built-in Model Manager values
2937
mappings = {'LogisticRegression': 'Logistic regression',
3038
'LinearRegression': 'Linear regression',
3139
'SVC': 'Support vector machine',
3240
'GradientBoostingClassifier': 'Gradient boosting',
41+
'XGBClassifier': 'Gradient boosting',
42+
'XGBRegressor': 'Gradient boosting',
3343
'RandomForestClassifier': 'Forest',
3444
'DecisionTreeClassifier': 'Decision tree',
3545
'DecisionTreeRegressor': 'Decision tree',
3646
'classifier': 'Classification',
3747
'regressor': 'Prediction'}
3848

49+
if hasattr(model, '_final_estimator'):
50+
estimator = type(model._final_estimator)
51+
else:
52+
estimator = type(model)
53+
3954
# Can tell if multi-class .multi_class
4055
result = dict(
41-
description=str(model),
42-
algorithm=mappings.get(type(model).__name__, type(model).__name__),
56+
description=str(model)[:DESC_MAXLEN],
57+
algorithm=mappings.get(estimator.__name__, estimator.__name__),
4358
scoreCodeType='ds2MultiType',
4459
trainCodeType='Python',
4560
function=mappings.get(model._estimator_type, model._estimator_type),
4661
tool='Python %s.%s'
4762
% (sys.version_info.major, sys.version_info.minor),
48-
properties=[{'name': k, 'value': v}
63+
properties=[{'name': str(k)[:PROP_MAXLEN],
64+
'value': str(v)[:PROP_MAXLEN]}
4965
for k, v in model.get_params().items()]
5066
)
5167

0 commit comments

Comments
 (0)