资源简介
spark 机器学习 第二版 含源码 高清版本
代码片段和文件信息
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import scala.Tuple2;
import java.util.*;
import java.util.stream.Collectors;
/**
* A simple Spark app in Java (Wordcount example)
*/
public class JavaApp {
public static void main(String[] args) {
JavaSparkContext sc = null;
try {
// ####### create spark context by starting the cluster locally using 2 CPU cores #######
sc = new JavaSparkContext(“local[2]“ “First Spark App“);
JavaRDD data = sc.textFile(“data/UserPurchaseHistory.csv“).map(s -> s.split(““));
// ####### let‘s count the number of purchases #######
long numPurchases = data.count();
System.out.println(“NumberPurchases : “ + numPurchases);
long uniqueUsers = data.map(strings -> strings[0]).distinct().count();
// ####### let‘s count the number of users #######
System.out.println(“Unique users : “ + uniqueUsers);
Double totalRevenue = data.map(strings -> Double.parseDouble(strings[2])).reduce((Double v1 Double v2) -> new Double(v1.doubleValue() + v2.doubleValue()));
// ####### let‘s count the total revenue #######
System.out.println(“Total revenue : “ + totalRevenue);
List> pairs = data.mapToPair(strings -> new Tuple2(strings[1] 1)).reduceByKey((Integer i1 Integer i2) -> i1 + i2).collect();
Map sortedData = new HashMap<>();
Iterator it = pairs.iterator();
while (it.hasNext()) {
Tuple2 o = (Tuple2) it.next();
sortedData.put(o._1() o._2());
}
List sorted = sortedData.entrySet()
.stream()
.sorted(Comparator.comparing((Map.Entry entry) -> entry.getValue()).reversed())
.map(Map.Entry::getKey)
.collect(Collectors.toList());
System.out.println(“Most popular products sorted : “ + sorted);
String mostPopular = sorted.get(0);
int purchases = sortedData.get(mostPopular);
System.out.println(“Most popular product is : “ + mostPopular + “ with number of purchases : “ + purchases);
} catch (Exception e) {
e.printStackTrace();
} finally {
sc.stop();
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 29494 2016-11-14 11:18 Graphic 图\B05184_08_01.png
文件 29503 2016-11-13 06:47 Graphic 图\B05184_08_02.png
文件 29517 2016-11-14 11:18 Graphic 图\B05184_08_03.png
文件 29519 2016-11-13 06:48 Graphic 图\B05184_08_04.png
文件 29475 2016-11-14 11:18 Graphic 图\B05184_08_05.png
文件 19647 2016-11-14 11:18 Graphic 图\B05184_08_06.png
....... 378 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\.gitattributes
....... 649 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\.gitignore
....... 251 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter01\java-spark-app\data\UserPurchaseHistory.csv
....... 1060 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter01\java-spark-app\pom.xm
....... 2513 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter01\java-spark-app\src\main\java\JavaApp.java
....... 117 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter01\python-spark-app\data\UserPurchaseHistory.csv
....... 1405 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter01\python-spark-app\pythonapp.py
....... 117 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter01\r-spark-app\data\UserPurchaseHistory.csv
....... 1767 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter01\r-spark-app\r-sc
....... 537 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter01\README
....... 5120 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter01\scala-shell-code_01.scala
....... 144 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter01\scala-spark-app\build.sbt
....... 117 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter01\scala-spark-app\data\UserPurchaseHistory.csv
....... 1426 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter01\scala-spark-app\src\main\scala\ScalaApp.scala
....... 1093 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter02\breeze\build.sbt
....... 882 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter02\breeze\src\main\scala\linalg\fields\ComplexNumber.scala
....... 285 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter02\breeze\src\main\scala\linalg\fields\GaloisField.scala
....... 579 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter02\breeze\src\main\scala\linalg\fields\GF2.scala
....... 501 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter02\breeze\src\main\scala\linalg\matrix\BreezeMatrix.scala
....... 909 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter02\breeze\src\main\scala\linalg\matrix\BreezeMatrixOperations.scala
....... 1607 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter02\breeze\src\main\scala\linalg\operations\common.scala
....... 362 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter02\breeze\src\main\scala\linalg\plot\BreezePlotGaussian.scala
....... 413 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter02\breeze\src\main\scala\linalg\plot\BreezePlotLine.scala
....... 633 2017-04-28 19:15 Machine-Learning-with-Spark-Second-Edition-master 源码\Chapter02\breeze\src\main\scala\linalg\sgd\BreezeSGDVector.scala
............此处省略1092个文件信息
相关资源
- linux2.6.11.12内核源码注释
- Spring MVC 学习指南(第2版高清中文
- 20套项目源码.zip
- 算法导论(原书第3版) 中文完整版
- 完整无碳小车全套资料参考文献、图
- 管线成图系统V3.0_CAD2008.zip
- AD常用库原理图+PCB非常全1.zip
- 微信大屏幕互动源码
- 《程序员代码面试指南》(高清PDF版
- 数字图像处理冈萨雷斯第三版 英文原
- 图解密码技术完整版本pdf
- 竹林蹊径:深入浅出Windows驱动开发(
- 51个自己收集的小程序案例源码
- 《Xilinx ZYNQ-7000 AP SoC开发实战指南》符
- 150个微信小程序源码,前端技能练习
- EXCEL图表拒绝平庸-全彩
- 基于labview图像处理、分析与机器视觉
- GPU精粹1-中文版.pdf《GPU精粹:实时图形
- 计算机图形学 基于3D图形开发技术
- jmeter3.1官方源码
- 机器学习实战 高清完整版PDF
- 灵动软件图书租赁系统.zip
- 程序员表白程序 源码开放性 第一辑
- 多尺度hessian滤波器图像增强
- EasyJF开源网上会议系统源码整理.
- VC 图像几何变换、图像平移、垂直水
- Steam快捷一键登录源码
- 中国各省地市级行政区域地图(shp格
- 仿QQ截图工具源代码
- 串口调试助手 Qt5版源码
评论
共有 条评论