Dagli是LikedI开源的用于Java(和其他JVM语言)的机器学习函数库,其开发团队表示通过它可轻松编写不易出错、可读、可修改、可维护且易于部署的模型管道,而不会引起技术债。Dagli充分利用了现代多核的CPU和功能日益强大的GPU,可以对真实世界模型进行有效的单机训练。
下面是一个文本分类器的介绍性示例,此文本分类器以管道的形式实现,使用梯度增强决策树模型(XGBoost)的主动学习以及高维gram集作为逻辑回归分类器中的特征:
Placeholder<Strig>text=ewPlaceholder<>();Placeholder<LabelType>label=ewPlaceholder<>();Tokestokes=ewTokes().withIput(text);NgramVectoruigramFeatures=ewNgramVector().withMaxSize(1).withIput(tokes);Producer<Vector>leafFeatures=ewXGBoostClassificatio<>().withFeaturesIput(uigramFeatures).withLabelIput(label).asLeafFeatures();NgramVectorgramFeatures=ewNgramVector().withMaxSize(3).withIput(tokes);LibliearClassificatio<LabelType>predictio=ewLibliearClassificatio<LabelType>().withFeaturesIput().fromVectors(gramFeatures,leafFeatures).withLabelIput(label);DAG2x1.Prepared<Strig,LabelType,DiscreteDistributio<LabelType>>traiedModel=DAG.withPlaceholders(text,label).withOutput(predictio).prepare(textList,labelList);LabelTypepredictedLabel=traiedModel.apply("Sometextforwhichtopredictalabel",ull);//traiedModelowcabeserializedadlaterloadedoaserver,iaCLIapp,iaHiveUDF...
评论