Project 4 Use the posted simulation and perform the following tasks. 1. For specific value of K, change the percentage of the data that you use for training and plot accuracy vs. training size...

1 answer below »
Attach File


Project 4 Use the posted simulation and perform the following tasks. 1. For specific value of K, change the percentage of the data that you use for training and plot accuracy vs. training size (percentage). Start with 10% and use the increments of 10%, up to 90%. Run the simulation 100 times for each training size (percentage) and calculate the Monte Carlo average performance and standard error and plot them vs. training percentage in the same panel. Repeat this for different values of K. Start with K =1, and repeat for 3, 5, 7, 9, 15, and 25. 2. For 25% training percentage, change the value of K and plot accuracy vs. K. Start with K =1, and repeat for 3, 5, 7, 9, 15, and 25. Run the simulation 100 times for each K and calculate the Monte Carlo average performance and standard error and plot them vs. K in the same panel. Presentation: Mon, Nov 15 Report Deadline: Sat, Nov 13.
Answered 1 days AfterNov 15, 2021

Answer To: Project 4 Use the posted simulation and perform the following tasks. 1. For specific value of K,...

Kamalika answered on Nov 16 2021
126 Votes
monte carlo simulation
monte carlo simulation
REPORT
Introduction
Monte Carlo simulations are used to model the probability of different outcomes in a process that cannot easily be predicted due to the intervention of random variables. It is a technique used to und
erstand the impact of risk and uncertainty in prediction and forecasting models. The basis of a Monte Carlo simulation is that the probability of varying outcomes cannot be determined because of random variable interference. Therefore, a Monte Carlo simulation focuses on constantly repeating random samples to achieve certain results. A Monte Carlo simulation takes the variable that has uncertainty and assigns it a random value. The model is then run and a result is provided. This process is repeated again and again while assigning the variable in question with many different values. Once the simulation is complete, the results are averaged together to provide an estimate. In the present context, R Studio is used to do the simulation. For this purpose, the dataset ‘iris’ is being considered. The report has explored the percentage change in dataset for some specific values and compared the accuracy of the training size across these specific values. In the next section, we will present the programming codes for the questions asked and its resultant output.
Analysis and Final Outcome
The whole analysis is divided into two parts.
Part 1:
In this part, we have taken the values of K = 1, 3, 5, 7, 9, 15, 25. Our objective is that for these specific values of K, how any change in percentage of data used for training purpose can impact the plot between accuracy vs. training size. We will run the simulation for 100 times and start with 10% data and increase the percentage by 10% till we reach 90%.
##load data
data("iris")
##store it as data frame
iris <- data.frame(iris)
##create a random number equal 10% of total number of rows
ran <- sample(1:nrow(iris),0.1 * nrow(iris))
##the normalization function is created
nor <-function(x) { (x -min(x))/(max(x)-min(x)) }
##normalization function is created
iris_nor <- as.data.frame(lapply(iris[,c(1,2,3,4)], nor))
##training dataset extracted
iris_train <- iris_nor[ran,]
##test dataset extracted
iris_test <- iris_nor[-ran,]
##the 2nd column of training dataset because that is what we need to predict about testing dataset
##also convert ordered factor to normal factor
iris_target <- as.factor(iris[ran,5])
##the actual values of 2nd couln of testing dataset to compare it with values that will be predicted
##also convert ordered factor to normal factor
test_target <- as.factor(iris[-ran,5])
##run knn function
library(class)
pr <-...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here