@Test public final void testPredictiveFieldsDoNotContainTargetField() { final FieldSchema targetField = new FieldSchema("field3", 3, new CategoricalValueSchema(false, ImmutableSet.of("true", "false"))); final List<FieldSchema> predictiveFields = ImmutableList.of( new FieldSchema("field0", 0, new NumericValueSchema(false)), new FieldSchema("field1", 1, new StringValueSchema(true)), new FieldSchema("field2", 2, new NumericValueSchema(true)) ); final List<FieldSchema> allFields = ImmutableList.<FieldSchema>builder() .addAll(predictiveFields) .add(targetField) .build(); final DatasetSchema datasetWithTarget = new DatasetSchema(3, allFields); final DatasetSchema datasetNoTarget = new DatasetSchema(allFields); final SoftAssertions assertions = new SoftAssertions(); assertions.assertThat(datasetWithTarget.getPredictiveFields()) .as("A dataset with target field will consider all fields but the target as predictive fields") .isEqualTo(predictiveFields) .doesNotContain(targetField); assertions.assertThat(datasetNoTarget.getPredictiveFields()) .as("A dataset with no target field will consider all fields, including the target, as predictive fields") .containsAll(predictiveFields) .contains(targetField); assertions.assertAll(); }
public List<FieldSchema> getPredictiveFields() { final Optional<Integer> targetIndex = getTargetIndex(); if (!targetIndex.isPresent()) { return this.fieldSchemas; } return this.fieldSchemas .stream() .filter(field -> field.getFieldIndex() != targetIndex.get()) .collect(Collectors.toList()); }
DatasetSchema implements Serializable { public List<FieldSchema> getPredictiveFields() { final Optional<Integer> targetIndex = getTargetIndex(); if (!targetIndex.isPresent()) { return this.fieldSchemas; } return this.fieldSchemas .stream() .filter(field -> field.getFieldIndex() != targetIndex.get()) .collect(Collectors.toList()); } }
DatasetSchema implements Serializable { public List<FieldSchema> getPredictiveFields() { final Optional<Integer> targetIndex = getTargetIndex(); if (!targetIndex.isPresent()) { return this.fieldSchemas; } return this.fieldSchemas .stream() .filter(field -> field.getFieldIndex() != targetIndex.get()) .collect(Collectors.toList()); } DatasetSchema(final int targetIndex,
                         final List<FieldSchema> fieldSchemas);  DatasetSchema(final List<FieldSchema> fieldSchemas); }
DatasetSchema implements Serializable { public List<FieldSchema> getPredictiveFields() { final Optional<Integer> targetIndex = getTargetIndex(); if (!targetIndex.isPresent()) { return this.fieldSchemas; } return this.fieldSchemas .stream() .filter(field -> field.getFieldIndex() != targetIndex.get()) .collect(Collectors.toList()); } DatasetSchema(final int targetIndex,
                         final List<FieldSchema> fieldSchemas);  DatasetSchema(final List<FieldSchema> fieldSchemas); Optional<Integer> getTargetIndex(); List<FieldSchema> getFieldSchemas(); Optional<FieldSchema> getTargetFieldSchema(); List<FieldSchema> getPredictiveFields(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); }
DatasetSchema implements Serializable { public List<FieldSchema> getPredictiveFields() { final Optional<Integer> targetIndex = getTargetIndex(); if (!targetIndex.isPresent()) { return this.fieldSchemas; } return this.fieldSchemas .stream() .filter(field -> field.getFieldIndex() != targetIndex.get()) .collect(Collectors.toList()); } DatasetSchema(final int targetIndex,
                         final List<FieldSchema> fieldSchemas);  DatasetSchema(final List<FieldSchema> fieldSchemas); Optional<Integer> getTargetIndex(); List<FieldSchema> getFieldSchemas(); Optional<FieldSchema> getTargetFieldSchema(); List<FieldSchema> getPredictiveFields(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString();  }