@@ -46,6 +46,7 @@ public static Builder builder(String dependentVariable) {
46
46
static final ParseField ETA = new ParseField ("eta" );
47
47
static final ParseField MAXIMUM_NUMBER_TREES = new ParseField ("maximum_number_trees" );
48
48
static final ParseField FEATURE_BAG_FRACTION = new ParseField ("feature_bag_fraction" );
49
+ static final ParseField NUM_TOP_FEATURE_IMPORTANCE_VALUES = new ParseField ("num_top_feature_importance_values" );
49
50
static final ParseField PREDICTION_FIELD_NAME = new ParseField ("prediction_field_name" );
50
51
static final ParseField TRAINING_PERCENT = new ParseField ("training_percent" );
51
52
static final ParseField NUM_TOP_CLASSES = new ParseField ("num_top_classes" );
@@ -62,10 +63,11 @@ public static Builder builder(String dependentVariable) {
62
63
(Double ) a [3 ],
63
64
(Integer ) a [4 ],
64
65
(Double ) a [5 ],
65
- (String ) a [6 ],
66
- (Double ) a [7 ],
67
- (Integer ) a [8 ],
68
- (Long ) a [9 ]));
66
+ (Integer ) a [6 ],
67
+ (String ) a [7 ],
68
+ (Double ) a [8 ],
69
+ (Integer ) a [9 ],
70
+ (Long ) a [10 ]));
69
71
70
72
static {
71
73
PARSER .declareString (ConstructingObjectParser .constructorArg (), DEPENDENT_VARIABLE );
@@ -74,6 +76,7 @@ public static Builder builder(String dependentVariable) {
74
76
PARSER .declareDouble (ConstructingObjectParser .optionalConstructorArg (), ETA );
75
77
PARSER .declareInt (ConstructingObjectParser .optionalConstructorArg (), MAXIMUM_NUMBER_TREES );
76
78
PARSER .declareDouble (ConstructingObjectParser .optionalConstructorArg (), FEATURE_BAG_FRACTION );
79
+ PARSER .declareInt (ConstructingObjectParser .optionalConstructorArg (), NUM_TOP_FEATURE_IMPORTANCE_VALUES );
77
80
PARSER .declareString (ConstructingObjectParser .optionalConstructorArg (), PREDICTION_FIELD_NAME );
78
81
PARSER .declareDouble (ConstructingObjectParser .optionalConstructorArg (), TRAINING_PERCENT );
79
82
PARSER .declareInt (ConstructingObjectParser .optionalConstructorArg (), NUM_TOP_CLASSES );
@@ -86,20 +89,23 @@ public static Builder builder(String dependentVariable) {
86
89
private final Double eta ;
87
90
private final Integer maximumNumberTrees ;
88
91
private final Double featureBagFraction ;
92
+ private final Integer numTopFeatureImportanceValues ;
89
93
private final String predictionFieldName ;
90
94
private final Double trainingPercent ;
91
95
private final Integer numTopClasses ;
92
96
private final Long randomizeSeed ;
93
97
94
98
private Classification (String dependentVariable , @ Nullable Double lambda , @ Nullable Double gamma , @ Nullable Double eta ,
95
- @ Nullable Integer maximumNumberTrees , @ Nullable Double featureBagFraction , @ Nullable String predictionFieldName ,
99
+ @ Nullable Integer maximumNumberTrees , @ Nullable Double featureBagFraction ,
100
+ @ Nullable Integer numTopFeatureImportanceValues , @ Nullable String predictionFieldName ,
96
101
@ Nullable Double trainingPercent , @ Nullable Integer numTopClasses , @ Nullable Long randomizeSeed ) {
97
102
this .dependentVariable = Objects .requireNonNull (dependentVariable );
98
103
this .lambda = lambda ;
99
104
this .gamma = gamma ;
100
105
this .eta = eta ;
101
106
this .maximumNumberTrees = maximumNumberTrees ;
102
107
this .featureBagFraction = featureBagFraction ;
108
+ this .numTopFeatureImportanceValues = numTopFeatureImportanceValues ;
103
109
this .predictionFieldName = predictionFieldName ;
104
110
this .trainingPercent = trainingPercent ;
105
111
this .numTopClasses = numTopClasses ;
@@ -135,6 +141,10 @@ public Double getFeatureBagFraction() {
135
141
return featureBagFraction ;
136
142
}
137
143
144
+ public Integer getNumTopFeatureImportanceValues () {
145
+ return numTopFeatureImportanceValues ;
146
+ }
147
+
138
148
public String getPredictionFieldName () {
139
149
return predictionFieldName ;
140
150
}
@@ -170,6 +180,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
170
180
if (featureBagFraction != null ) {
171
181
builder .field (FEATURE_BAG_FRACTION .getPreferredName (), featureBagFraction );
172
182
}
183
+ if (numTopFeatureImportanceValues != null ) {
184
+ builder .field (NUM_TOP_FEATURE_IMPORTANCE_VALUES .getPreferredName (), numTopFeatureImportanceValues );
185
+ }
173
186
if (predictionFieldName != null ) {
174
187
builder .field (PREDICTION_FIELD_NAME .getPreferredName (), predictionFieldName );
175
188
}
@@ -188,8 +201,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
188
201
189
202
@ Override
190
203
public int hashCode () {
191
- return Objects .hash (dependentVariable , lambda , gamma , eta , maximumNumberTrees , featureBagFraction , predictionFieldName ,
192
- trainingPercent , randomizeSeed , numTopClasses );
204
+ return Objects .hash (dependentVariable , lambda , gamma , eta , maximumNumberTrees , featureBagFraction , numTopFeatureImportanceValues ,
205
+ predictionFieldName , trainingPercent , randomizeSeed , numTopClasses );
193
206
}
194
207
195
208
@ Override
@@ -203,6 +216,7 @@ public boolean equals(Object o) {
203
216
&& Objects .equals (eta , that .eta )
204
217
&& Objects .equals (maximumNumberTrees , that .maximumNumberTrees )
205
218
&& Objects .equals (featureBagFraction , that .featureBagFraction )
219
+ && Objects .equals (numTopFeatureImportanceValues , that .numTopFeatureImportanceValues )
206
220
&& Objects .equals (predictionFieldName , that .predictionFieldName )
207
221
&& Objects .equals (trainingPercent , that .trainingPercent )
208
222
&& Objects .equals (randomizeSeed , that .randomizeSeed )
@@ -221,6 +235,7 @@ public static class Builder {
221
235
private Double eta ;
222
236
private Integer maximumNumberTrees ;
223
237
private Double featureBagFraction ;
238
+ private Integer numTopFeatureImportanceValues ;
224
239
private String predictionFieldName ;
225
240
private Double trainingPercent ;
226
241
private Integer numTopClasses ;
@@ -255,6 +270,11 @@ public Builder setFeatureBagFraction(Double featureBagFraction) {
255
270
return this ;
256
271
}
257
272
273
+ public Builder setNumTopFeatureImportanceValues (Integer numTopFeatureImportanceValues ) {
274
+ this .numTopFeatureImportanceValues = numTopFeatureImportanceValues ;
275
+ return this ;
276
+ }
277
+
258
278
public Builder setPredictionFieldName (String predictionFieldName ) {
259
279
this .predictionFieldName = predictionFieldName ;
260
280
return this ;
@@ -276,8 +296,8 @@ public Builder setNumTopClasses(Integer numTopClasses) {
276
296
}
277
297
278
298
public Classification build () {
279
- return new Classification (dependentVariable , lambda , gamma , eta , maximumNumberTrees , featureBagFraction , predictionFieldName ,
280
- trainingPercent , numTopClasses , randomizeSeed );
299
+ return new Classification (dependentVariable , lambda , gamma , eta , maximumNumberTrees , featureBagFraction ,
300
+ numTopFeatureImportanceValues , predictionFieldName , trainingPercent , numTopClasses , randomizeSeed );
281
301
}
282
302
}
283
303
}
0 commit comments