use of org.apache.sysml.api.mlcontext.MatrixMetadata in project systemml by apache.
the class MLContextTest method testJavaRDDGoodMetadataPYDML.
@Test
public void testJavaRDDGoodMetadataPYDML() {
System.out.println("MLContextTest - JavaRDD<String> good metadata PYDML");
List<String> list = new ArrayList<String>();
list.add("1,2,3");
list.add("4,5,6");
list.add("7,8,9");
JavaRDD<String> javaRDD = sc.parallelize(list);
MatrixMetadata mm = new MatrixMetadata(3, 3, 9);
Script script = pydml("print('sum: ' + sum(M))").in("M", javaRDD, mm);
setExpectedStdOut("sum: 45.0");
ml.execute(script);
}
use of org.apache.sysml.api.mlcontext.MatrixMetadata in project systemml by apache.
the class MLContextTest method testDataFrameSumDMLDoublesWithIDColumnSortCheck.
@Test
public void testDataFrameSumDMLDoublesWithIDColumnSortCheck() {
System.out.println("MLContextTest - DataFrame sum DML, doubles with ID column sort check");
List<String> list = new ArrayList<String>();
list.add("3,7,8,9");
list.add("1,1,2,3");
list.add("2,4,5,6");
JavaRDD<String> javaRddString = sc.parallelize(list);
JavaRDD<Row> javaRddRow = javaRddString.map(new CommaSeparatedValueStringToDoubleArrayRow());
List<StructField> fields = new ArrayList<StructField>();
fields.add(DataTypes.createStructField(RDDConverterUtils.DF_ID_COLUMN, DataTypes.DoubleType, true));
fields.add(DataTypes.createStructField("C1", DataTypes.DoubleType, true));
fields.add(DataTypes.createStructField("C2", DataTypes.DoubleType, true));
fields.add(DataTypes.createStructField("C3", DataTypes.DoubleType, true));
StructType schema = DataTypes.createStructType(fields);
Dataset<Row> dataFrame = spark.createDataFrame(javaRddRow, schema);
MatrixMetadata mm = new MatrixMetadata(MatrixFormat.DF_DOUBLES_WITH_INDEX);
Script script = dml("print('M[1,1]: ' + as.scalar(M[1,1]));").in("M", dataFrame, mm);
setExpectedStdOut("M[1,1]: 1.0");
ml.execute(script);
}
use of org.apache.sysml.api.mlcontext.MatrixMetadata in project systemml by apache.
the class MLContextTest method testJavaRDDBadMetadataDML.
@Test(expected = MLContextException.class)
public void testJavaRDDBadMetadataDML() {
System.out.println("MLContextTest - JavaRDD<String> bad metadata DML");
List<String> list = new ArrayList<String>();
list.add("1,2,3");
list.add("4,5,6");
list.add("7,8,9");
JavaRDD<String> javaRDD = sc.parallelize(list);
MatrixMetadata mm = new MatrixMetadata(1, 1, 9);
Script script = dml("print('sum: ' + sum(M));").in("M", javaRDD, mm);
ml.execute(script);
}
use of org.apache.sysml.api.mlcontext.MatrixMetadata in project systemml by apache.
the class MLContextTest method testJavaRDDIJVSumPYDML.
@Test
public void testJavaRDDIJVSumPYDML() {
System.out.println("MLContextTest - JavaRDD<String> IJV sum PYDML");
List<String> list = new ArrayList<String>();
list.add("1 1 5");
list.add("2 2 5");
list.add("3 3 5");
JavaRDD<String> javaRDD = sc.parallelize(list);
MatrixMetadata mm = new MatrixMetadata(MatrixFormat.IJV, 3, 3);
Script script = pydml("print('sum: ' + sum(M))").in("M", javaRDD, mm);
setExpectedStdOut("sum: 15.0");
ml.execute(script);
}
use of org.apache.sysml.api.mlcontext.MatrixMetadata in project systemml by apache.
the class MLContextTest method testDataFrameGoodMetadataPYDML.
@Test
public void testDataFrameGoodMetadataPYDML() {
System.out.println("MLContextTest - DataFrame good metadata PYDML");
List<String> list = new ArrayList<String>();
list.add("10,20,30");
list.add("40,50,60");
list.add("70,80,90");
JavaRDD<String> javaRddString = sc.parallelize(list);
JavaRDD<Row> javaRddRow = javaRddString.map(new CommaSeparatedValueStringToDoubleArrayRow());
List<StructField> fields = new ArrayList<StructField>();
fields.add(DataTypes.createStructField("C1", DataTypes.DoubleType, true));
fields.add(DataTypes.createStructField("C2", DataTypes.DoubleType, true));
fields.add(DataTypes.createStructField("C3", DataTypes.DoubleType, true));
StructType schema = DataTypes.createStructType(fields);
Dataset<Row> dataFrame = spark.createDataFrame(javaRddRow, schema);
MatrixMetadata mm = new MatrixMetadata(3, 3, 9);
Script script = pydml("print('sum: ' + sum(M))").in("M", dataFrame, mm);
setExpectedStdOut("sum: 450.0");
ml.execute(script);
}
Aggregations