mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-23 13:26:02 +00:00
Deprecates `maximum_number_trees` parameter of classification and regression and replaces it with `max_trees`. Backport of #53300
This commit is contained in:
parent
532a720e1b
commit
0fd0516d0d
@ -44,7 +44,7 @@ public class Classification implements DataFrameAnalysis {
|
||||
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");
|
||||
@ -74,7 +74,7 @@ public class Classification implements DataFrameAnalysis {
|
||||
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);
|
||||
@ -87,7 +87,7 @@ public class Classification implements DataFrameAnalysis {
|
||||
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;
|
||||
@ -96,14 +96,14 @@ public class Classification implements DataFrameAnalysis {
|
||||
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;
|
||||
@ -133,8 +133,8 @@ public class Classification implements DataFrameAnalysis {
|
||||
return eta;
|
||||
}
|
||||
|
||||
public Integer getMaximumNumberTrees() {
|
||||
return maximumNumberTrees;
|
||||
public Integer getMaxTrees() {
|
||||
return maxTrees;
|
||||
}
|
||||
|
||||
public Double getFeatureBagFraction() {
|
||||
@ -174,8 +174,8 @@ public class Classification implements DataFrameAnalysis {
|
||||
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);
|
||||
@ -201,7 +201,7 @@ public class Classification implements DataFrameAnalysis {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ public class Classification implements DataFrameAnalysis {
|
||||
&& 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)
|
||||
@ -233,7 +233,7 @@ public class Classification implements DataFrameAnalysis {
|
||||
private Double lambda;
|
||||
private Double gamma;
|
||||
private Double eta;
|
||||
private Integer maximumNumberTrees;
|
||||
private Integer maxTrees;
|
||||
private Double featureBagFraction;
|
||||
private Integer numTopFeatureImportanceValues;
|
||||
private String predictionFieldName;
|
||||
@ -260,8 +260,8 @@ public class Classification implements DataFrameAnalysis {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMaximumNumberTrees(Integer maximumNumberTrees) {
|
||||
this.maximumNumberTrees = maximumNumberTrees;
|
||||
public Builder setMaxTrees(Integer maxTrees) {
|
||||
this.maxTrees = maxTrees;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ public class Classification implements DataFrameAnalysis {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class Regression implements DataFrameAnalysis {
|
||||
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");
|
||||
@ -72,7 +72,7 @@ public class Regression implements DataFrameAnalysis {
|
||||
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);
|
||||
@ -84,7 +84,7 @@ public class Regression implements DataFrameAnalysis {
|
||||
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;
|
||||
@ -92,14 +92,14 @@ public class Regression implements DataFrameAnalysis {
|
||||
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;
|
||||
@ -128,8 +128,8 @@ public class Regression implements DataFrameAnalysis {
|
||||
return eta;
|
||||
}
|
||||
|
||||
public Integer getMaximumNumberTrees() {
|
||||
return maximumNumberTrees;
|
||||
public Integer getMaxTrees() {
|
||||
return maxTrees;
|
||||
}
|
||||
|
||||
public Double getFeatureBagFraction() {
|
||||
@ -165,8 +165,8 @@ public class Regression implements DataFrameAnalysis {
|
||||
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);
|
||||
@ -189,7 +189,7 @@ public class Regression implements DataFrameAnalysis {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ public class Regression implements DataFrameAnalysis {
|
||||
&& 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)
|
||||
@ -220,7 +220,7 @@ public class Regression implements DataFrameAnalysis {
|
||||
private Double lambda;
|
||||
private Double gamma;
|
||||
private Double eta;
|
||||
private Integer maximumNumberTrees;
|
||||
private Integer maxTrees;
|
||||
private Double featureBagFraction;
|
||||
private Integer numTopFeatureImportanceValues;
|
||||
private String predictionFieldName;
|
||||
@ -246,8 +246,8 @@ public class Regression implements DataFrameAnalysis {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMaximumNumberTrees(Integer maximumNumberTrees) {
|
||||
this.maximumNumberTrees = maximumNumberTrees;
|
||||
public Builder setMaxTrees(Integer maxTrees) {
|
||||
this.maxTrees = maxTrees;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ public class Regression implements DataFrameAnalysis {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1327,7 +1327,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase {
|
||||
.setLambda(1.0)
|
||||
.setGamma(1.0)
|
||||
.setEta(1.0)
|
||||
.setMaximumNumberTrees(10)
|
||||
.setMaxTrees(10)
|
||||
.setFeatureBagFraction(0.5)
|
||||
.setNumTopFeatureImportanceValues(3)
|
||||
.build())
|
||||
@ -1370,7 +1370,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase {
|
||||
.setLambda(1.0)
|
||||
.setGamma(1.0)
|
||||
.setEta(1.0)
|
||||
.setMaximumNumberTrees(10)
|
||||
.setMaxTrees(10)
|
||||
.setFeatureBagFraction(0.5)
|
||||
.setNumTopFeatureImportanceValues(3)
|
||||
.build())
|
||||
|
@ -2973,7 +2973,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase {
|
||||
.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>
|
||||
@ -2988,7 +2988,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase {
|
||||
.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>
|
||||
|
@ -30,7 +30,7 @@ public class ClassificationTests extends AbstractXContentTestCase<Classification
|
||||
.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))
|
||||
|
@ -30,7 +30,7 @@ public class RegressionTests extends AbstractXContentTestCase<Regression> {
|
||||
.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))
|
||||
|
@ -126,9 +126,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)
|
||||
@ -220,9 +220,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)
|
||||
|
@ -950,10 +950,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
|
||||
|
@ -33,7 +33,7 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
public static final ParseField LAMBDA = new ParseField("lambda");
|
||||
public static final ParseField GAMMA = new ParseField("gamma");
|
||||
public static final ParseField ETA = new ParseField("eta");
|
||||
public static final ParseField MAXIMUM_NUMBER_TREES = new ParseField("maximum_number_trees");
|
||||
public static final ParseField MAX_TREES = new ParseField("max_trees", "maximum_number_trees");
|
||||
public static final ParseField FEATURE_BAG_FRACTION = new ParseField("feature_bag_fraction");
|
||||
public static final ParseField NUM_TOP_FEATURE_IMPORTANCE_VALUES = new ParseField("num_top_feature_importance_values");
|
||||
|
||||
@ -41,7 +41,7 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
parser.declareDouble(optionalConstructorArg(), LAMBDA);
|
||||
parser.declareDouble(optionalConstructorArg(), GAMMA);
|
||||
parser.declareDouble(optionalConstructorArg(), ETA);
|
||||
parser.declareInt(optionalConstructorArg(), MAXIMUM_NUMBER_TREES);
|
||||
parser.declareInt(optionalConstructorArg(), MAX_TREES);
|
||||
parser.declareDouble(optionalConstructorArg(), FEATURE_BAG_FRACTION);
|
||||
parser.declareInt(optionalConstructorArg(), NUM_TOP_FEATURE_IMPORTANCE_VALUES);
|
||||
}
|
||||
@ -49,14 +49,14 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
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;
|
||||
|
||||
public BoostedTreeParams(@Nullable Double lambda,
|
||||
@Nullable Double gamma,
|
||||
@Nullable Double eta,
|
||||
@Nullable Integer maximumNumberTrees,
|
||||
@Nullable Integer maxTrees,
|
||||
@Nullable Double featureBagFraction,
|
||||
@Nullable Integer numTopFeatureImportanceValues) {
|
||||
if (lambda != null && lambda < 0) {
|
||||
@ -68,8 +68,8 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
if (eta != null && (eta < 0.001 || eta > 1)) {
|
||||
throw ExceptionsHelper.badRequestException("[{}] must be a double in [0.001, 1]", ETA.getPreferredName());
|
||||
}
|
||||
if (maximumNumberTrees != null && (maximumNumberTrees <= 0 || maximumNumberTrees > 2000)) {
|
||||
throw ExceptionsHelper.badRequestException("[{}] must be an integer in [1, 2000]", MAXIMUM_NUMBER_TREES.getPreferredName());
|
||||
if (maxTrees != null && (maxTrees <= 0 || maxTrees > 2000)) {
|
||||
throw ExceptionsHelper.badRequestException("[{}] must be an integer in [1, 2000]", MAX_TREES.getPreferredName());
|
||||
}
|
||||
if (featureBagFraction != null && (featureBagFraction <= 0 || featureBagFraction > 1.0)) {
|
||||
throw ExceptionsHelper.badRequestException("[{}] must be a double in (0, 1]", FEATURE_BAG_FRACTION.getPreferredName());
|
||||
@ -81,7 +81,7 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
this.lambda = lambda;
|
||||
this.gamma = gamma;
|
||||
this.eta = eta;
|
||||
this.maximumNumberTrees = maximumNumberTrees;
|
||||
this.maxTrees = maxTrees;
|
||||
this.featureBagFraction = featureBagFraction;
|
||||
this.numTopFeatureImportanceValues = numTopFeatureImportanceValues;
|
||||
}
|
||||
@ -90,7 +90,7 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
lambda = in.readOptionalDouble();
|
||||
gamma = in.readOptionalDouble();
|
||||
eta = in.readOptionalDouble();
|
||||
maximumNumberTrees = in.readOptionalVInt();
|
||||
maxTrees = in.readOptionalVInt();
|
||||
featureBagFraction = in.readOptionalDouble();
|
||||
if (in.getVersion().onOrAfter(Version.V_7_6_0)) {
|
||||
numTopFeatureImportanceValues = in.readOptionalInt();
|
||||
@ -104,7 +104,7 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
out.writeOptionalDouble(lambda);
|
||||
out.writeOptionalDouble(gamma);
|
||||
out.writeOptionalDouble(eta);
|
||||
out.writeOptionalVInt(maximumNumberTrees);
|
||||
out.writeOptionalVInt(maxTrees);
|
||||
out.writeOptionalDouble(featureBagFraction);
|
||||
if (out.getVersion().onOrAfter(Version.V_7_6_0)) {
|
||||
out.writeOptionalInt(numTopFeatureImportanceValues);
|
||||
@ -122,8 +122,8 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
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);
|
||||
@ -145,8 +145,8 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
if (eta != null) {
|
||||
params.put(ETA.getPreferredName(), eta);
|
||||
}
|
||||
if (maximumNumberTrees != null) {
|
||||
params.put(MAXIMUM_NUMBER_TREES.getPreferredName(), maximumNumberTrees);
|
||||
if (maxTrees != null) {
|
||||
params.put(MAX_TREES.getPreferredName(), maxTrees);
|
||||
}
|
||||
if (featureBagFraction != null) {
|
||||
params.put(FEATURE_BAG_FRACTION.getPreferredName(), featureBagFraction);
|
||||
@ -165,14 +165,14 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
return 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(lambda, gamma, eta, maximumNumberTrees, featureBagFraction, numTopFeatureImportanceValues);
|
||||
return Objects.hash(lambda, gamma, eta, maxTrees, featureBagFraction, numTopFeatureImportanceValues);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
@ -184,7 +184,7 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
private Double lambda;
|
||||
private Double gamma;
|
||||
private Double eta;
|
||||
private Integer maximumNumberTrees;
|
||||
private Integer maxTrees;
|
||||
private Double featureBagFraction;
|
||||
private Integer numTopFeatureImportanceValues;
|
||||
|
||||
@ -194,7 +194,7 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
this.lambda = params.lambda;
|
||||
this.gamma = params.gamma;
|
||||
this.eta = params.eta;
|
||||
this.maximumNumberTrees = params.maximumNumberTrees;
|
||||
this.maxTrees = params.maxTrees;
|
||||
this.featureBagFraction = params.featureBagFraction;
|
||||
this.numTopFeatureImportanceValues = params.numTopFeatureImportanceValues;
|
||||
}
|
||||
@ -214,8 +214,8 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMaximumNumberTrees(Integer maximumNumberTrees) {
|
||||
this.maximumNumberTrees = maximumNumberTrees;
|
||||
public Builder setMaxTrees(Integer maxTrees) {
|
||||
this.maxTrees = maxTrees;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable {
|
||||
}
|
||||
|
||||
public BoostedTreeParams build() {
|
||||
return new BoostedTreeParams(lambda, gamma, eta, maximumNumberTrees, featureBagFraction, numTopFeatureImportanceValues);
|
||||
return new BoostedTreeParams(lambda, gamma, eta, maxTrees, featureBagFraction, numTopFeatureImportanceValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ public final class ReservedFieldNames {
|
||||
BoostedTreeParams.LAMBDA.getPreferredName(),
|
||||
BoostedTreeParams.GAMMA.getPreferredName(),
|
||||
BoostedTreeParams.ETA.getPreferredName(),
|
||||
BoostedTreeParams.MAXIMUM_NUMBER_TREES.getPreferredName(),
|
||||
BoostedTreeParams.MAX_TREES.getPreferredName(),
|
||||
BoostedTreeParams.FEATURE_BAG_FRACTION.getPreferredName(),
|
||||
BoostedTreeParams.NUM_TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName(),
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
"lambda" : {
|
||||
"type" : "double"
|
||||
},
|
||||
"maximum_number_trees" : {
|
||||
"max_trees" : {
|
||||
"type" : "integer"
|
||||
},
|
||||
"num_top_classes" : {
|
||||
@ -87,7 +87,7 @@
|
||||
"lambda" : {
|
||||
"type" : "double"
|
||||
},
|
||||
"maximum_number_trees" : {
|
||||
"max_trees" : {
|
||||
"type" : "integer"
|
||||
},
|
||||
"num_top_feature_importance_values" : {
|
||||
|
@ -39,7 +39,7 @@ public class BoostedTreeParamsTests extends AbstractBWCSerializationTestCase<Boo
|
||||
.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))
|
||||
.build();
|
||||
@ -88,16 +88,16 @@ public class BoostedTreeParamsTests extends AbstractBWCSerializationTestCase<Boo
|
||||
|
||||
public void testConstructor_GivenMaximumNumberTreesIsZero() {
|
||||
ElasticsearchStatusException e = expectThrows(ElasticsearchStatusException.class,
|
||||
() -> BoostedTreeParams.builder().setMaximumNumberTrees(0).build());
|
||||
() -> BoostedTreeParams.builder().setMaxTrees(0).build());
|
||||
|
||||
assertThat(e.getMessage(), equalTo("[maximum_number_trees] must be an integer in [1, 2000]"));
|
||||
assertThat(e.getMessage(), equalTo("[max_trees] must be an integer in [1, 2000]"));
|
||||
}
|
||||
|
||||
public void testConstructor_GivenMaximumNumberTreesIsGreaterThan2k() {
|
||||
ElasticsearchStatusException e = expectThrows(ElasticsearchStatusException.class,
|
||||
() -> BoostedTreeParams.builder().setMaximumNumberTrees(2001).build());
|
||||
() -> BoostedTreeParams.builder().setMaxTrees(2001).build());
|
||||
|
||||
assertThat(e.getMessage(), equalTo("[maximum_number_trees] must be an integer in [1, 2000]"));
|
||||
assertThat(e.getMessage(), equalTo("[max_trees] must be an integer in [1, 2000]"));
|
||||
}
|
||||
|
||||
public void testConstructor_GivenFeatureBagFractionIsLessThanZero() {
|
||||
|
@ -76,8 +76,8 @@ integTest.runner {
|
||||
'ml/data_frame_analytics_crud/Test put regression given negative gamma',
|
||||
'ml/data_frame_analytics_crud/Test put regression given eta less than 1e-3',
|
||||
'ml/data_frame_analytics_crud/Test put regression given eta greater than one',
|
||||
'ml/data_frame_analytics_crud/Test put regression given maximum_number_trees is zero',
|
||||
'ml/data_frame_analytics_crud/Test put regression given maximum_number_trees is greater than 2k',
|
||||
'ml/data_frame_analytics_crud/Test put regression given max_trees is zero',
|
||||
'ml/data_frame_analytics_crud/Test put regression given max_trees is greater than 2k',
|
||||
'ml/data_frame_analytics_crud/Test put regression given feature_bag_fraction is negative',
|
||||
'ml/data_frame_analytics_crud/Test put regression given feature_bag_fraction is greater than one',
|
||||
'ml/data_frame_analytics_crud/Test put regression given training_percent is less than one',
|
||||
@ -87,8 +87,8 @@ integTest.runner {
|
||||
'ml/data_frame_analytics_crud/Test put classification given negative gamma',
|
||||
'ml/data_frame_analytics_crud/Test put classification given eta less than 1e-3',
|
||||
'ml/data_frame_analytics_crud/Test put classification given eta greater than one',
|
||||
'ml/data_frame_analytics_crud/Test put classification given maximum_number_trees is zero',
|
||||
'ml/data_frame_analytics_crud/Test put classification given maximum_number_trees is greater than 2k',
|
||||
'ml/data_frame_analytics_crud/Test put classification given max_trees is zero',
|
||||
'ml/data_frame_analytics_crud/Test put classification given max_trees is greater than 2k',
|
||||
'ml/data_frame_analytics_crud/Test put classification given feature_bag_fraction is negative',
|
||||
'ml/data_frame_analytics_crud/Test put classification given feature_bag_fraction is greater than one',
|
||||
'ml/data_frame_analytics_crud/Test put classification given num_top_classes is less than zero',
|
||||
|
@ -434,7 +434,7 @@ public class ClassificationIT extends MlNativeDataFrameAnalyticsIntegTestCase {
|
||||
.setGamma(1.0)
|
||||
.setEta(1.0)
|
||||
.setFeatureBagFraction(1.0)
|
||||
.setMaximumNumberTrees(1)
|
||||
.setMaxTrees(1)
|
||||
.build();
|
||||
|
||||
DataFrameAnalyticsConfig firstJob = buildAnalytics(firstJobId, sourceIndex, firstJobDestIndex, null,
|
||||
|
@ -283,7 +283,7 @@ public class RegressionIT extends MlNativeDataFrameAnalyticsIntegTestCase {
|
||||
.setGamma(1.0)
|
||||
.setEta(1.0)
|
||||
.setFeatureBagFraction(1.0)
|
||||
.setMaximumNumberTrees(1)
|
||||
.setMaxTrees(1)
|
||||
.build();
|
||||
|
||||
DataFrameAnalyticsConfig firstJob = buildAnalytics(firstJobId, sourceIndex, firstJobDestIndex, null,
|
||||
|
@ -1333,12 +1333,12 @@ setup:
|
||||
}
|
||||
|
||||
---
|
||||
"Test put regression given maximum_number_trees is zero":
|
||||
"Test put regression given max_trees is zero":
|
||||
|
||||
- do:
|
||||
catch: /\[maximum_number_trees\] must be an integer in \[1, 2000\]/
|
||||
catch: /\[max_trees\] must be an integer in \[1, 2000\]/
|
||||
ml.put_data_frame_analytics:
|
||||
id: "regression-maximum-number-trees-is-zero"
|
||||
id: "regression-max-trees-is-zero"
|
||||
body: >
|
||||
{
|
||||
"source": {
|
||||
@ -1350,18 +1350,18 @@ setup:
|
||||
"analysis": {
|
||||
"regression": {
|
||||
"dependent_variable": "foo",
|
||||
"maximum_number_trees": 0
|
||||
"max_trees": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
"Test put regression given maximum_number_trees is greater than 2k":
|
||||
"Test put regression given max_trees is greater than 2k":
|
||||
|
||||
- do:
|
||||
catch: /\[maximum_number_trees\] must be an integer in \[1, 2000\]/
|
||||
catch: /\[max_trees\] must be an integer in \[1, 2000\]/
|
||||
ml.put_data_frame_analytics:
|
||||
id: "regression-maximum-number-trees-greater-than-2k"
|
||||
id: "regression-max-trees-greater-than-2k"
|
||||
body: >
|
||||
{
|
||||
"source": {
|
||||
@ -1373,7 +1373,7 @@ setup:
|
||||
"analysis": {
|
||||
"regression": {
|
||||
"dependent_variable": "foo",
|
||||
"maximum_number_trees": 2001
|
||||
"max_trees": 2001
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1490,7 +1490,7 @@ setup:
|
||||
"lambda": 3.14,
|
||||
"gamma": 0.42,
|
||||
"eta": 0.5,
|
||||
"maximum_number_trees": 400,
|
||||
"max_trees": 400,
|
||||
"feature_bag_fraction": 0.3,
|
||||
"training_percent": 60.3,
|
||||
"randomize_seed": 42
|
||||
@ -1506,7 +1506,7 @@ setup:
|
||||
"lambda": 3.14,
|
||||
"gamma": 0.42,
|
||||
"eta": 0.5,
|
||||
"maximum_number_trees": 400,
|
||||
"max_trees": 400,
|
||||
"feature_bag_fraction": 0.3,
|
||||
"prediction_field_name": "foo_prediction",
|
||||
"training_percent": 60.3,
|
||||
@ -1629,12 +1629,12 @@ setup:
|
||||
}
|
||||
|
||||
---
|
||||
"Test put classification given maximum_number_trees is zero":
|
||||
"Test put classification given max_trees is zero":
|
||||
|
||||
- do:
|
||||
catch: /\[maximum_number_trees\] must be an integer in \[1, 2000\]/
|
||||
catch: /\[max_trees\] must be an integer in \[1, 2000\]/
|
||||
ml.put_data_frame_analytics:
|
||||
id: "classification-maximum-number-trees-is-zero"
|
||||
id: "classification-max-trees-is-zero"
|
||||
body: >
|
||||
{
|
||||
"source": {
|
||||
@ -1646,18 +1646,18 @@ setup:
|
||||
"analysis": {
|
||||
"classification": {
|
||||
"dependent_variable": "foo",
|
||||
"maximum_number_trees": 0
|
||||
"max_trees": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
"Test put classification given maximum_number_trees is greater than 2k":
|
||||
"Test put classification given max_trees is greater than 2k":
|
||||
|
||||
- do:
|
||||
catch: /\[maximum_number_trees\] must be an integer in \[1, 2000\]/
|
||||
catch: /\[max_trees\] must be an integer in \[1, 2000\]/
|
||||
ml.put_data_frame_analytics:
|
||||
id: "classification-maximum-number-trees-greater-than-2k"
|
||||
id: "classification-max-trees-greater-than-2k"
|
||||
body: >
|
||||
{
|
||||
"source": {
|
||||
@ -1669,7 +1669,7 @@ setup:
|
||||
"analysis": {
|
||||
"classification": {
|
||||
"dependent_variable": "foo",
|
||||
"maximum_number_trees": 2001
|
||||
"max_trees": 2001
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1832,7 +1832,7 @@ setup:
|
||||
"lambda": 3.14,
|
||||
"gamma": 0.42,
|
||||
"eta": 0.5,
|
||||
"maximum_number_trees": 400,
|
||||
"max_trees": 400,
|
||||
"feature_bag_fraction": 0.3,
|
||||
"training_percent": 60.3,
|
||||
"randomize_seed": 24
|
||||
@ -1848,7 +1848,7 @@ setup:
|
||||
"lambda": 3.14,
|
||||
"gamma": 0.42,
|
||||
"eta": 0.5,
|
||||
"maximum_number_trees": 400,
|
||||
"max_trees": 400,
|
||||
"feature_bag_fraction": 0.3,
|
||||
"prediction_field_name": "foo_prediction",
|
||||
"training_percent": 60.3,
|
||||
@ -1859,6 +1859,49 @@ setup:
|
||||
- is_true: create_time
|
||||
- is_true: version
|
||||
|
||||
---
|
||||
"Test put classification given deprecated maximum_number_trees":
|
||||
|
||||
- skip:
|
||||
features: allowed_warnings
|
||||
|
||||
- do:
|
||||
allowed_warnings:
|
||||
- 'Deprecated field [maximum_number_trees] used, expected [max_trees] instead'
|
||||
ml.put_data_frame_analytics:
|
||||
id: "classification-with-maximum-number-trees"
|
||||
body: >
|
||||
{
|
||||
"source": {
|
||||
"index": "index-source"
|
||||
},
|
||||
"dest": {
|
||||
"index": "index-dest"
|
||||
},
|
||||
"analysis": {
|
||||
"classification": {
|
||||
"dependent_variable": "foo",
|
||||
"maximum_number_trees": 400,
|
||||
"randomize_seed": 24
|
||||
}
|
||||
}
|
||||
}
|
||||
- match: { id: "classification-with-maximum-number-trees" }
|
||||
- match: { source.index: ["index-source"] }
|
||||
- match: { dest.index: "index-dest" }
|
||||
- match: { analysis: {
|
||||
"classification":{
|
||||
"dependent_variable": "foo",
|
||||
"max_trees": 400,
|
||||
"prediction_field_name": "foo_prediction",
|
||||
"training_percent": 100.0,
|
||||
"randomize_seed": 24,
|
||||
"num_top_classes": 2
|
||||
}
|
||||
}}
|
||||
- is_true: create_time
|
||||
- is_true: version
|
||||
|
||||
---
|
||||
"Test put with description":
|
||||
|
||||
|
@ -79,8 +79,18 @@ public class MlConfigIndexMappingsFullClusterRestartIT extends AbstractFullClust
|
||||
} else {
|
||||
// trigger .ml-config index mappings update
|
||||
createAnomalyDetectorJob(NEW_CLUSTER_JOB_ID);
|
||||
|
||||
// assert that the mappings are updated
|
||||
assertThat(getDataFrameAnalysisMappings(), equalTo(loadDataFrameAnalysisMappings()));
|
||||
Map<String, Object> dataFrameAnalysisMappings = getDataFrameAnalysisMappings();
|
||||
|
||||
// Remove renamed fields
|
||||
if (getOldClusterVersion().before(Version.V_7_7_0)) {
|
||||
dataFrameAnalysisMappings = XContentMapValues.filter(dataFrameAnalysisMappings, null, new String[] {
|
||||
"*.properties.maximum_number_trees" // This was renamed to max_trees
|
||||
});
|
||||
}
|
||||
|
||||
assertThat(dataFrameAnalysisMappings, equalTo(loadDataFrameAnalysisMappings()));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user