Skip to content

Commit

Permalink
Rename to num_top_feature_important_values
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitris-athanasiou committed Jan 14, 2020
1 parent 5283cd9 commit 1f255b1
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand All @@ -89,23 +89,23 @@ 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;
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 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;
this.gamma = gamma;
this.eta = eta;
this.maximumNumberTrees = maximumNumberTrees;
this.featureBagFraction = featureBagFraction;
this.topFeatureImportanceValues = topFeatureImportanceValues;
this.numTopFeatureImportanceValues = numTopFeatureImportanceValues;
this.predictionFieldName = predictionFieldName;
this.trainingPercent = trainingPercent;
this.numTopClasses = numTopClasses;
Expand Down Expand Up @@ -141,8 +141,8 @@ public Double getFeatureBagFraction() {
return featureBagFraction;
}

public Integer getTopFeatureImportanceValues() {
return topFeatureImportanceValues;
public Integer getNumTopFeatureImportanceValues() {
return numTopFeatureImportanceValues;
}

public String getPredictionFieldName() {
Expand Down Expand Up @@ -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);
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, topFeatureImportanceValues,
return Objects.hash(dependentVariable, lambda, gamma, eta, maximumNumberTrees, featureBagFraction, numTopFeatureImportanceValues,
predictionFieldName, trainingPercent, randomizeSeed, numTopClasses);
}

Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand All @@ -86,22 +86,22 @@ 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;
this.gamma = gamma;
this.eta = eta;
this.maximumNumberTrees = maximumNumberTrees;
this.featureBagFraction = featureBagFraction;
this.topFeatureImportanceValues = topFeatureImportanceValues;
this.numTopFeatureImportanceValues = numTopFeatureImportanceValues;
this.predictionFieldName = predictionFieldName;
this.trainingPercent = trainingPercent;
this.randomizeSeed = randomizeSeed;
Expand Down Expand Up @@ -136,8 +136,8 @@ public Double getFeatureBagFraction() {
return featureBagFraction;
}

public Integer getTopFeatureImportanceValues() {
return topFeatureImportanceValues;
public Integer getNumTopFeatureImportanceValues() {
return numTopFeatureImportanceValues;
}

public String getPredictionFieldName() {
Expand Down Expand Up @@ -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);
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, topFeatureImportanceValues,
return Objects.hash(dependentVariable, lambda, gamma, eta, maximumNumberTrees, featureBagFraction, numTopFeatureImportanceValues,
predictionFieldName, trainingPercent, randomizeSeed);
}

Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -3672,7 +3672,7 @@ public void testPutTrainedModel() throws Exception {
}
{
PutTrainedModelRequest request = new PutTrainedModelRequest(trainedModelConfig);

// tag::put-trained-model-execute-listener
ActionListener<PutTrainedModelResponse> listener = new ActionListener<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
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 @@ -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)
Expand Down Expand Up @@ -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)
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 @@ -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[]

+
--
Expand Down
Loading

0 comments on commit 1f255b1

Please sign in to comment.