From 1f255b18151638a90a25b402167c1042d2dc5a32 Mon Sep 17 00:00:00 2001 From: Dimitris Athanasiou Date: Tue, 14 Jan 2020 12:33:07 +0200 Subject: [PATCH] Rename to num_top_feature_important_values --- .../client/ml/dataframe/Classification.java | 30 +++++++------- .../client/ml/dataframe/Regression.java | 34 ++++++++-------- .../client/MachineLearningIT.java | 4 +- .../MlClientDocumentationIT.java | 6 +-- .../ml/dataframe/ClassificationTests.java | 2 +- .../client/ml/dataframe/RegressionTests.java | 2 +- .../apis/put-dfanalytics.asciidoc | 8 ++-- docs/reference/ml/ml-shared.asciidoc | 4 +- .../dataframe/analyses/BoostedTreeParams.java | 40 +++++++++---------- .../persistence/ElasticsearchMappings.java | 4 +- .../ml/job/results/ReservedFieldNames.java | 2 +- .../analyses/BoostedTreeParamsTests.java | 6 +-- .../ml/integration/ClassificationIT.java | 2 +- .../xpack/ml/integration/RegressionIT.java | 2 +- 14 files changed, 73 insertions(+), 73 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/Classification.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/Classification.java index bde3556d07b2a..02861adc73845 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/Classification.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/Classification.java @@ -46,7 +46,7 @@ public static Builder builder(String dependentVariable) { static final ParseField ETA = new ParseField("eta"); static final ParseField MAXIMUM_NUMBER_TREES = new ParseField("maximum_number_trees"); static final ParseField FEATURE_BAG_FRACTION = new ParseField("feature_bag_fraction"); - static final ParseField TOP_FEATURE_IMPORTANCE_VALUES = new ParseField("top_feature_importance_values"); + 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"); static final ParseField TRAINING_PERCENT = new ParseField("training_percent"); static final ParseField NUM_TOP_CLASSES = new ParseField("num_top_classes"); @@ -76,7 +76,7 @@ public static Builder builder(String dependentVariable) { PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), ETA); PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), MAXIMUM_NUMBER_TREES); PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), FEATURE_BAG_FRACTION); - PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), TOP_FEATURE_IMPORTANCE_VALUES); + PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), NUM_TOP_FEATURE_IMPORTANCE_VALUES); PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), PREDICTION_FIELD_NAME); PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), TRAINING_PERCENT); PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), NUM_TOP_CLASSES); @@ -89,7 +89,7 @@ public static Builder builder(String dependentVariable) { private final Double eta; private final Integer maximumNumberTrees; private final Double featureBagFraction; - private final Integer topFeatureImportanceValues; + private final Integer numTopFeatureImportanceValues; private final String predictionFieldName; private final Double trainingPercent; private final Integer numTopClasses; @@ -97,7 +97,7 @@ public static Builder builder(String dependentVariable) { private Classification(String dependentVariable, @Nullable Double lambda, @Nullable Double gamma, @Nullable Double eta, @Nullable Integer maximumNumberTrees, @Nullable Double featureBagFraction, - @Nullable Integer topFeatureImportanceValues, @Nullable String predictionFieldName, + @Nullable Integer numTopFeatureImportanceValues, @Nullable String predictionFieldName, @Nullable Double trainingPercent, @Nullable Integer numTopClasses, @Nullable Long randomizeSeed) { this.dependentVariable = Objects.requireNonNull(dependentVariable); this.lambda = lambda; @@ -105,7 +105,7 @@ private Classification(String dependentVariable, @Nullable Double lambda, @Nulla this.eta = eta; this.maximumNumberTrees = maximumNumberTrees; this.featureBagFraction = featureBagFraction; - this.topFeatureImportanceValues = topFeatureImportanceValues; + this.numTopFeatureImportanceValues = numTopFeatureImportanceValues; this.predictionFieldName = predictionFieldName; this.trainingPercent = trainingPercent; this.numTopClasses = numTopClasses; @@ -141,8 +141,8 @@ public Double getFeatureBagFraction() { return featureBagFraction; } - public Integer getTopFeatureImportanceValues() { - return topFeatureImportanceValues; + public Integer getNumTopFeatureImportanceValues() { + return numTopFeatureImportanceValues; } public String getPredictionFieldName() { @@ -180,8 +180,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws if (featureBagFraction != null) { builder.field(FEATURE_BAG_FRACTION.getPreferredName(), featureBagFraction); } - if (topFeatureImportanceValues != null) { - builder.field(TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName(), topFeatureImportanceValues); + if (numTopFeatureImportanceValues != null) { + builder.field(NUM_TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName(), numTopFeatureImportanceValues); } if (predictionFieldName != null) { builder.field(PREDICTION_FIELD_NAME.getPreferredName(), predictionFieldName); @@ -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, topFeatureImportanceValues, + return Objects.hash(dependentVariable, lambda, gamma, eta, maximumNumberTrees, featureBagFraction, numTopFeatureImportanceValues, predictionFieldName, trainingPercent, randomizeSeed, numTopClasses); } @@ -216,7 +216,7 @@ public boolean equals(Object o) { && Objects.equals(eta, that.eta) && Objects.equals(maximumNumberTrees, that.maximumNumberTrees) && Objects.equals(featureBagFraction, that.featureBagFraction) - && Objects.equals(topFeatureImportanceValues, that.topFeatureImportanceValues) + && Objects.equals(numTopFeatureImportanceValues, that.numTopFeatureImportanceValues) && Objects.equals(predictionFieldName, that.predictionFieldName) && Objects.equals(trainingPercent, that.trainingPercent) && Objects.equals(randomizeSeed, that.randomizeSeed) @@ -235,7 +235,7 @@ public static class Builder { private Double eta; private Integer maximumNumberTrees; private Double featureBagFraction; - private Integer topFeatureImportanceValues; + private Integer numTopFeatureImportanceValues; private String predictionFieldName; private Double trainingPercent; private Integer numTopClasses; @@ -270,8 +270,8 @@ public Builder setFeatureBagFraction(Double featureBagFraction) { return this; } - public Builder setTopFeatureImportanceValues(Integer topFeatureImportanceValues) { - this.topFeatureImportanceValues = topFeatureImportanceValues; + public Builder setNumTopFeatureImportanceValues(Integer numTopFeatureImportanceValues) { + this.numTopFeatureImportanceValues = numTopFeatureImportanceValues; return this; } @@ -297,7 +297,7 @@ public Builder setNumTopClasses(Integer numTopClasses) { public Classification build() { return new Classification(dependentVariable, lambda, gamma, eta, maximumNumberTrees, featureBagFraction, - topFeatureImportanceValues, predictionFieldName, trainingPercent, numTopClasses, randomizeSeed); + numTopFeatureImportanceValues, predictionFieldName, trainingPercent, numTopClasses, randomizeSeed); } } } diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/Regression.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/Regression.java index 226f8cb58c5ee..d7e374a2563a1 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/Regression.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/Regression.java @@ -46,7 +46,7 @@ public static Builder builder(String dependentVariable) { static final ParseField ETA = new ParseField("eta"); static final ParseField MAXIMUM_NUMBER_TREES = new ParseField("maximum_number_trees"); static final ParseField FEATURE_BAG_FRACTION = new ParseField("feature_bag_fraction"); - static final ParseField TOP_FEATURE_IMPORTANCE_VALUES = new ParseField("top_feature_importance_values"); + 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"); static final ParseField TRAINING_PERCENT = new ParseField("training_percent"); static final ParseField RANDOMIZE_SEED = new ParseField("randomize_seed"); @@ -74,7 +74,7 @@ public static Builder builder(String dependentVariable) { PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), ETA); PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), MAXIMUM_NUMBER_TREES); PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), FEATURE_BAG_FRACTION); - PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), TOP_FEATURE_IMPORTANCE_VALUES); + PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), NUM_TOP_FEATURE_IMPORTANCE_VALUES); PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), PREDICTION_FIELD_NAME); PARSER.declareDouble(ConstructingObjectParser.optionalConstructorArg(), TRAINING_PERCENT); PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), RANDOMIZE_SEED); @@ -86,14 +86,14 @@ public static Builder builder(String dependentVariable) { private final Double eta; private final Integer maximumNumberTrees; private final Double featureBagFraction; - private final Integer topFeatureImportanceValues; + 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, + private Regression(String dependentVariable, @Nullable Double lambda, @Nullable Double gamma, @Nullable Double eta, @Nullable Integer maximumNumberTrees, @Nullable Double featureBagFraction, - @Nullable Integer topFeatureImportanceValues, @Nullable String predictionFieldName, + @Nullable Integer numTopFeatureImportanceValues, @Nullable String predictionFieldName, @Nullable Double trainingPercent, @Nullable Long randomizeSeed) { this.dependentVariable = Objects.requireNonNull(dependentVariable); this.lambda = lambda; @@ -101,7 +101,7 @@ private Regression(String dependentVariable, @Nullable Double lambda, @Nullable this.eta = eta; this.maximumNumberTrees = maximumNumberTrees; this.featureBagFraction = featureBagFraction; - this.topFeatureImportanceValues = topFeatureImportanceValues; + this.numTopFeatureImportanceValues = numTopFeatureImportanceValues; this.predictionFieldName = predictionFieldName; this.trainingPercent = trainingPercent; this.randomizeSeed = randomizeSeed; @@ -136,8 +136,8 @@ public Double getFeatureBagFraction() { return featureBagFraction; } - public Integer getTopFeatureImportanceValues() { - return topFeatureImportanceValues; + public Integer getNumTopFeatureImportanceValues() { + return numTopFeatureImportanceValues; } public String getPredictionFieldName() { @@ -171,8 +171,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws if (featureBagFraction != null) { builder.field(FEATURE_BAG_FRACTION.getPreferredName(), featureBagFraction); } - if (topFeatureImportanceValues != null) { - builder.field(TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName(), topFeatureImportanceValues); + if (numTopFeatureImportanceValues != null) { + builder.field(NUM_TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName(), numTopFeatureImportanceValues); } if (predictionFieldName != null) { builder.field(PREDICTION_FIELD_NAME.getPreferredName(), predictionFieldName); @@ -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, topFeatureImportanceValues, + return Objects.hash(dependentVariable, lambda, gamma, eta, maximumNumberTrees, featureBagFraction, numTopFeatureImportanceValues, predictionFieldName, trainingPercent, randomizeSeed); } @@ -204,7 +204,7 @@ public boolean equals(Object o) { && Objects.equals(eta, that.eta) && Objects.equals(maximumNumberTrees, that.maximumNumberTrees) && Objects.equals(featureBagFraction, that.featureBagFraction) - && Objects.equals(topFeatureImportanceValues, that.topFeatureImportanceValues) + && Objects.equals(numTopFeatureImportanceValues, that.numTopFeatureImportanceValues) && Objects.equals(predictionFieldName, that.predictionFieldName) && Objects.equals(trainingPercent, that.trainingPercent) && Objects.equals(randomizeSeed, that.randomizeSeed); @@ -222,7 +222,7 @@ public static class Builder { private Double eta; private Integer maximumNumberTrees; private Double featureBagFraction; - private Integer topFeatureImportanceValues; + private Integer numTopFeatureImportanceValues; private String predictionFieldName; private Double trainingPercent; private Long randomizeSeed; @@ -256,8 +256,8 @@ public Builder setFeatureBagFraction(Double featureBagFraction) { return this; } - public Builder setTopFeatureImportanceValues(Integer topFeatureImportanceValues) { - this.topFeatureImportanceValues = topFeatureImportanceValues; + public Builder setNumTopFeatureImportanceValues(Integer numTopFeatureImportanceValues) { + this.numTopFeatureImportanceValues = numTopFeatureImportanceValues; return this; } @@ -277,8 +277,8 @@ public Builder setRandomizeSeed(Long randomizeSeed) { } public Regression build() { - return new Regression(dependentVariable, lambda, gamma, eta, maximumNumberTrees, featureBagFraction, topFeatureImportanceValues, - predictionFieldName, trainingPercent, randomizeSeed); + return new Regression(dependentVariable, lambda, gamma, eta, maximumNumberTrees, featureBagFraction, + numTopFeatureImportanceValues, predictionFieldName, trainingPercent, randomizeSeed); } } } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java index 44f3d0129c7ca..6fe08f8a507de 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java @@ -1299,7 +1299,7 @@ public void testPutDataFrameAnalyticsConfig_GivenRegression() throws Exception { .setEta(1.0) .setMaximumNumberTrees(10) .setFeatureBagFraction(0.5) - .setTopFeatureImportanceValues(3) + .setNumTopFeatureImportanceValues(3) .build()) .setDescription("this is a regression") .build(); @@ -1342,7 +1342,7 @@ public void testPutDataFrameAnalyticsConfig_GivenClassification() throws Excepti .setEta(1.0) .setMaximumNumberTrees(10) .setFeatureBagFraction(0.5) - .setTopFeatureImportanceValues(3) + .setNumTopFeatureImportanceValues(3) .build()) .setDescription("this is a classification") .build(); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java index 38e87ed774ae8..b850b2e8b9f1a 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java @@ -2975,7 +2975,7 @@ public void testPutDataFrameAnalytics() throws Exception { .setEta(5.5) // <4> .setMaximumNumberTrees(50) // <5> .setFeatureBagFraction(0.4) // <6> - .setTopFeatureImportanceValues(3) // <7> + .setNumTopFeatureImportanceValues(3) // <7> .setPredictionFieldName("my_prediction_field_name") // <8> .setTrainingPercent(50.0) // <9> .setRandomizeSeed(1234L) // <10> @@ -2990,7 +2990,7 @@ public void testPutDataFrameAnalytics() throws Exception { .setEta(5.5) // <4> .setMaximumNumberTrees(50) // <5> .setFeatureBagFraction(0.4) // <6> - .setTopFeatureImportanceValues(3) // <7> + .setNumTopFeatureImportanceValues(3) // <7> .setPredictionFieldName("my_prediction_field_name") // <8> .setTrainingPercent(50.0) // <9> .setRandomizeSeed(1234L) // <10> @@ -3672,7 +3672,7 @@ public void testPutTrainedModel() throws Exception { } { PutTrainedModelRequest request = new PutTrainedModelRequest(trainedModelConfig); - + // tag::put-trained-model-execute-listener ActionListener listener = new ActionListener<>() { @Override diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/ml/dataframe/ClassificationTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/ml/dataframe/ClassificationTests.java index f6ded9d3dcbb7..79d78c888880f 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/ml/dataframe/ClassificationTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/ml/dataframe/ClassificationTests.java @@ -32,7 +32,7 @@ public static Classification randomClassification() { .setEta(randomBoolean() ? null : randomDoubleBetween(0.001, 1.0, true)) .setMaximumNumberTrees(randomBoolean() ? null : randomIntBetween(1, 2000)) .setFeatureBagFraction(randomBoolean() ? null : randomDoubleBetween(0.0, 1.0, false)) - .setTopFeatureImportanceValues(randomBoolean() ? null : randomIntBetween(0, Integer.MAX_VALUE)) + .setNumTopFeatureImportanceValues(randomBoolean() ? null : randomIntBetween(0, Integer.MAX_VALUE)) .setPredictionFieldName(randomBoolean() ? null : randomAlphaOfLength(10)) .setTrainingPercent(randomBoolean() ? null : randomDoubleBetween(1.0, 100.0, true)) .setRandomizeSeed(randomBoolean() ? null : randomLong()) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/ml/dataframe/RegressionTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/ml/dataframe/RegressionTests.java index 60529e7e1687b..eedffb4740d78 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/ml/dataframe/RegressionTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/ml/dataframe/RegressionTests.java @@ -32,7 +32,7 @@ public static Regression randomRegression() { .setEta(randomBoolean() ? null : randomDoubleBetween(0.001, 1.0, true)) .setMaximumNumberTrees(randomBoolean() ? null : randomIntBetween(1, 2000)) .setFeatureBagFraction(randomBoolean() ? null : randomDoubleBetween(0.0, 1.0, false)) - .setTopFeatureImportanceValues(randomBoolean() ? null : randomIntBetween(0, Integer.MAX_VALUE)) + .setNumTopFeatureImportanceValues(randomBoolean() ? null : randomIntBetween(0, Integer.MAX_VALUE)) .setPredictionFieldName(randomBoolean() ? null : randomAlphaOfLength(10)) .setTrainingPercent(randomBoolean() ? null : randomDoubleBetween(1.0, 100.0, true)) .build(); diff --git a/docs/reference/ml/df-analytics/apis/put-dfanalytics.asciidoc b/docs/reference/ml/df-analytics/apis/put-dfanalytics.asciidoc index 1fa304bfb2152..18b3446bca56c 100644 --- a/docs/reference/ml/df-analytics/apis/put-dfanalytics.asciidoc +++ b/docs/reference/ml/df-analytics/apis/put-dfanalytics.asciidoc @@ -148,9 +148,9 @@ include::{docdir}/ml/ml-shared.asciidoc[tag=prediction-field-name] (Optional, long) include::{docdir}/ml/ml-shared.asciidoc[tag=randomize-seed] -`analysis`.`classification`.`top_feature_importance_values`:::: +`analysis`.`classification`.`num_top_feature_importance_values`:::: (Optional, integer) -include::{docdir}/ml/ml-shared.asciidoc[tag=top-feature-importance-values] +include::{docdir}/ml/ml-shared.asciidoc[tag=num-top-feature-importance-values] `analysis`.`classification`.`training_percent`:::: (Optional, integer) @@ -231,9 +231,9 @@ include::{docdir}/ml/ml-shared.asciidoc[tag=lambda] (Optional, string) include::{docdir}/ml/ml-shared.asciidoc[tag=prediction-field-name] -`analysis`.`regression`.`top_feature_importance_values`:::: +`analysis`.`regression`.`num_top_feature_importance_values`:::: (Optional, integer) -include::{docdir}/ml/ml-shared.asciidoc[tag=top-feature-importance-values] +include::{docdir}/ml/ml-shared.asciidoc[tag=num-top-feature-importance-values] `analysis`.`regression`.`training_percent`:::: (Optional, integer) diff --git a/docs/reference/ml/ml-shared.asciidoc b/docs/reference/ml/ml-shared.asciidoc index d1b2a952e494f..f25cfb94e8bed 100644 --- a/docs/reference/ml/ml-shared.asciidoc +++ b/docs/reference/ml/ml-shared.asciidoc @@ -640,12 +640,12 @@ tag::indices[] An array of index names. Wildcards are supported. For example: `["it_ops_metrics", "server*"]`. -tag::top-feature-importance-values[] +tag::num-top-feature-importance-values[] Advanced configuration option. If set, feature importance for the top most important features will be computed. Importance is calculated using the SHAP (SHapley Additive exPlanations) method as described in https://papers.nips.cc/paper/7062-a-unified-approach-to-interpreting-model-predictions.pdf[Lundberg, S. M., & Lee, S.-I. A Unified Approach to Interpreting Model Predictions. In NeurIPS 2017.]. -end::top-feature-importance-values[] +end::num-top-feature-importance-values[] + -- diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/BoostedTreeParams.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/BoostedTreeParams.java index b913ffe65cc18..ec563af73f520 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/BoostedTreeParams.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/BoostedTreeParams.java @@ -35,7 +35,7 @@ public class BoostedTreeParams implements ToXContentFragment, Writeable { public static final ParseField ETA = new ParseField("eta"); public static final ParseField MAXIMUM_NUMBER_TREES = new ParseField("maximum_number_trees"); public static final ParseField FEATURE_BAG_FRACTION = new ParseField("feature_bag_fraction"); - public static final ParseField TOP_FEATURE_IMPORTANCE_VALUES = new ParseField("top_feature_importance_values"); + public static final ParseField NUM_TOP_FEATURE_IMPORTANCE_VALUES = new ParseField("num_top_feature_importance_values"); static void declareFields(AbstractObjectParser parser) { parser.declareDouble(optionalConstructorArg(), LAMBDA); @@ -43,7 +43,7 @@ static void declareFields(AbstractObjectParser parser) { parser.declareDouble(optionalConstructorArg(), ETA); parser.declareInt(optionalConstructorArg(), MAXIMUM_NUMBER_TREES); parser.declareDouble(optionalConstructorArg(), FEATURE_BAG_FRACTION); - parser.declareInt(optionalConstructorArg(), TOP_FEATURE_IMPORTANCE_VALUES); + parser.declareInt(optionalConstructorArg(), NUM_TOP_FEATURE_IMPORTANCE_VALUES); } private final Double lambda; @@ -51,14 +51,14 @@ static void declareFields(AbstractObjectParser parser) { private final Double eta; private final Integer maximumNumberTrees; private final Double featureBagFraction; - private final Integer topFeatureImportanceValues; + private final Integer numTopFeatureImportanceValues; public BoostedTreeParams(@Nullable Double lambda, @Nullable Double gamma, @Nullable Double eta, @Nullable Integer maximumNumberTrees, @Nullable Double featureBagFraction, - @Nullable Integer topFeatureImportanceValues) { + @Nullable Integer numTopFeatureImportanceValues) { if (lambda != null && lambda < 0) { throw ExceptionsHelper.badRequestException("[{}] must be a non-negative double", LAMBDA.getPreferredName()); } @@ -74,16 +74,16 @@ public BoostedTreeParams(@Nullable Double lambda, if (featureBagFraction != null && (featureBagFraction <= 0 || featureBagFraction > 1.0)) { throw ExceptionsHelper.badRequestException("[{}] must be a double in (0, 1]", FEATURE_BAG_FRACTION.getPreferredName()); } - if (topFeatureImportanceValues != null && topFeatureImportanceValues < 0) { + if (numTopFeatureImportanceValues != null && numTopFeatureImportanceValues < 0) { throw ExceptionsHelper.badRequestException("[{}] must be a non-negative integer", - TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName()); + NUM_TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName()); } this.lambda = lambda; this.gamma = gamma; this.eta = eta; this.maximumNumberTrees = maximumNumberTrees; this.featureBagFraction = featureBagFraction; - this.topFeatureImportanceValues = topFeatureImportanceValues; + this.numTopFeatureImportanceValues = numTopFeatureImportanceValues; } BoostedTreeParams(StreamInput in) throws IOException { @@ -93,9 +93,9 @@ public BoostedTreeParams(@Nullable Double lambda, maximumNumberTrees = in.readOptionalVInt(); featureBagFraction = in.readOptionalDouble(); if (in.getVersion().onOrAfter(Version.V_8_0_0)) { - topFeatureImportanceValues = in.readOptionalInt(); + numTopFeatureImportanceValues = in.readOptionalInt(); } else { - topFeatureImportanceValues = null; + numTopFeatureImportanceValues = null; } } @@ -107,7 +107,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalVInt(maximumNumberTrees); out.writeOptionalDouble(featureBagFraction); if (out.getVersion().onOrAfter(Version.V_8_0_0)) { - out.writeOptionalInt(topFeatureImportanceValues); + out.writeOptionalInt(numTopFeatureImportanceValues); } } @@ -128,8 +128,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws if (featureBagFraction != null) { builder.field(FEATURE_BAG_FRACTION.getPreferredName(), featureBagFraction); } - if (topFeatureImportanceValues != null) { - builder.field(TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName(), topFeatureImportanceValues); + if (numTopFeatureImportanceValues != null) { + builder.field(NUM_TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName(), numTopFeatureImportanceValues); } return builder; } @@ -151,8 +151,8 @@ Map getParams() { if (featureBagFraction != null) { params.put(FEATURE_BAG_FRACTION.getPreferredName(), featureBagFraction); } - if (topFeatureImportanceValues != null) { - params.put(TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName(), topFeatureImportanceValues); + if (numTopFeatureImportanceValues != null) { + params.put(NUM_TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName(), numTopFeatureImportanceValues); } return params; } @@ -167,12 +167,12 @@ public boolean equals(Object o) { && Objects.equals(eta, that.eta) && Objects.equals(maximumNumberTrees, that.maximumNumberTrees) && Objects.equals(featureBagFraction, that.featureBagFraction) - && Objects.equals(topFeatureImportanceValues, that.topFeatureImportanceValues); + && Objects.equals(numTopFeatureImportanceValues, that.numTopFeatureImportanceValues); } @Override public int hashCode() { - return Objects.hash(lambda, gamma, eta, maximumNumberTrees, featureBagFraction, topFeatureImportanceValues); + return Objects.hash(lambda, gamma, eta, maximumNumberTrees, featureBagFraction, numTopFeatureImportanceValues); } public static Builder builder() { @@ -186,7 +186,7 @@ public static class Builder { private Double eta; private Integer maximumNumberTrees; private Double featureBagFraction; - private Integer topFeatureImportanceValues; + private Integer numTopFeatureImportanceValues; private Builder() {} @@ -215,13 +215,13 @@ public Builder setFeatureBagFraction(Double featureBagFraction) { return this; } - public Builder setTopFeatureImportanceValues(Integer topFeatureImportanceValues) { - this.topFeatureImportanceValues = topFeatureImportanceValues; + public Builder setNumTopFeatureImportanceValues(Integer numTopFeatureImportanceValues) { + this.numTopFeatureImportanceValues = numTopFeatureImportanceValues; return this; } public BoostedTreeParams build() { - return new BoostedTreeParams(lambda, gamma, eta, maximumNumberTrees, featureBagFraction, topFeatureImportanceValues); + return new BoostedTreeParams(lambda, gamma, eta, maximumNumberTrees, featureBagFraction, numTopFeatureImportanceValues); } } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/ElasticsearchMappings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/ElasticsearchMappings.java index fca2ede69d4ce..b64a12e087ea9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/ElasticsearchMappings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/ElasticsearchMappings.java @@ -471,7 +471,7 @@ public static void addDataFrameAnalyticsFields(XContentBuilder builder) throws I .startObject(BoostedTreeParams.FEATURE_BAG_FRACTION.getPreferredName()) .field(TYPE, DOUBLE) .endObject() - .startObject(BoostedTreeParams.TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName()) + .startObject(BoostedTreeParams.NUM_TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName()) .field(TYPE, INTEGER) .endObject() .startObject(Regression.PREDICTION_FIELD_NAME.getPreferredName()) @@ -502,7 +502,7 @@ public static void addDataFrameAnalyticsFields(XContentBuilder builder) throws I .startObject(BoostedTreeParams.FEATURE_BAG_FRACTION.getPreferredName()) .field(TYPE, DOUBLE) .endObject() - .startObject(BoostedTreeParams.TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName()) + .startObject(BoostedTreeParams.NUM_TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName()) .field(TYPE, INTEGER) .endObject() .startObject(Classification.PREDICTION_FIELD_NAME.getPreferredName()) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ReservedFieldNames.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ReservedFieldNames.java index e8c28f6a443c8..968df76d5ed91 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ReservedFieldNames.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ReservedFieldNames.java @@ -322,7 +322,7 @@ public final class ReservedFieldNames { BoostedTreeParams.ETA.getPreferredName(), BoostedTreeParams.MAXIMUM_NUMBER_TREES.getPreferredName(), BoostedTreeParams.FEATURE_BAG_FRACTION.getPreferredName(), - BoostedTreeParams.TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName(), + BoostedTreeParams.NUM_TOP_FEATURE_IMPORTANCE_VALUES.getPreferredName(), ElasticsearchMappings.CONFIG_TYPE, diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/BoostedTreeParamsTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/BoostedTreeParamsTests.java index 896068af5f5d6..6f3aff88846d9 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/BoostedTreeParamsTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/dataframe/analyses/BoostedTreeParamsTests.java @@ -40,7 +40,7 @@ public static BoostedTreeParams createRandom() { .setEta(randomBoolean() ? null : randomDoubleBetween(0.001, 1.0, true)) .setMaximumNumberTrees(randomBoolean() ? null : randomIntBetween(1, 2000)) .setFeatureBagFraction(randomBoolean() ? null : randomDoubleBetween(0.0, 1.0, false)) - .setTopFeatureImportanceValues(randomBoolean() ? null : randomIntBetween(0, Integer.MAX_VALUE)) + .setNumTopFeatureImportanceValues(randomBoolean() ? null : randomIntBetween(0, Integer.MAX_VALUE)) .build(); } @@ -107,8 +107,8 @@ public void testConstructor_GivenFeatureBagFractionIsGreaterThanOne() { public void testConstructor_GivenTopFeatureImportanceValuesIsNegative() { ElasticsearchStatusException e = expectThrows(ElasticsearchStatusException.class, - () -> BoostedTreeParams.builder().setTopFeatureImportanceValues(-1).build()); + () -> BoostedTreeParams.builder().setNumTopFeatureImportanceValues(-1).build()); - assertThat(e.getMessage(), equalTo("[top_feature_importance_values] must be a non-negative integer")); + assertThat(e.getMessage(), equalTo("[num_top_feature_importance_values] must be a non-negative integer")); } } diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/ClassificationIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/ClassificationIT.java index b61a2094257c6..8ae1216ec3120 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/ClassificationIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/ClassificationIT.java @@ -84,7 +84,7 @@ public void testSingleNumericFeatureAndMixedTrainingAndNonTrainingRows() throws DataFrameAnalyticsConfig config = buildAnalytics(jobId, sourceIndex, destIndex, null, new Classification( KEYWORD_FIELD, - BoostedTreeParams.builder().setTopFeatureImportanceValues(1).build(), + BoostedTreeParams.builder().setNumTopFeatureImportanceValues(1).build(), null, null, null, diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RegressionIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RegressionIT.java index 4902be5fc5771..3315727df57c6 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RegressionIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RegressionIT.java @@ -55,7 +55,7 @@ public void testSingleNumericFeatureAndMixedTrainingAndNonTrainingRows() throws DataFrameAnalyticsConfig config = buildAnalytics(jobId, sourceIndex, destIndex, null, new Regression( DEPENDENT_VARIABLE_FIELD, - BoostedTreeParams.builder().setTopFeatureImportanceValues(1).build(), + BoostedTreeParams.builder().setNumTopFeatureImportanceValues(1).build(), null, null, null)