网页设计 网站开发 网络安全,怎么用手机制作手机网站,网络舆情监测预警系统,宁波外包seo服务在原有pdf教程教程上#xff0c;做一个补充
idea内搭建环境
导入依赖
就直接利用之前的作业工程项目里直接写#xff0c;所以依赖基本上不用再导入了#xff0c;如果要导入#xff0c;看自己依赖的版本号#xff0c;不要直接复制教程#xff0c;比如我的#xff1a; …在原有pdf教程教程上做一个补充
idea内搭建环境
导入依赖
就直接利用之前的作业工程项目里直接写所以依赖基本上不用再导入了如果要导入看自己依赖的版本号不要直接复制教程比如我的 dependencygroupIdorg.apache.spark/groupIdartifactIdspark-core_2.12/artifactIdversion3.1.1/version/dependencydependencygroupIdorg.apache.spark/groupIdartifactIdspark-sql_2.12/artifactId/dependencydependencygroupIdorg.apache.spark/groupIdartifactIdspark-mllib_2.12/artifactId/dependency
依赖导入失败
因为之前连热点下载依赖可能网太慢下载出现了问题出现了下面的问题
net.sf.opencsv:opencsv:jar:2.3 failed to transfer from https://maven.aliyun.com/repository/public during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of aliyunmaven has elapsed or updates are forced. Original error: Could not transfer artifact net.sf.opencsv:opencsv:jar:2.3 from/to aliyunmaven (https://maven.aliyun.com/repository/public): transfer failed for直接去本地仓库的对应路径把文件删掉然后刷新就可以了
读取数据集
参考https://blog.csdn.net/heiren_a/article/details/122133564 注意上文中提到第一行是列名和需要自动推断数据类型的情况 如 val training spark.read.option(header, true) // 假设文件没有表头.option(inferSchema, true) // 自动推断列的数据类型.csv(dataPath).toDF(timestamp, back_x, back_y, back_z, thigh_x, thigh_y, thigh_z, label)注意后面组合特征向量的时候不要把label列放进去了
将时间戳转换为数值型
参考 https://blog.csdn.net/bowenlaw/article/details/111644932 // 将时间戳转换为数值型val trainWithTimestamp training.withColumn(timestamp_numeric, to_timestamp(col(timestamp)))val dataWithNumericFeatures trainWithTimestamp.withColumn(timestamp_numeric, col(timestamp_numeric).cast(double))模型使用逻辑回归和决策树
https://blog.csdn.net/qq_44665283/article/details/131766504
spark模型评估和选择准确率F1-Score
直接调接口https://blog.csdn.net/weixin_43871785/article/details/132334104 https://blog.csdn.net/yeshang_lady/article/details/127856065
在单个节点上运行多个worker
编辑配置文件 进入Spark的conf目录复制spark-env.sh.template文件并重命名为spark-env.sh。 编辑spark-env.sh文件添加以下配置根据需要调整
export SPARK_WORKER_INSTANCES1 # 在单机上模拟的Worker数量可以设置为多个但需要不同端口
export SPARK_WORKER_CORES1 # 每个Worker的CPU核心数参考https://www.cnblogs.com/xinfang520/p/8038306.html
Spark运行的中间结果查看spark web ui
注意要在运行时进4040端口参考 https://www.cnblogs.com/bigdata1024/p/12194298.html
题目附录
数据集说明
时间戳记录样本的日期和时间使用的时候最好将其转换为数值型back_x 单位时间中背部传感器在 x 方向下的加速度back_y 单位时间中背部传感器在 y 方向左的加速度back_z 单位时间中背部传感器在z 方向向前的加速度thigh_x 单位时间中大腿传感器在 x 方向下的加速度thigh_y 单位时间中大腿传感器在 y 方向右的加速度thigh_z 单位时间中大腿传感器在 z 方向向后的加速度label带注释的活动代码 1步行 2运行 3洗牌 4楼梯上升 5楼梯下降 6站立 7坐着 8撒谎 13 自行车 坐着 14 自行车 站着