package com.fz.classification
import com.fz.util.Utils
import org.apache.spark.mllib.classification.{LogisticRegressionWithSGD, LogisticRegressionWithLBFGS}
import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.mllib.regression.LabeledPoint
import org.apache.spark.{SparkConf, SparkContext}
/**
* 逻辑回归封装算法
* Labels used in Logistic Regression should be {0, 1, ..., k - 1} for k classes multi-label classification problem
* 输入参数:
* testOrNot : 是否是测试,正常情况设置为false
* input:输出数据;
* minPartitions : 输入数据最小partition个数
* output:输出路径
* targetIndex:目标列所在下标,从1开始
* splitter:数据分隔符;
* method:使用逻辑回归算法:"SGD" or "LBFGS"
* hasIntercept : 是否具有截距
* numClasses: 目标列类别个数;
* Created by fanzhe on 2016/12/19.
*/
object LogisticRegression {
def main (args: Array[String]) {
if(args.length != 9){
println("Usage: com.fz.classification.LogisticRegression testOrNot input minPartitions output targetIndex " +
"splitter method hasIntercept numClasses")
System.exit(-1)
}
val testOrNot = args(0).toBoolean // 是否是测试,sparkContext获取方式不一样, true 为test
val input = args(1)
val minPartitions = args(2).toInt
val output = args(3)
val targetIndex = args(4).toInt // 从1开始,不是从0开始要注意
val splitter = args(5)
val method = args(6) //should be "SGD" or "LBFGS"
val hasIntercept = args(7).toBoolean
val numClasses = args(8).toInt
val sc = Utils.getSparkContext(testOrNot,"Logistic Create Model")
// construct data
// Load and parse the data
val training = Utils.getLabeledPointData(sc,input,minPartitions,splitter,targetIndex).cache()
// Run training algorithm to build the model
val model = method match {
case "SGD" => new LogisticRegressionWithSGD()
.setIntercept(hasIntercept)
.run(training)
case "LBFGS" => new LogisticRegressionWithLBFGS().setNumClasses(numClasses)
.setIntercept(hasIntercept)
.run(training)
case _ => throw new RuntimeException("no method")
}
// save model
model.save(sc,output)
sc.stop()
}
}
Traits are a fundamental unit of code reuse in Scala. A trait encapsulates method and field definitions, which can then be reused by mixing them into classes. Unlike class inheritance, in which each c
版本:WebLogic Server 10.3
说明:%DOMAIN_HOME%:指WebLogic Server 域(Domain)目录
例如我的做测试的域的根目录 DOMAIN_HOME=D:/Weblogic/Middleware/user_projects/domains/base_domain
1.为了保证操作安全,备份%DOMAIN_HOME%/security/Defa
http://crazyjvm.iteye.com/blog/1693757 文中提到相关超时问题,但是又出现了一个问题,我把min和max都设置成了180000,但是仍然出现了以下的异常信息:
Client session timed out, have not heard from server in 154339ms for sessionid 0x13a3f7732340003
在Mysql 众多表中查找一个表名或者字段名的 SQL 语句:
方法一:SELECT table_name, column_name from information_schema.columns WHERE column_name LIKE 'Name';
方法二:SELECT column_name from information_schema.colum