物联网机器学习应用实战
一、物联网数据处理基础
在处理物联网数据时,我们通常需要将数据接入并进行结构化处理,以便后续进行分析和机器学习。以下是具体的操作步骤:
1. 配置事件中心参数
endingEventPosition = {
"offset": None,
"seqNo": -1,
"enqueuedTime": endTime,
"isInclusive": True
}
ehConf["eventhubs.recieverTimeout"] = 100
- 将数据加载到Spark DataFrame
df = spark \
.readStream \
.format("eventhubs") \
.options(**ehConf) \
.load()
- 定义数据结构
from pyspark.sql.types import *
Schema = StructType([StructField("deviceEndSessionTime", StringType()),
StructField("sensor1", StringType(