Java Code Examples for org.datavec.api.transform.TransformProcess#toYaml()
The following examples show how to use
org.datavec.api.transform.TransformProcess#toYaml() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SerializationExample.java From Java-Deep-Learning-Cookbook with MIT License | 6 votes |
public static void main(String[] args) { Schema schema = new Schema.Builder() .addColumnsString("Name", "Subject") .addColumnInteger("Score") .addColumnCategorical("Grade", Arrays.asList("A","B","C","D")) .addColumnInteger("Passed").build(); TransformProcess transformProcess = new TransformProcess.Builder(schema) .removeColumns("Name") .transform(new ConvertToDouble("Score")) .categoricalToInteger("Grade").build(); String json = transformProcess.toJson(); System.out.println(json); String yaml = transformProcess.toYaml(); System.out.println(yaml); }
Example 2
Source File: SerializationExample.java From Java-Deep-Learning-Cookbook with MIT License | 6 votes |
public static void main(String[] args) { Schema schema = new Schema.Builder() .addColumnsString("Name", "Subject") .addColumnInteger("Score") .addColumnCategorical("Grade", Arrays.asList("A","B","C","D")) .addColumnInteger("Passed").build(); TransformProcess transformProcess = new TransformProcess.Builder(schema) .removeColumns("Name") .transform(new ConvertToDouble("Score")) .categoricalToInteger("Grade").build(); String json = transformProcess.toJson(); System.out.println(json); String yaml = transformProcess.toYaml(); System.out.println(yaml); }
Example 3
Source File: TestYamlJsonSerde.java From DataVec with Apache License 2.0 | 6 votes |
@Test public void testTransformProcessAndSchema() { Schema schema = new Schema.Builder().addColumnInteger("firstCol").addColumnNDArray("nd1a", new long[] {1, 10}) .addColumnNDArray("nd1b", new long[] {1, 10}).addColumnNDArray("nd2", new long[] {1, 100}) .addColumnNDArray("nd3", new long[] {-1, -1}).build(); TransformProcess tp = new TransformProcess.Builder(schema).integerMathOp("firstCol", MathOp.Add, 1) .ndArrayColumnsMathOpTransform("added", MathOp.Add, "nd1a", "nd1b") .ndArrayMathFunctionTransform("nd2", MathFunction.SQRT) .ndArrayScalarOpTransform("nd3", MathOp.Multiply, 2.0).build(); String asJson = tp.toJson(); String asYaml = tp.toYaml(); TransformProcess fromJson = TransformProcess.fromJson(asJson); TransformProcess fromYaml = TransformProcess.fromYaml(asYaml); assertEquals(tp, fromJson); assertEquals(tp, fromYaml); }
Example 4
Source File: TestCustomTransformJsonYaml.java From DataVec with Apache License 2.0 | 6 votes |
@Test public void testCustomTransform() { Schema schema = new Schema.Builder().addColumnInteger("firstCol").addColumnDouble("secondCol").build(); TransformProcess tp = new TransformProcess.Builder(schema).integerMathOp("firstCol", MathOp.Add, 1) .transform(new CustomTransform("secondCol", 3.14159)) .doubleMathOp("secondCol", MathOp.Multiply, 2.0).filter(new CustomFilter(123)) .filter(new CustomCondition("someArg")).build(); String asJson = tp.toJson(); String asYaml = tp.toYaml(); TransformProcess fromJson = TransformProcess.fromJson(asJson); TransformProcess fromYaml = TransformProcess.fromYaml(asYaml); assertEquals(tp, fromJson); assertEquals(tp, fromYaml); }
Example 5
Source File: TestYamlJsonSerde.java From deeplearning4j with Apache License 2.0 | 6 votes |
@Test public void testTransformProcessAndSchema() { Schema schema = new Schema.Builder().addColumnInteger("firstCol").addColumnNDArray("nd1a", new long[] {1, 10}) .addColumnNDArray("nd1b", new long[] {1, 10}).addColumnNDArray("nd2", new long[] {1, 100}) .addColumnNDArray("nd3", new long[] {-1, -1}).build(); TransformProcess tp = new TransformProcess.Builder(schema).integerMathOp("firstCol", MathOp.Add, 1) .ndArrayColumnsMathOpTransform("added", MathOp.Add, "nd1a", "nd1b") .ndArrayMathFunctionTransform("nd2", MathFunction.SQRT) .ndArrayScalarOpTransform("nd3", MathOp.Multiply, 2.0).build(); String asJson = tp.toJson(); String asYaml = tp.toYaml(); TransformProcess fromJson = TransformProcess.fromJson(asJson); TransformProcess fromYaml = TransformProcess.fromYaml(asYaml); assertEquals(tp, fromJson); assertEquals(tp, fromYaml); }
Example 6
Source File: TestCustomTransformJsonYaml.java From deeplearning4j with Apache License 2.0 | 6 votes |
@Test public void testCustomTransform() { Schema schema = new Schema.Builder().addColumnInteger("firstCol").addColumnDouble("secondCol").build(); TransformProcess tp = new TransformProcess.Builder(schema).integerMathOp("firstCol", MathOp.Add, 1) .transform(new CustomTransform("secondCol", 3.14159)) .doubleMathOp("secondCol", MathOp.Multiply, 2.0).filter(new CustomFilter(123)) .filter(new CustomCondition("someArg")).build(); String asJson = tp.toJson(); String asYaml = tp.toYaml(); TransformProcess fromJson = TransformProcess.fromJson(asJson); TransformProcess fromYaml = TransformProcess.fromYaml(asYaml); assertEquals(tp, fromJson); assertEquals(tp, fromYaml); }