This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plot(data, col="blue", xlab="Year", ylab="Passengers", main="Seasonal Naive Forecast", type='l') | |
| lines(naive$mean, col="red", lwd=2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ets_forecast = forecast(ets_model, h=length(validation)) | |
| MAPE(ets_forecast$mean, validation) *100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tbats_model = tbats(training) | |
| tbats_forecast = forecast(tbats_model, h=length(validation)) | |
| MAPE(tbats_forecast$mean, validation) * 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| naive = snaive(training, h=length(validation)) | |
| MAPE(naive$mean, validation) * 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(forecast) | |
| library(MLmetrics) | |
| data=AirPassengers | |
| #Create samples | |
| training=window(data, start = c(1949,1), end = c(1955,12)) | |
| validation=window(data, start = c(1956,1)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Plotting IQ on x-axis and result on y-axis | |
| plot(IQ, result, xlab = "IQ Level", | |
| ylab = "Probability of Passing") | |
| # Create a logistic model | |
| g = glm(result~IQ, family=binomial, df) | |
| # Create a curve based on prediction using the regression model | |
| curve(predict(g, data.frame(IQ=x), type="resp"), add=TRUE) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Generate vector with pass and fail values of 40 students | |
| result <- c(0, 0, 0, 1, 0, 0, 0, 0, 0, 1, | |
| 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, | |
| 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, | |
| 1, 1, 1, 0, 1, 1, 1, 1, 0, 1) | |
| # Data Frame | |
| df <- as.data.frame(cbind(IQ, result)) | |
| # Print data frame |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Generate random IQ values with mean = 30 and sd =2 | |
| IQ <- rnorm(40, 30, 2) | |
| # Sorting IQ level in ascending order | |
| IQ <- sort(IQ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ggplot(data=iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point(aes(color=Species, shape=Species)) + | |
| xlab("Sepal Length") + ylab("Sepal Width") + | |
| ggtitle("Sepal Length-Width") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ggplot(data=iris, aes(x=Species, y=Sepal.Length)) + | |
| geom_boxplot(aes(fill=Species)) + | |
| ylab("Sepal Length") + ggtitle("Iris Boxplot") |
NewerOlder