Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Gaussian mixture clustering in spark mlilib

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the example analysis of Gaussian mixture clustering in spark mlilib, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.

The running code is as follows: package spark.clusteringimport org.apache.spark.mllib.clustering. {GaussianMixture, KMeans} import org.apache.spark.mllib.linalg.Vectorsimport org.apache.spark. {SparkConf, SparkContext} / * * Gaussian mixture clustering * Gaussian distribution: when a data vector is within the model calculation of a Gaussian distribution, it is considered to match the Gaussian distribution. Clustering belonging to this model. * mixed Gaussian distribution: the clustering of any sample can be represented by multiple single Gaussian distribution models. * * Created by eric on 16-7-21. * / object GMG {val conf = new SparkConf () / / create the environment variable .setMaster ("local") / / set the localization handler .setAppName ("gaussian") / / set the name val sc = new SparkContext (conf) Def main (args: Array [String]) {val data = sc.textFile (". / src/main/spark/clustering/gmg.txt") val parsedData = data.map (s = > Vectors.dense (s.trim (). Split ('). Map (_ .toDouble)) .cache () val model = new GaussianMixture (). SetK (2) .run (parsedData) / / sets the number of classifications for the training model for (I)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report