use of com.alibaba.alink.operator.batch.source.TsvSourceBatchOp in project Alink by alibaba.
the class Chap03 method c_2_2.
static void c_2_2() throws Exception {
new TsvSourceBatchOp().setFilePath(LOCAL_DIR + "u.data").setSchemaStr("user_id long, item_id long, rating float, ts long").firstN(5).print();
new TextSourceBatchOp().setFilePath(LOCAL_DIR + "iris.scale").firstN(5).print();
new LibSvmSourceBatchOp().setFilePath(LOCAL_DIR + "iris.scale").firstN(5).lazyPrint(5, "< read by LibSvmSourceBatchOp >").link(new VectorNormalizeBatchOp().setSelectedCol("features")).print();
}
use of com.alibaba.alink.operator.batch.source.TsvSourceBatchOp in project Alink by alibaba.
the class Chap24 method c_4.
static void c_4() throws Exception {
TsvSourceBatchOp train_set = new TsvSourceBatchOp().setFilePath(DATA_DIR + RATING_TRAIN_FILE).setSchemaStr(RATING_SCHEMA_STRING);
TsvSourceBatchOp test_set = new TsvSourceBatchOp().setFilePath(DATA_DIR + RATING_TEST_FILE).setSchemaStr(RATING_SCHEMA_STRING);
if (!new File(DATA_DIR + ALS_MODEL_FILE).exists()) {
train_set.link(new AlsTrainBatchOp().setUserCol(USER_COL).setItemCol(ITEM_COL).setRateCol(RATING_COL).setLambda(0.1).setRank(10).setNumIter(10)).link(new AkSinkBatchOp().setFilePath(DATA_DIR + ALS_MODEL_FILE));
BatchOperator.execute();
}
new PipelineModel(new AlsRateRecommender().setUserCol(USER_COL).setItemCol(ITEM_COL).setRecommCol(RECOMM_COL).setModelData(new AkSourceBatchOp().setFilePath(DATA_DIR + ALS_MODEL_FILE)), new Lookup().setSelectedCols(ITEM_COL).setOutputCols("item_name").setModelData(getSourceItems()).setMapKeyCols("item_id").setMapValueCols("title")).transform(test_set.filter("user_id=1")).select("user_id, rating, recomm, item_name").orderBy("rating, recomm", 1000).lazyPrint(-1);
BatchOperator.execute();
new AlsRateRecommender().setUserCol(USER_COL).setItemCol(ITEM_COL).setRecommCol(RECOMM_COL).setModelData(new AkSourceBatchOp().setFilePath(DATA_DIR + ALS_MODEL_FILE)).transform(test_set).link(new EvalRegressionBatchOp().setLabelCol(RATING_COL).setPredictionCol(RECOMM_COL).lazyPrintMetrics());
BatchOperator.execute();
}
Aggregations