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. Redis学习笔记——数据类型及操作

    数据操作 redis是key-value的数据,所以每个数据都是一个键值对 键的类型是字符串 值的类型分为五种: 字符串string 哈希hash 列表list 集合set 有序集合zset 数据操作 ...

  2. Android基础总结(四)网络通信

    网络图片查看器 确定图片的网址 发送http请求 URL url = new URL(address); //获取连接对象,并没有建立连接 HttpURLConnection conn = (Http ...

  3. 源码分享!!!world文档转换为JPG图片

    http://bbs.csdn.net/topics/390055515 —————————————————————————————————————————————————— 基本思路是:先将worl ...

  4. MapReduce 中的两表 join 几种方案简介

    转自:http://my.oschina.net/leejun2005/blog/95186 MapSideJoin例子:http://my.oschina.net/leejun2005/blog/1 ...

  5. 嵌入式驱动开发之uboot---uboot 中的常见命令参数参数

    Uboot相关命令介绍 bootm bootp cmp cp crc32 echo erase flinfo go minfo loadb loads mw 14mw 用指定的数据填充内存 15md ...

  6. 【BZOJ】1609: [Usaco2008 Feb]Eating Together麻烦的聚餐(dp+被坑)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1609 首先我不得不说,我被这题坑了.题目前边没有说可以不需要3种牛都有啊!!!!!!!!然后我一直在 ...

  7. 滚动到指定位置js

    function mScroll(id){ $("html,body").stop(true); $(); }

  8. POJ2456 Aggressive cows(二分+贪心)

    如果C(d)为满足全部牛之间的距离都不小于d. 先对牛舍的位置排序,然后二分枚举d,寻找满足条件的d. #include<iostream> #include<cstdio> ...

  9. EF简单查询

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  10. 修改tomcat配置通过域名直接访问项目首页

    1.在自己项目的web.xml中配置欢迎页面 <welcome-file-list> <welcome-file>index.html</welcome-file> ...