简体   繁体   English

Output 预测 Model 从执行 R 脚本模块中 Z3A580F14203676F53F0

[英]Output Prediction Model from Execute R Script Module in Azure ML

I'm doing an experiment to predict energy demand using 3 types of machine learning method which is ANN-MLP, SVM RBF and k-NN.我正在做一个实验来预测能源需求,使用 3 种机器学习方法,即 ANN-MLP、SVM RBF 和 k-NN。 I'm utilizing the Execute R Script module to run the R code.我正在使用执行 R 脚本模块来运行 R 代码。 My questions is how to output the executed model, so that the model can be used to predict in another dataset.我的问题是如何 output 执行 model,以便 model 可用于预测另一个数据集。 Basically I have 2 datasets - June dataset and July dataset.基本上我有 2 个数据集 - 六月数据集和七月数据集。 The prediction model is created using June data set, and I wanted to test July dataset using the model.预测 model 是使用六月数据集创建的,我想使用 model 测试七月数据集。

predictor <- maml.mapInputPort(1) 
datafull <- maml.mapInputPort(2) 

library(caret)

#data splitting
datasplit <- createDataPartition(y = predictor$demand, p = 0.7, list = FALSE)
datatrain <- predictor[datasplit,] 
datatest <- predictor[-datasplit,] 

#repeated cv, 10 cross validation
ctrl <- trainControl(method="repeatedcv", repeats =5)
knnFit <- train(demand ~ ., data = datatrain, method = "knn", trControl = ctrl, preProcess = c("center", "scale"), tuneLength = 20)
knnFit
plot(knnFit)

#Prediction
datapredict <- predict(knnFit, predictor)

plot(datafull$cdate, datafull$demand, xlab = "Time", ylab = "Demand", col = "#0441d9")
lines(datafull$cdate, datafull$demand, xlab = "Time", ylab = "Demand", col = "#0441d9")
lines(datafull$cdate, datapredict, xlab = "Time", ylab = "Demand", col = "#cc0000")

Right now the code only output the original dataset with a new column consist of the predicted value.现在代码只有 output 带有新列的原始数据集包含预测值。

datafull$data.predict <- datapredict 
str(datafull)

# Select data.frame to be sent to the output Dataset port
maml.mapOutputPort('datafull');

You can convert you experiment to a predictive experiment.您可以将实验转换为预测性实验。 Then the model is saved and you can use predictive experiement to have any data evaluated you want.然后 model 被保存,您可以使用预测实验来评估您想要的任何数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM