forked from memoryz/mmlspark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ICETransformer.py
48 lines (45 loc) · 1.75 KB
/
ICETransformer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Copyright (C) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE in project root for information.
from synapse.ml.explainers._ICETransformer import _ICETransformer
from pyspark.ml.common import inherit_doc
from typing import List, Dict, Union
@inherit_doc
class ICETransformer(_ICETransformer):
def setCategoricalFeatures(self, values: List[Union[str, Dict]]):
"""
Args:
values: The list of values that represent categorical features to explain.
Values are list of dicts with parameters or just a list of names of categorical features
"""
if len(values) == 0:
pass
else:
list_values = []
for value in values:
if isinstance(value, str):
list_values.append({"name": value})
elif isinstance(value, dict):
list_values.append(value)
else:
pass
self._java_obj.setCategoricalFeaturesPy(list_values)
return self
def setNumericFeatures(self, values: List[Union[str, Dict]]):
"""
Args:
values: The list of values that represent numeric features to explain.
Values are list of dicts with parameters or just a list of names of numeric features
"""
if len(values) == 0:
pass
else:
list_values = []
for value in values:
if isinstance(value, str):
list_values.append({"name": value})
elif isinstance(value, dict):
list_values.append(value)
else:
pass
self._java_obj.setNumericFeaturesPy(list_values)
return self