6 Copyright (C) e2its - All Rights Reserved 7 * Unauthorized copying of this file, via any medium is strictly prohibited 8 * Proprietary and confidential 10 * This file is part of gDayF project. 12 * Written by Jose L. Sanchez <e2its.es@gmail.com>, 2016-2019 17 from collections
import OrderedDict
25 ModelMetadata.__init__(self, e_c)
38 if atype[0][
'type'] ==
'binomial':
39 distribution =
'binomial' 40 elif atype[0][
'type'] ==
'multinomial':
41 distribution =
'multinomial' 43 distribution =
'default' 46 if each_model[
'model'] == model_type:
47 for key, value
in each_model.items():
48 if key ==
'parameters':
49 self.
model[key] = OrderedDict()
50 for subkey, subvalue
in value.items():
51 if subkey
not in [
'stopping',
'distribution',
'effort']:
52 for parm, parm_value
in subvalue.items():
53 if parm_value[
'seleccionable']:
54 self.
model[key][parm] = parm_value
55 elif subkey ==
'stopping':
56 if amode
in [POC, FAST, FAST_PARANOIAC]:
57 for parm, parm_value
in subvalue.items():
58 if parm_value[
'seleccionable']:
59 self.
model[key][parm] = parm_value
60 elif subkey ==
'effort':
61 for parm, parm_value
in subvalue.items():
62 if parm_value[
'seleccionable']:
63 self.
model[key][parm] = parm_value
64 if isinstance(self.
model[key][parm][
'value'], list)\
66 for counter
in range(0, len(self.
model[key][parm][
'value'])):
67 self.
model[key][parm][
'value'][counter] = \
68 int(self.
model[key][parm][
'value'][counter] * increment)
69 elif self.
model[key][parm][
'type']
in DTYPES \
71 if self.
model[key][parm][
'type']
in ITYPES:
72 self.
model[key][parm][
'value'] = \
73 int(self.
model[key][parm][
'value'] * increment)
75 self.
model[key][parm][
'value'] *= increment
76 elif subkey ==
'distribution':
77 for parm, parm_value
in subvalue.items():
78 if parm_value[
'seleccionable']:
79 self.
model[key][parm] = parm_value
80 if parm ==
'modelType':
81 if distribution ==
'binomial':
82 distribution =
'bernoulli' 83 elif distribution ==
'multinomial':
84 distribution =
'multinomial' 85 if distribution
in [
'bernoulli',
'multinomial']:
86 self.
model[key][parm][
'value'] = distribution
87 self.
model[key][parm][
'type'] = list()
89 self.
model[key] = atype
91 self.
model[key] = value
94 self.
model[
'parameters'][
'seed'][
'value'] = int(ts)
100 if __name__ ==
"__main__":
101 from json
import dumps
103 models = [
'sparkDeepLearningEstimator',
'sparkGradientBoostingEstimator',
104 'sparkGeneralizedLinearEstimator',
'sparkRandomForestEstimator']
105 amodes = [POC, NORMAL]
116 "type":
"multinomial",
123 "type":
"regression",
129 for each_model
in models:
134 print(dumps(modelbase.generate_models(each_model, atype, amode), indent=4))