我是R.的新手。我正在使用Azure Machine Learning Studio来尝试预测何时可以根据历史兑换兑换优惠券或优惠(营销推广)。这是我的数据。
这是我的R脚本。
#ARIMA Seasonal / ARIMA non-seasonal
install.packages("forecast")
library(forecast)
# Map 1-based optional input ports to variables
dataset1 <- maml.mapInputPort(1) # class: data.frame
dataset2 <- maml.mapInputPort(2) # class: data.frame
######dataset1$RedeemedOn <- as.POSIXlt(dataset1$RedeemedOn, format="%m/%d/%Y %I:%M:%S %p")
######dataset2$RedeemedOn <- as.POSIXlt(dataset2$RedeemedOn, format="%m/%d/%Y %I:%M:%S %p")
dataset1$RedeemedOn <- as.Date(dataset1$RedeemedOn, # Character vector to convert
format= "%y/%m/%d")
dataset2$RedeemedOn <- as.Date(dataset2$RedeemedOn, # Character vector to convert
format= "%y/%m/%d")
#Enter the seasonality of the timeseries here
#For non-seasonal model use '1' as the seasonality
seasonality<-12
labels <- as.numeric(dataset1$OfferId)
timeseries <- ts(labels,frequency=seasonality)
model <- auto.arima(timeseries)
numPeriodsToForecast <- ceiling(max(dataset2$RedeemedOn)) - ceiling(max(dataset1$RedeemedOn))
#numPeriodsToForecast <- ceiling(max(dataset2$hour)) - ceiling(max(dataset1$hour))
numPeriodsToForecast <- max(numPeriodsToForecast, 0)
forecastedData <- forecast(model, h=numPeriodsToForecast)
forecastedData <- as.numeric(forecastedData$mean)
output <- data.frame(RedeemedOn=dataset2$RedeemedOn,forecast=forecastedData)
data.set <- output
# Select data.frame to be sent to the output Dataset port
maml.mapOutputPort("data.set");
这是错误。
错误0063:在评估R脚本期间发生以下错误: ----------从R开始的错误消息---------- 0(非NA)案件
我是否正确地做到了这一点?这是否会根据之前的RedeemedOn日期和时间预测未来的优惠/优惠券兑换?
编辑1
#ARIMA Seasonal / ARIMA non-seasonal
install.packages("forecast")
library(forecast)
# Map 1-based optional input ports to variables
dataset1 <- maml.mapInputPort(1) # class: data.frame
dataset2 <- maml.mapInputPort(2) # class: data.frame
dataset1$RedeemedOn <- as.POSIXct(dataset1$RedeemedOn, format="%d/%m/%Y")
dataset2$RedeemedOn <- as.POSIXct(dataset2$RedeemedOn, format="%d/%m/%Y")
#dataset1$RedeemedOn <- as.POSIXct(dataset1$RedeemedOn, format="%d/%m/%Y %I:%M:%S %p")
#dataset2$RedeemedOn <- as.POSIXct(dataset2$RedeemedOn, format="%d/%m/%Y %I:%M:%S %p")
#####dataset1$RedeemedOn <- as.Date(dataset1$RedeemedOn, # Character vector to convert
#####format= "%y/%m/%d")
#####dataset2$RedeemedOn <- as.Date(dataset2$RedeemedOn, # Character vector to convert
#####format= "%y/%m/%d")
#Enter the seasonality of the timeseries here
#For non-seasonal model use '1' as the seasonality
seasonality<-12
labels <- as.numeric(dataset1$OfferId)
timeseries <- ts(labels,frequency=seasonality)
model <- auto.arima(timeseries)
numPeriodsToForecast <- ceiling(max(dataset2$RedeemedOn)) - ceiling(max(dataset1$RedeemedOn))
#numPeriodsToForecast <- ceiling(max(dataset2$hour)) - ceiling(max(dataset1$hour))
numPeriodsToForecast <- max(numPeriodsToForecast, 0)
forecastedData <- forecast(model, h=numPeriodsToForecast)
forecastedData <- as.numeric(forecastedData$mean)
#output <- data.frame(RedeemedOn=dataset2$RedeemedOn,forecast=forecastedData)
output <- data.frame(date=format(dataset2$RedeemedOn, "%d/%m/%y"),forecast=forecastedData)
data.set <- output
# Select data.frame to be sent to the output Dataset port
maml.mapOutputPort("data.set");
非常感谢任何帮助。谢谢!