Skip to content

Commit

Permalink
[ML] Rename data frame analytics maximum_number_trees to max_trees (#…
Browse files Browse the repository at this point in the history
…53300)

Deprecates `maximum_number_trees` parameter of classification and
regression and replaces it with `max_trees`.
  • Loading branch information
dimitris-athanasiou authored Mar 11, 2020
1 parent d367984 commit 5a32f50
Show file tree
Hide file tree
Showing 17 changed files with 149 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static Builder builder(String dependentVariable) {
static final ParseField LAMBDA = new ParseField("lambda");
static final ParseField GAMMA = new ParseField("gamma");
static final ParseField ETA = new ParseField("eta");
static final ParseField MAXIMUM_NUMBER_TREES = new ParseField("maximum_number_trees");
static final ParseField MAX_TREES = new ParseField("max_trees");
static final ParseField FEATURE_BAG_FRACTION = new ParseField("feature_bag_fraction");
static final ParseField NUM_TOP_FEATURE_IMPORTANCE_VALUES = new ParseField("num_top_feature_importance_values");
static final ParseField PREDICTION_FIELD_NAME = new ParseField("prediction_field_name");
Expand Down Expand Up @@ -74,7 +74,7 @@ public static Builder builder(String dependentVariable) {
PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), LAMBDA);
PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), GAMMA);
PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), ETA);
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), MAXIMUM_NUMBER_TREES);
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), MAX_TREES);
PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), FEATURE_BAG_FRACTION);
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), NUM_TOP_FEATURE_IMPORTANCE_VALUES);
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), PREDICTION_FIELD_NAME);
Expand All @@ -87,7 +87,7 @@ public static Builder builder(String dependentVariable) {
private final Double lambda;
private final Double gamma;
private final Double eta;
private final Integer maximumNumberTrees;
private final Integer maxTrees;
private final Double featureBagFraction;
private final Integer numTopFeatureImportanceValues;
private final String predictionFieldName;
Expand All @@ -96,14 +96,14 @@ public static Builder builder(String dependentVariable) {
private final Long randomizeSeed;

private Classification(String dependentVariable, @Nullable Double lambda, @Nullable Double gamma, @Nullable Double eta,
@Nullable Integer maximumNumberTrees, @Nullable Double featureBagFraction,
@Nullable Integer maxTrees, @Nullable Double featureBagFraction,
@Nullable Integer numTopFeatureImportanceValues, @Nullable String predictionFieldName,
@Nullable Double trainingPercent, @Nullable Integer numTopClasses, @Nullable Long randomizeSeed) {
this.dependentVariable = Objects.requireNonNull(dependentVariable);
this.lambda = lambda;
this.gamma = gamma;
this.eta = eta;
this.maximumNumberTrees = maximumNumberTrees;
this.maxTrees = maxTrees;
this.featureBagFraction = featureBagFraction;
this.numTopFeatureImportanceValues = numTopFeatureImportanceValues;
this.predictionFieldName = predictionFieldName;
Expand Down Expand Up @@ -133,8 +133,8 @@ public Double getEta() {
return eta;
}

public Integer getMaximumNumberTrees() {
return maximumNumberTrees;
public Integer getMaxTrees() {
return maxTrees;
}

public Double getFeatureBagFraction() {
Expand Down Expand Up @@ -174,8 +174,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (eta != null) {
builder.field(ETA.getPreferredName(), eta);
}
if (maximumNumberTrees != null) {
builder.field(MAXIMUM_NUMBER_TREES.getPreferredName(), maximumNumberTrees);
if (maxTrees != null) {
builder.field(MAX_TREES.getPreferredName(), maxTrees);
}
if (featureBagFraction != null) {
builder.field(FEATURE_BAG_FRACTION.getPreferredName(), featureBagFraction);
Expand All @@ -201,7 +201,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws

@Override
public int hashCode() {
return Objects.hash(dependentVariable, lambda, gamma, eta, maximumNumberTrees, featureBagFraction, numTopFeatureImportanceValues,
return Objects.hash(dependentVariable, lambda, gamma, eta, maxTrees, featureBagFraction, numTopFeatureImportanceValues,
predictionFieldName, trainingPercent, randomizeSeed, numTopClasses);
}

Expand All @@ -214,7 +214,7 @@ public boolean equals(Object o) {
&& Objects.equals(lambda, that.lambda)
&& Objects.equals(gamma, that.gamma)
&& Objects.equals(eta, that.eta)
&& Objects.equals(maximumNumberTrees, that.maximumNumberTrees)
&& Objects.equals(maxTrees, that.maxTrees)
&& Objects.equals(featureBagFraction, that.featureBagFraction)
&& Objects.equals(numTopFeatureImportanceValues, that.numTopFeatureImportanceValues)
&& Objects.equals(predictionFieldName, that.predictionFieldName)
Expand All @@ -233,7 +233,7 @@ public static class Builder {
private Double lambda;
private Double gamma;
private Double eta;
private Integer maximumNumberTrees;
private Integer maxTrees;
private Double featureBagFraction;
private Integer numTopFeatureImportanceValues;
private String predictionFieldName;
Expand All @@ -260,8 +260,8 @@ public Builder setEta(Double eta) {
return this;
}

public Builder setMaximumNumberTrees(Integer maximumNumberTrees) {
this.maximumNumberTrees = maximumNumberTrees;
public Builder setMaxTrees(Integer maxTrees) {
this.maxTrees = maxTrees;
return this;
}

Expand Down Expand Up @@ -296,7 +296,7 @@ public Builder setNumTopClasses(Integer numTopClasses) {
}

public Classification build() {
return new Classification(dependentVariable, lambda, gamma, eta, maximumNumberTrees, featureBagFraction,
return new Classification(dependentVariable, lambda, gamma, eta, maxTrees, featureBagFraction,
numTopFeatureImportanceValues, predictionFieldName, trainingPercent, numTopClasses, randomizeSeed);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static Builder builder(String dependentVariable) {
static final ParseField LAMBDA = new ParseField("lambda");
static final ParseField GAMMA = new ParseField("gamma");
static final ParseField ETA = new ParseField("eta");
static final ParseField MAXIMUM_NUMBER_TREES = new ParseField("maximum_number_trees");
static final ParseField MAX_TREES = new ParseField("max_trees");
static final ParseField FEATURE_BAG_FRACTION = new ParseField("feature_bag_fraction");
static final ParseField NUM_TOP_FEATURE_IMPORTANCE_VALUES = new ParseField("num_top_feature_importance_values");
static final ParseField PREDICTION_FIELD_NAME = new ParseField("prediction_field_name");
Expand Down Expand Up @@ -72,7 +72,7 @@ public static Builder builder(String dependentVariable) {
PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), LAMBDA);
PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), GAMMA);
PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), ETA);
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), MAXIMUM_NUMBER_TREES);
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), MAX_TREES);
PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), FEATURE_BAG_FRACTION);
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), NUM_TOP_FEATURE_IMPORTANCE_VALUES);
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), PREDICTION_FIELD_NAME);
Expand All @@ -84,22 +84,22 @@ public static Builder builder(String dependentVariable) {
private final Double lambda;
private final Double gamma;
private final Double eta;
private final Integer maximumNumberTrees;
private final Integer maxTrees;
private final Double featureBagFraction;
private final Integer numTopFeatureImportanceValues;
private final String predictionFieldName;
private final Double trainingPercent;
private final Long randomizeSeed;

private Regression(String dependentVariable, @Nullable Double lambda, @Nullable Double gamma, @Nullable Double eta,
@Nullable Integer maximumNumberTrees, @Nullable Double featureBagFraction,
@Nullable Integer maxTrees, @Nullable Double featureBagFraction,
@Nullable Integer numTopFeatureImportanceValues, @Nullable String predictionFieldName,
@Nullable Double trainingPercent, @Nullable Long randomizeSeed) {
this.dependentVariable = Objects.requireNonNull(dependentVariable);
this.lambda = lambda;
this.gamma = gamma;
this.eta = eta;
this.maximumNumberTrees = maximumNumberTrees;
this.maxTrees = maxTrees;
this.featureBagFraction = featureBagFraction;
this.numTopFeatureImportanceValues = numTopFeatureImportanceValues;
this.predictionFieldName = predictionFieldName;
Expand Down Expand Up @@ -128,8 +128,8 @@ public Double getEta() {
return eta;
}

public Integer getMaximumNumberTrees() {
return maximumNumberTrees;
public Integer getMaxTrees() {
return maxTrees;
}

public Double getFeatureBagFraction() {
Expand Down Expand Up @@ -165,8 +165,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (eta != null) {
builder.field(ETA.getPreferredName(), eta);
}
if (maximumNumberTrees != null) {
builder.field(MAXIMUM_NUMBER_TREES.getPreferredName(), maximumNumberTrees);
if (maxTrees != null) {
builder.field(MAX_TREES.getPreferredName(), maxTrees);
}
if (featureBagFraction != null) {
builder.field(FEATURE_BAG_FRACTION.getPreferredName(), featureBagFraction);
Expand All @@ -189,7 +189,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws

@Override
public int hashCode() {
return Objects.hash(dependentVariable, lambda, gamma, eta, maximumNumberTrees, featureBagFraction, numTopFeatureImportanceValues,
return Objects.hash(dependentVariable, lambda, gamma, eta, maxTrees, featureBagFraction, numTopFeatureImportanceValues,
predictionFieldName, trainingPercent, randomizeSeed);
}

Expand All @@ -202,7 +202,7 @@ public boolean equals(Object o) {
&& Objects.equals(lambda, that.lambda)
&& Objects.equals(gamma, that.gamma)
&& Objects.equals(eta, that.eta)
&& Objects.equals(maximumNumberTrees, that.maximumNumberTrees)
&& Objects.equals(maxTrees, that.maxTrees)
&& Objects.equals(featureBagFraction, that.featureBagFraction)
&& Objects.equals(numTopFeatureImportanceValues, that.numTopFeatureImportanceValues)
&& Objects.equals(predictionFieldName, that.predictionFieldName)
Expand All @@ -220,7 +220,7 @@ public static class Builder {
private Double lambda;
private Double gamma;
private Double eta;
private Integer maximumNumberTrees;
private Integer maxTrees;
private Double featureBagFraction;
private Integer numTopFeatureImportanceValues;
private String predictionFieldName;
Expand All @@ -246,8 +246,8 @@ public Builder setEta(Double eta) {
return this;
}

public Builder setMaximumNumberTrees(Integer maximumNumberTrees) {
this.maximumNumberTrees = maximumNumberTrees;
public Builder setMaxTrees(Integer maxTrees) {
this.maxTrees = maxTrees;
return this;
}

Expand Down Expand Up @@ -277,7 +277,7 @@ public Builder setRandomizeSeed(Long randomizeSeed) {
}

public Regression build() {
return new Regression(dependentVariable, lambda, gamma, eta, maximumNumberTrees, featureBagFraction,
return new Regression(dependentVariable, lambda, gamma, eta, maxTrees, featureBagFraction,
numTopFeatureImportanceValues, predictionFieldName, trainingPercent, randomizeSeed);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ public void testPutDataFrameAnalyticsConfig_GivenRegression() throws Exception {
.setLambda(1.0)
.setGamma(1.0)
.setEta(1.0)
.setMaximumNumberTrees(10)
.setMaxTrees(10)
.setFeatureBagFraction(0.5)
.setNumTopFeatureImportanceValues(3)
.build())
Expand Down Expand Up @@ -1340,7 +1340,7 @@ public void testPutDataFrameAnalyticsConfig_GivenClassification() throws Excepti
.setLambda(1.0)
.setGamma(1.0)
.setEta(1.0)
.setMaximumNumberTrees(10)
.setMaxTrees(10)
.setFeatureBagFraction(0.5)
.setNumTopFeatureImportanceValues(3)
.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2973,7 +2973,7 @@ public void testPutDataFrameAnalytics() throws Exception {
.setLambda(1.0) // <2>
.setGamma(5.5) // <3>
.setEta(5.5) // <4>
.setMaximumNumberTrees(50) // <5>
.setMaxTrees(50) // <5>
.setFeatureBagFraction(0.4) // <6>
.setNumTopFeatureImportanceValues(3) // <7>
.setPredictionFieldName("my_prediction_field_name") // <8>
Expand All @@ -2988,7 +2988,7 @@ public void testPutDataFrameAnalytics() throws Exception {
.setLambda(1.0) // <2>
.setGamma(5.5) // <3>
.setEta(5.5) // <4>
.setMaximumNumberTrees(50) // <5>
.setMaxTrees(50) // <5>
.setFeatureBagFraction(0.4) // <6>
.setNumTopFeatureImportanceValues(3) // <7>
.setPredictionFieldName("my_prediction_field_name") // <8>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static Classification randomClassification() {
.setLambda(randomBoolean() ? null : randomDoubleBetween(0.0, Double.MAX_VALUE, true))
.setGamma(randomBoolean() ? null : randomDoubleBetween(0.0, Double.MAX_VALUE, true))
.setEta(randomBoolean() ? null : randomDoubleBetween(0.001, 1.0, true))
.setMaximumNumberTrees(randomBoolean() ? null : randomIntBetween(1, 2000))
.setMaxTrees(randomBoolean() ? null : randomIntBetween(1, 2000))
.setFeatureBagFraction(randomBoolean() ? null : randomDoubleBetween(0.0, 1.0, false))
.setNumTopFeatureImportanceValues(randomBoolean() ? null : randomIntBetween(0, Integer.MAX_VALUE))
.setPredictionFieldName(randomBoolean() ? null : randomAlphaOfLength(10))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static Regression randomRegression() {
.setLambda(randomBoolean() ? null : randomDoubleBetween(0.0, Double.MAX_VALUE, true))
.setGamma(randomBoolean() ? null : randomDoubleBetween(0.0, Double.MAX_VALUE, true))
.setEta(randomBoolean() ? null : randomDoubleBetween(0.001, 1.0, true))
.setMaximumNumberTrees(randomBoolean() ? null : randomIntBetween(1, 2000))
.setMaxTrees(randomBoolean() ? null : randomIntBetween(1, 2000))
.setFeatureBagFraction(randomBoolean() ? null : randomDoubleBetween(0.0, 1.0, false))
.setNumTopFeatureImportanceValues(randomBoolean() ? null : randomIntBetween(0, Integer.MAX_VALUE))
.setPredictionFieldName(randomBoolean() ? null : randomAlphaOfLength(10))
Expand Down
8 changes: 4 additions & 4 deletions docs/reference/ml/df-analytics/apis/put-dfanalytics.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ include::{docdir}/ml/ml-shared.asciidoc[tag=eta]
(Optional, double)
include::{docdir}/ml/ml-shared.asciidoc[tag=feature-bag-fraction]

`analysis`.`classification`.`maximum_number_trees`::::
`analysis`.`classification`.`max_trees`::::
(Optional, integer)
include::{docdir}/ml/ml-shared.asciidoc[tag=maximum-number-trees]
include::{docdir}/ml/ml-shared.asciidoc[tag=max-trees]

`analysis`.`classification`.`gamma`::::
(Optional, double)
Expand Down Expand Up @@ -218,9 +218,9 @@ include::{docdir}/ml/ml-shared.asciidoc[tag=eta]
(Optional, double)
include::{docdir}/ml/ml-shared.asciidoc[tag=feature-bag-fraction]

`analysis`.`regression`.`maximum_number_trees`::::
`analysis`.`regression`.`max_trees`::::
(Optional, integer)
include::{docdir}/ml/ml-shared.asciidoc[tag=maximum-number-trees]
include::{docdir}/ml/ml-shared.asciidoc[tag=max-trees]

`analysis`.`regression`.`gamma`::::
(Optional, double)
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/ml/ml-shared.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -946,10 +946,10 @@ remain started until it is explicitly stopped. By default this setting is not
set.
end::max-empty-searches[]

tag::maximum-number-trees[]
tag::max-trees[]
Advanced configuration option. Defines the maximum number of trees the forest is
allowed to contain. The maximum value is 2000.
end::maximum-number-trees[]
end::max-trees[]

tag::memory-estimation[]
An object containing the memory estimates. The object has the
Expand Down
Loading

0 comments on commit 5a32f50

Please sign in to comment.