In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to implement matrix multiplication operation in Spark. The content of the article is of high quality. Therefore, Xiaobian shares it with you as a reference. I hope you have a certain understanding of relevant knowledge after reading this article.
1,Pom.xml introduces Spark-Mllib library
org.apache.spark spark-mllib_2.11 2.3.1 runtime
We need to pay attention here, because we need to use the relevant API, so here the runtime sentence should be removed, using the default dependency mode on the line
org.apache.spark spark-mllib_2.11 runtime
2, Code
public static void main(String[] args) { SparkConf sparkConf = new SparkConf().setAppName("Mllib-test").setMaster("local"); JavaSparkContext jpc = new JavaSparkContext(sparkConf); double[][] data = new double[4][4] ; data[0][0] = 0.0; data[0][1] = 2.0; data[0][2] = 3.0; data[0][3] = 4.0; data[1][0] = 1.0; data[1][1] = 3.0; data[1][2] = 4.0; data[1][3] = 5.0; data[2][0] = 2.0; data[2][1] = 4.0; data[2][2] = 5.0; data[2][3] = 6.0; data[3][0] = 3.0; data[3][1] = 5.0; data[3][2] = 6.0; data[3][3] = 7.0; JavaRDD rdd=jpc.parallelize(Arrays.asList(data)).map(f->{ long key = new Double(f[0]).longValue(); double[] value = new double[f.length-1]; for(int i = 1;i{ long key = new Double(f[0]).longValue(); double[] value = new double[f.length-1]; for(int i = 1;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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.