文章目录
0 前言
今天学长给各位同学分享一个机器学习大数据分析项目,可以用作毕业设计哦~🧿 选题指导, 项目分享:见文末
1 数据集介绍
df = pd.read_csv('/home/kesci/input/jena1246/jena_climate_2009_2016.csv')
df.head()
如上所示,每10分钟记录一次观测值,一个小时内有6个观测值,一天有144(6x24)个观测值。
给定一个特定的时间,假设要预测未来6小时的温度。为了做出此预测,选择使用5天的观察时间。因此,创建一个包含最后720(5x144)个观测值的窗口以训练模型。
下面的函数返回上述时间窗以供模型训练。参数 history_size 是过去信息的滑动窗口大小。target_size 是模型需要学习预测的未来时间步,也作为需要被预测的标签。
下面使用数据的前300,000行当做训练数据集,其余的作为验证数据集。总计约2100天的训练数据。
def univariate_data(dataset, start_index, end_index, history_size, target_size):
data = []
labels = []
start_index = start_index + history_size
if end_index is None:
end_index = len(dataset) - target_size
for i in range(start_index, end_index):
indices = range(i-history_size, i)
# Reshape data from (history`1_size,) to (history_size, 1)
data.append(np.reshape(dataset[indices], (history_size, 1)))
labels.append(dataset[i+target_size])
return np.array(data), np.array(labels)
2 开始分析
2.1 单变量分析
首先,使用一个特征(温度)训练模型,并在使用该模型做预测。
2.1.1 温度变量
从数据集中提取温度
uni_data = df['T (degC)']
uni_data.index = df['Date Time'</