Grasp the Spark 2.0 (new features, including real project, pure Scala language development, CDH5.7)

Performance improvement and Project Tungsten (tungsten project)

In 1.5 the biggest change is within the development cycle Tungsten first phase of the project has been completed, and in Spark1.5 version officially joined the main functions. This function is performed by Spark to manage their own memory rather than using the JVM , to avoid JVM GC performance loss brings. Memory Java objects are stored as Spark own binary format, calculation takes place directly on the binary format, eliminating the need for serialization and deserialization time. This format is also more compact at the same time, save memory space, but also to better estimate the amount of data size and memory usage.

The following chart shows the performance visual impression, in the default configuration, the comparison test spark1.4 , Spark1.5 in the performance of small-scale and large-scale processing performance data volume:
clip_image002

In the External Data Source aspect, Parquet support has been greatly enhanced. Parquet version upgrade to 1.7 ; faster metadata discovery and Schema Merging ; at the same time be able to read non-standard legal or other tool to generate libraries of parquet documents; as well as faster and more robust dynamic partitioning insert.

 

Availability and Interoperability

Spark1.5 increase in UI View interface, SQL and DataFrame query plan, capable of displaying a different query plan based on different operating memory and runtime, the following picture shows through the UI display interface query plan:

clip_image004

另外Spark1.5加入了其他的易用组件,在Hive模块最大的变化是支持连接Hive 1.2版本的metastore,同时支持metastore partition pruning(通过spark.sql.hive.metastorePartitionPruning=true开启,默认为false)。因为很多公司的Hive集群都升级到了1.2以上,那么这个改进对于需要访问Hive元数据的Spark集群来说非常重要。Spark 1.5支持可以连接Hive 0.13, 0.14, 1.0/0.14.1, 1.1, 1.2metastore

机器学习MLlib

MLlib最大的变化就是从一个机器学习的library开始转向构建一个机器学习工作流的系统,这些变化发生在ML包里面。MLlib模块下现在有两个包:MLlibMLML把整个机器学习的过程抽象成Pipeline,一个Pipeline是由多个Stage组成,每个StageTransformer或者Estimator

以前机器学习工程师要花费大量时间在training model之前的feature的抽取、转换等准备工作。ML提供了多个Transformer,极大提高了这些工作的效率。在1.5版本之后,已经有了25+feature transformer,其中CountVectorizer, Discrete Cosine Transformation, MinMaxScaler, NGram, PCA, RFormula, StopWordsRemover, and VectorSlicer这些feature transformer都是1.5版本新添加的,做机器学习的朋友可以看看哪些满足你的需求。

这里面的一个亮点就是RFormula的支持,目标是使用户可以把原来用R写的机器学习程序(目前只支持GLM算法)不用修改直接搬到Spark平台上来执行。不过目前只支持集中简单的R公式(包括'.', '~', '+' '-'),社区在接下来的版本中会增强这项功能。

另外越来越多的算法也作为Estimator搬到了ML下面,在1.5版本中新搬过来的有Naive Bayes, K-means, Isotonic Regression等。大家不要以为只是简单的在ML下面提供一个调用相应算法的API,这里面变换还是挺多的。例如Naive Bayes原来的模型分别用Array[Double>Array[Array[Double]]来存储pitheta,而在ML下面新的API里面使用的是VectorMatrix来存储。从这也可以看出,新的ML框架下所有的数据源都是基于DataFrame,所有的模型也尽量都基于Spark的数据类型表示。在ML里面的public API下基本上看不到对RDD的直接操作了,这也与Tungsten项目的设计目标是一致的。

除了这些既有的算法在ML API下的实现,ML里面也增加了几个新算法:

lMultilayerPerceptronClassifier(MLPC) 这是一个基于前馈神经网络的分类器,它是一种在输入层与输出层之间含有一层或多层隐含结点的具有正向传播机制的神经网络模型,中间的节点使用sigmoid (logistic)函数,输出层的节点使用softmax函数。输出层的节点的数目表示分类器有几类。MLPC学习过程中使用BP算法,优化问题抽象成logistic loss function并使用L-BFGS进行优化。

lMLlib包里面增加了一个频繁项挖掘算法PrefixSpanAssociationRules能够把FreqItemset生成关联式规则。

lMLlib的统计包里面实现了KolmogorovSmirnov检验,用以检验两个经验分布是否不同或一个经验分布与另一个理想分布是否不同。

l另外还有一些现有算法的增强:LDA算法,决策树和ensemble算法,GMM算法。

lML里面的多个分类模型现在都支持预测结果的概率而不像过去只支持预测结果,像LogisticRegressionModel, NaiveBayesModel, DecisionTreeClassificationModel, RandomForestClassificationModel, GBTClassificationModel等,分别使用predictRaw, predictProbability, predict分别可以得到原始预测、概率预测和最后的分类预测。同时这些分类模型也支持通过设置thresholds指定各个类的阈值。

lRandomForestClassificationModelRandomForestRegressionModel模型都支持输出feature importance

lGMM EM算法实现了当feature维度或者cluster数目比较大的时候的分布式矩阵求逆计算。实验表明当feature维度>30cluster数目>10的时候,这个优化性能提升明显。

l对于LinearRegressionModelLogisticRegressionModel实现了LinearRegressionTrainingSummaryLogisticRegressionTrainingSummary用来记录模型训练过程中的一些统计指标。

1.5版本的Python API也在不断加强,越来越多的算法和功能的Python API基本上与Scala API对等了。此外在tuningevaluator上也有增强。

其它

From 1.5 beginning, Standalone, YARN and Mesos three deployment all the way to support the dynamic allocation of resources.

SparkR support running YARN on the cluster, while DataFrame function also provides some R style aliases, you can reduce the familiar R migration cost of ownership.


Guess you like

Origin blog.51cto.com/14384035/2406331