Spark 优缺点分析

以下翻译自Scikit。 
The advantages of support vector machines are: 
(1)Effective in high dimensional spaces.在高维空间表现良好。 
(2)Still effective in cases where number of dimensions is greater than the number of samples.在数据维度大于样本点数时候,依然可以起作用 
(3)Uses a subset of training points in the decision function (called support vectors), so it is also memory efficient.仅仅使用训练数据的一个子集(支持向量),因此是内存友好型的算法。 
(4)Versatile: different Kernel functions can be specified for the decision function. Common kernels are provided, but it is also possible to specify custom kernels.适应广,能解决多种情况下的分类问题,这是由于它支持不同类型的核函数,甚至支持自定义的核函数。 
能灵活使用多种核函数的确使得SVM变得非常强大,而核函数相关的理论很深奥,初步的探讨可参考转载的一篇文章:http://blog.csdn.net/qq_34531825/article/details/52895621 
The disadvantages of support vector machines include: 
(1)If the number of features is much greater than the number of samples, the method is likely to give poor performances.在数据维度(特征个数)多于样本数很多的时候,通常只能训练出一个表现很差的模型。 
(2)SVMs do not directly provide probability estimates, these are calculated using an expensive five-fold cross-validation (see Scores and probabilities, below).SVM不支持直接进行概率估计,Scikit中使用很耗费资源的5折交叉检验来估计概率。

Spark Mllib

 
 

import org.apache.spark.{SparkConf,SparkContext}
import org.apache.log4j.{Level, Logger}
import org.apache.spark.mllib.classification.{SVMModel,SVMWithSGD}
import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics
import org.apache.spark.mllib.util.MLUtils
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.spark.mllib.optimization.L1Updater
import org.apache.spark.mllib.optimization.SquaredL2Updater object mySVM {
def main(args:Array[String]){
//屏蔽日志
Logger.getLogger("org.apache.spark").setLevel(Level.ERROR)
Logger.getLogger("org.eclipse.jetty.server").setLevel(Level.OFF)
val conf=new SparkConf().setMaster("local").setAppName("My App")
val sc=new SparkContext(conf) // Load training data in LIBSVM format.
val data = MLUtils.loadLibSVMFile(sc, "/data/mllib/sample_libsvm_data.txt")
//println(data.collect()(0))//检查数据 // Split data into training (60%) and test (40%).
val splits = data.randomSplit(Array(0.6, 0.4), seed = 11L)
val training = splits().cache()
val test = splits() // Run training algorithm to build the model
/*
* stepSize: 迭代步长,默认为1.0
* numIterations: 迭代次数,默认为100
* regParam: 正则化参数,默认值为0.0
* miniBatchFraction: 每次迭代参与计算的样本比例,默认为1.0
* gradient:HingeGradient (),梯度下降;
* updater:SquaredL2Updater (),正则化,L2范数;
* optimizer:GradientDescent (gradient, updater),梯度下降最优化计算。
*/
val svmAlg=new SVMWithSGD()
svmAlg.optimizer
.setNumIterations()
.setRegParam(0.1)//正则化参数
.setUpdater(new L1Updater)
val modelL1=svmAlg.run(training) // Clear the default threshold.
modelL1.clearThreshold() // Compute raw scores on the test set.
val scoreAndLabels = test.map { point =>
val score = modelL1.predict(point.features)
(score, point.label)//return score and label
} // Get evaluation metrics.
val metrics = new BinaryClassificationMetrics(scoreAndLabels)
val auROC = metrics.areaUnderROC()
println("Area under ROC = " + auROC) } }

参考文献 
(1) 支持向量机通俗导论(理解SVM的三层境界) http://blog.csdn.net/v_july_v/article/details/7624837 
(2)Spark MLlib SVM算法(源代码分析)http://www.itnose.net/detail/6267193.html 
(3)Spark官网与Scikit官网 
(4)LIBSVM: A  Library是 for Support Vector Machines , Chih-Chung Chang and Chih-Jen Lin,Department of Computer Science National Taiwan University, Taipei, Taiwan http://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.pdf 
(5)A Tutorial on Support Vector Regression Alex J. Smola† and Bernhard Scholkopf 
(6)如何解决机器学习中数据不平衡问题 http://www.zhaokv.com/2016/01/learning-from-imbalanced-data.html 
(7)不平衡数据下的机器学习方法简介 http://www.jianshu.com/p/3e8b9f2764c8 
(8)核函数 http://blog.csdn.net/xiaojiegege123456/article/details/7728198,xiaojiegege123456 CSDN 对核函数有一个比较容易的理解的介绍 
(9)http://www.cnblogs.com/zxb1990/p/5098345.html SVM学习笔记(二)—-手写数字识别 贴近实际应用一些 
(10)http://www.cnblogs.com/jerrylead/archive/2011/03/18/1988406.html 
(11)RBF 参数 http://scikit-learn.org/stable/auto_examples/svm/plot_rbf_parameters.html

Spark机器学习系列之13: 支持向量机SVM的更多相关文章

  1. 机器学习常见面试题—支持向量机SVM

    前言 总结了2017年找实习时,在头条.腾讯.小米.搜狐.阿里等公司常见的机器学习面试题. 支持向量机SVM 关于min和max交换位置满足的 d* <= p* 的条件并不是KKT条件 Ans: ...

  2. Stanford机器学习---第八讲. 支持向量机SVM

    原文: http://blog.csdn.net/abcjennifer/article/details/7849812 本栏目(Machine learning)包括单参数的线性回归.多参数的线性回 ...

  3. 机器学习(二)—支持向量机SVM

    1.SVM的原理是什么? SVM是一种二类分类模型.它的基本模型是在特征空间中寻找间隔最大化的分离超平面的线性分类器.(间隔最大是它有别于感知机) 试图寻找一个超平面来对样本分割,把样本中的正例和反例 ...

  4. 【原】Coursera—Andrew Ng机器学习—Week 7 习题—支持向量机SVM

    [1] [2] Answer: B. 即 x1=3这条垂直线. [3] Answer: B 因为要尽可能小.对B,右侧红叉,有1/2 * 2  = 1 ≥ 1,左侧圆圈,有1/2 * -2  = -1 ...

  5. 【IUML】支持向量机SVM

    从1995年Vapnik等人提出一种机器学习的新方法支持向量机(SVM)之后,支持向量机成为继人工神经网络之后又一研究热点,国内外研究都很多.支持向量机方法是建立在统计学习理论的VC维理论和结构风险最 ...

  6. Spark2.0机器学习系列之11: 聚类(幂迭代聚类, power iteration clustering, PIC)

    在Spark2.0版本中(不是基于RDD API的MLlib),共有四种聚类方法:             (1)K-means             (2)Latent Dirichlet all ...

  7. Spark2.0机器学习系列之10: 聚类(高斯混合模型 GMM)

    在Spark2.0版本中(不是基于RDD API的MLlib),共有四种聚类方法:      (1)K-means      (2)Latent Dirichlet allocation (LDA)  ...

  8. Spark2.0机器学习系列之9: 聚类(k-means,Bisecting k-means,Streaming k-means)

    在Spark2.0版本中(不是基于RDD API的MLlib),共有四种聚类方法:      (1)K-means      (2)Latent Dirichlet allocation (LDA)  ...

  9. 【Spark机器学习速成宝典】模型篇08支持向量机【SVM】(Python版)

    目录 什么是支持向量机(SVM) 线性可分数据集的分类 线性可分数据集的分类(对偶形式) 线性近似可分数据集的分类 线性近似可分数据集的分类(对偶形式) 非线性数据集的分类 SMO算法 合页损失函数 ...

随机推荐

  1. js 刷新后不提示并保留控件状态

    保存后,想提示一下并保留查询条件的状态,发现可以用document.forms[0].submit();继续提交达到刷新的目的 代码如下: ScriptManager.RegisterStartupS ...

  2. elasticsearch中mapping的_source和store的笔记

    0.故事引入 无意中看到了ES的mapping中有store字段,作为一个ES菜鸡,有必要对这个字段进行下笔记. 1._source _source字段我在们进行检索时相当重要, ES默认检索只会返回 ...

  3. jdk 配置时时区设置

    在eclipse中的 Default VM Arguments:添加 -Duser.timezone=Aisa/Shanghai

  4. tableview直接滚动至最后一行

    类似聊天界面,tableview应该直接显示在最后一行,并且不应该有滚动的出现. 在网上查了很久,直接滚动至最后一行很容易实现,有两种方法比较好. 1. 调用scrollToRowAtIndexPat ...

  5. U盘插入拔出提示

    Unit Unit1; Interface Uses Windows, Messages, SysUtils, Variants, classes, Graphics, Controls, Forms ...

  6. java框架---->RxJava的使用(一)

    RxJava是响应式程序设计的一种实现.在响应式程序设计中,当数据到达的时候,消费者做出响应.响应式编程可以将事件传递给注册了的observer.今天我们就来学习一下rxJava,并分析一下它源码感受 ...

  7. [libwww-perl]——POST方法的使用

    libwww-perl是我在学习varnish的时候遇到的一个工具. 具体libwww-perl是干什么的,可以参考官网https://github.com/libwww-perl/libwww-pe ...

  8. pdb文件及引发的思考

    最初只想知道线上iis里需要不需要pdb文件,了解部分之后对于.net底层产生了浓厚的兴趣,看了一点点资料 资料来源: https://www.cnblogs.com/itech/archive/20 ...

  9. 【POJ1275】Cashier Employment 差分约束

    [POJ1275]Cashier Employment 题意: 超市经历已经提供一天里每一小时需要出纳员的最少数量————R(0),R(1),...,R(23).R(0)表示从午夜到凌晨1:00所需要 ...

  10. Android 通过findViewById方式创建TabHost

    package org.shuxiang.tabhostsample; import android.os.Bundle; import android.app.ActivityGroup; impo ...