帮酷LOGO
0 0 评论
文章标签:IMP  Prediction  预计  tasks  PRE  JAVA  任务  Implementation  
Pure Java implementation of Xgboost predictor for online prediction tasks.

  • 源代码名称:xgboost-predictor-java
  • 源代码网址:http://www.github.com/komiya-atsushi/xgboost-predictor-java
  • xgboost-predictor-java源代码文档
  • xgboost-predictor-java源代码下载
  • Git URL:
    git://www.github.com/komiya-atsushi/xgboost-predictor-java.git
  • Git Clone代码到本地:
    git clone http://www.github.com/komiya-atsushi/xgboost-predictor-java
  • Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/komiya-atsushi/xgboost-predictor-java
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
  • xgboost-predictor-java

    Build StatusDownload

    基于纯Java的在线预测任务的xgboost实现。

    添加到依赖项

    如果你使用Maven :

    <repositories>
     <repository>
     <id>bintray-komiya-atsushi-maven</id>
     <url>http://dl.bintray.com/komiya-atsushi/maven</url>
     </repository>
    </repositories>
    <dependencies>
     <dependency>
     <groupId>biz.k11i</groupId>
     <artifactId>xgboost-predictor</artifactId>
     <version>0.3.0</version>
     </dependency>
    </dependencies>

    或Gradle

    repositories {
     // Use jcenter instead of mavenCentral jcenter()
    }
    dependencies {
     compile group: 'biz.k11i', name: 'xgboost-predictor', version: '0.3.0'}

    或sbt :

    resolvers +=Resolver.jcenterRepo
    libraryDependencies ++=Seq(
     "biz.k11i"%"xgboost-predictor"%"0.3.0")

    在Java中使用预测器

    packagebiz.k11i.xgboost.demo;importbiz.k11i.xgboost.Predictor;importbiz.k11i.xgboost.util.FVec;publicclassHowToUseXgboostPredictor {
     publicstaticvoidmain(String[] args) throwsjava.io.IOException {
     // If you want to use faster exp() calculation, uncomment the line below// ObjFunction.useFastMathExp(true);// Load model and create PredictorPredictor predictor =newPredictor(
     newjava.io.FileInputStream("/path/to/xgboost-model-file"));
     // Create feature vector from dense representation by arraydouble[] denseArray = {0, 0, 32, 0, 0, 16, -8, 0, 0, 0};
     FVec fVecDense =FVec.Transformer.fromArray(
     denseArray,
     true/* treat zero element as N/A */);
     // Create feature vector from sparse representation by mapFVec fVecSparse =FVec.Transformer.fromMap(
     newjava.util.HashMap<Integer, Double>() {{
     put(2, 32.);
     put(5, 16.);
     put(6, -8.);
     }});
     // Predict probability or classificationdouble[] prediction = predictor.predict(fVecDense);
     // prediction[0] has// - probability ("binary:logistic")// - class label ("multi:softmax")// Predict leaf index of each treeint[] leafIndexes = predictor.predictLeaf(fVecDense);
     // leafIndexes[i] has a leaf index of i-th tree }
    }

    Apache Spark集成

    查看详细信息xgboost-predictor-spark

    基准

    xgboost4j 1.1的吞吐量比较xgboost-predictor-benchmark

    功能
    模型加载 49017.60 ops/s
    单一预测 6016955.46 ops/s 1018.01 ops/s
    批量预测 44985.71 ops/s 5.04 ops/s
    Leaf prediction 11115853.34 ops/s 1076.54 ops/s


    文章标签:JAVA  IMP  Implementation  PRE  任务  tasks  预计  Prediction  

    Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语