In [1]:
%AddJar https://sparktc.ibmcloud.com/repo/latest/SystemML.jar
In [5]:
import org.apache.sysml.api.MLContext
In [6]:
import org.apache.spark.sql.SQLContext
val sqlCtx = new SQLContext(sc)
val ml = new MLContext(sc)
val dml = """
X = rand(rows=100, cols=10)
sumX = sum(X)
outMatrix = matrix(sumX, rows=1, cols=1)
write(outMatrix, " ", format="csv")
"""
ml.reset()
ml.registerOutput("outMatrix")
val out = ml.executeScript(dml)
val outMatrix = out.getDF(sqlCtx, "outMatrix")
In [7]:
outMatrix.show
In [ ]: