09.10.2023 Views

Advanced Data Analytics Using Python_ With Machine Learning, Deep Learning and NLP Examples ( 2023)

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6

Time Series

model provides the upper limit and the lower limit of the prediction in

forecasting.

asm_weekwise<-read.csv("F:/souravda/New ASM Weekwise.

csv",header=TRUE)

asm_weekwise$Week <- NULL

library(MASS, lib.loc="F:/souravda/lib/")

library(tseries, lib.loc="F:/souravda/lib/")

library(forecast, lib.loc="F:/souravda/lib/")

asm_weekwise[is.na(asm_weekwise)] <- 0

asm_weekwise[asm_weekwise <= 0] <- mean(as.matrix(asm_weekwise))

weekjoyforecastvalues <- data.frame( "asm" = integer(), "value"

= integer(), stringsAsFactors=FALSE)

for(i in 2:ncol(asm_weekwise))

{

asmname<-names(asm_weekwise)[i]

temparimadata<-asm_weekwise[,i]

m <- mean(as.matrix(temparimadata))

#print(m)

s <- sd(temparimadata)

#print(s)

temparimadata <- (temparimadata - m)

temparimadata <- (temparimadata / s)

temparima<-auto.arima(temparimadata, stationary = FALSE,

seasonal = TRUE, allowdrift = TRUE, allowmean = FALSE, biasadj

= FALSE)

tempforecast<-forecast(temparima,h=12)

#tempforecast <- (tempforecast * s)

#print(tempforecast)

142

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!