当前位置: 首页>>代码示例>>Java>>正文


Java L1类代码示例

本文整理汇总了Java中org.apache.mahout.classifier.sgd.L1的典型用法代码示例。如果您正苦于以下问题:Java L1类的具体用法?Java L1怎么用?Java L1使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


L1类属于org.apache.mahout.classifier.sgd包,在下文中一共展示了L1类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.mahout.classifier.sgd.L1; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  List<TelephoneCall> calls = Lists.newArrayList(new TelephoneCallParser("bank-full.csv"));

  double heldOutPercentage = 0.10;


  for (int run = 0; run < 20; run++) {
    Collections.shuffle(calls);
    int cutoff = (int) (heldOutPercentage * calls.size());
    List<TelephoneCall> test = calls.subList(0, cutoff);
    List<TelephoneCall> train = calls.subList(cutoff, calls.size());

    OnlineLogisticRegression lr = new OnlineLogisticRegression(NUM_CATEGORIES, TelephoneCall.FEATURES, new L1())
      .learningRate(1)
      .alpha(1)
      .lambda(0.000001)
      .stepOffset(10000)
      .decayExponent(0.2);
    for (int pass = 0; pass < 20; pass++) {
      for (TelephoneCall observation : train) {
        lr.train(observation.getTarget(), observation.asVector());
      }
      if (pass % 5 == 0) {
        Auc eval = new Auc(0.5);
        for (TelephoneCall testCall : test) {
          eval.add(testCall.getTarget(), lr.classifyScalar(testCall.asVector()));
        }
        System.out.printf("%d, %.4f, %.4f\n", pass, lr.currentLearningRate(), eval.auc());
      }
    }

  }
}
 
开发者ID:frankscholten,项目名称:mahout-sgd-bank-marketing,代码行数:34,代码来源:TelephoneCallClassificationMain.java

示例2: LogisticRegressionModel

import org.apache.mahout.classifier.sgd.L1; //导入依赖的package包/类
public LogisticRegressionModel(int NumCate,int NumFeature,double lambda,int learningRate){
	learningAlgo = new OnlineLogisticRegression(NumCate, NumFeature, new L1());
       learningAlgo.lambda(lambda);
       learningAlgo.learningRate(learningRate);
}
 
开发者ID:T-abide,项目名称:sentiment-analysis-movie-review,代码行数:6,代码来源:LogisticRegressionModel.java


注:本文中的org.apache.mahout.classifier.sgd.L1类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。