@@ -49,6 +49,7 @@ public static Builder builder(String dependentVariable) {
49
49
static final ParseField PREDICTION_FIELD_NAME = new ParseField ("prediction_field_name" );
50
50
static final ParseField TRAINING_PERCENT = new ParseField ("training_percent" );
51
51
static final ParseField NUM_TOP_CLASSES = new ParseField ("num_top_classes" );
52
+ static final ParseField RANDOMIZE_SEED = new ParseField ("randomize_seed" );
52
53
53
54
private static final ConstructingObjectParser <Classification , Void > PARSER =
54
55
new ConstructingObjectParser <>(
@@ -63,7 +64,8 @@ public static Builder builder(String dependentVariable) {
63
64
(Double ) a [5 ],
64
65
(String ) a [6 ],
65
66
(Double ) a [7 ],
66
- (Integer ) a [8 ]));
67
+ (Integer ) a [8 ],
68
+ (Long ) a [9 ]));
67
69
68
70
static {
69
71
PARSER .declareString (ConstructingObjectParser .constructorArg (), DEPENDENT_VARIABLE );
@@ -75,6 +77,7 @@ public static Builder builder(String dependentVariable) {
75
77
PARSER .declareString (ConstructingObjectParser .optionalConstructorArg (), PREDICTION_FIELD_NAME );
76
78
PARSER .declareDouble (ConstructingObjectParser .optionalConstructorArg (), TRAINING_PERCENT );
77
79
PARSER .declareInt (ConstructingObjectParser .optionalConstructorArg (), NUM_TOP_CLASSES );
80
+ PARSER .declareLong (ConstructingObjectParser .optionalConstructorArg (), RANDOMIZE_SEED );
78
81
}
79
82
80
83
private final String dependentVariable ;
@@ -86,10 +89,11 @@ public static Builder builder(String dependentVariable) {
86
89
private final String predictionFieldName ;
87
90
private final Double trainingPercent ;
88
91
private final Integer numTopClasses ;
92
+ private final Long randomizeSeed ;
89
93
90
94
private Classification (String dependentVariable , @ Nullable Double lambda , @ Nullable Double gamma , @ Nullable Double eta ,
91
95
@ Nullable Integer maximumNumberTrees , @ Nullable Double featureBagFraction , @ Nullable String predictionFieldName ,
92
- @ Nullable Double trainingPercent , @ Nullable Integer numTopClasses ) {
96
+ @ Nullable Double trainingPercent , @ Nullable Integer numTopClasses , @ Nullable Long randomizeSeed ) {
93
97
this .dependentVariable = Objects .requireNonNull (dependentVariable );
94
98
this .lambda = lambda ;
95
99
this .gamma = gamma ;
@@ -99,6 +103,7 @@ private Classification(String dependentVariable, @Nullable Double lambda, @Nulla
99
103
this .predictionFieldName = predictionFieldName ;
100
104
this .trainingPercent = trainingPercent ;
101
105
this .numTopClasses = numTopClasses ;
106
+ this .randomizeSeed = randomizeSeed ;
102
107
}
103
108
104
109
@ Override
@@ -138,6 +143,10 @@ public Double getTrainingPercent() {
138
143
return trainingPercent ;
139
144
}
140
145
146
+ public Long getRandomizeSeed () {
147
+ return randomizeSeed ;
148
+ }
149
+
141
150
public Integer getNumTopClasses () {
142
151
return numTopClasses ;
143
152
}
@@ -167,6 +176,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
167
176
if (trainingPercent != null ) {
168
177
builder .field (TRAINING_PERCENT .getPreferredName (), trainingPercent );
169
178
}
179
+ if (randomizeSeed != null ) {
180
+ builder .field (RANDOMIZE_SEED .getPreferredName (), randomizeSeed );
181
+ }
170
182
if (numTopClasses != null ) {
171
183
builder .field (NUM_TOP_CLASSES .getPreferredName (), numTopClasses );
172
184
}
@@ -177,7 +189,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
177
189
@ Override
178
190
public int hashCode () {
179
191
return Objects .hash (dependentVariable , lambda , gamma , eta , maximumNumberTrees , featureBagFraction , predictionFieldName ,
180
- trainingPercent , numTopClasses );
192
+ trainingPercent , randomizeSeed , numTopClasses );
181
193
}
182
194
183
195
@ Override
@@ -193,6 +205,7 @@ public boolean equals(Object o) {
193
205
&& Objects .equals (featureBagFraction , that .featureBagFraction )
194
206
&& Objects .equals (predictionFieldName , that .predictionFieldName )
195
207
&& Objects .equals (trainingPercent , that .trainingPercent )
208
+ && Objects .equals (randomizeSeed , that .randomizeSeed )
196
209
&& Objects .equals (numTopClasses , that .numTopClasses );
197
210
}
198
211
@@ -211,6 +224,7 @@ public static class Builder {
211
224
private String predictionFieldName ;
212
225
private Double trainingPercent ;
213
226
private Integer numTopClasses ;
227
+ private Long randomizeSeed ;
214
228
215
229
private Builder (String dependentVariable ) {
216
230
this .dependentVariable = Objects .requireNonNull (dependentVariable );
@@ -251,14 +265,19 @@ public Builder setTrainingPercent(Double trainingPercent) {
251
265
return this ;
252
266
}
253
267
268
+ public Builder setRandomizeSeed (Long randomizeSeed ) {
269
+ this .randomizeSeed = randomizeSeed ;
270
+ return this ;
271
+ }
272
+
254
273
public Builder setNumTopClasses (Integer numTopClasses ) {
255
274
this .numTopClasses = numTopClasses ;
256
275
return this ;
257
276
}
258
277
259
278
public Classification build () {
260
279
return new Classification (dependentVariable , lambda , gamma , eta , maximumNumberTrees , featureBagFraction , predictionFieldName ,
261
- trainingPercent , numTopClasses );
280
+ trainingPercent , numTopClasses , randomizeSeed );
262
281
}
263
282
}
264
283
}
0 commit comments