neuralnet for more information on the neuralnet library Generate 50 random

Neuralnet for more information on the neuralnet

This preview shows page 2 - 3 out of 3 pages.

#Type ?neuralnet for more information on the neuralnet library #Generate 50 random numbers uniformly distributed between 0 and 100 #And store them as a dataframe traininginput <- as.data.frame(runif(50, min=0, max=100)) trainingoutput <- sqrt(traininginput) #Column bind the data into one variable trainingdata <- cbind(traininginput,trainingoutput) colnames(trainingdata) <- c("Input","Output") #Train the neural network #Going to have 10 hidden layers #Threshold is a numeric value specifying the threshold for the partial #derivatives of the error function as stopping criteria. net.sqrt <- neuralnet(Output~Input,trainingdata, hidden=10, threshold=0.01) print(net.sqrt) #Plot the neural network plot(net.sqrt) #Test the neural network on some training data testdata <- as.data.frame((1:10)^2) #Generate some squared numbers net.results <- compute(net.sqrt, testdata) #Run them through the neural network #Lets see what properties net.sqrt has ls(net.results) #Lets see the results print(net.results$net.result) print(net.results$neurons) #Lets display a better version of the results cleanoutput <- cbind(testdata,sqrt(testdata), as.data.frame(net.results$net.result)) colnames(cleanoutput) <- c("Input","Expected Output","Neural Net Output") print(cleanoutput) #Options Vol setwd("C:/Users/tlonon/Documents/Courses/Spring '19/FE590") #If Needed Opt=read.csv("FOcsv.csv",header=T) train=sample(dim(Opt)[1],dim(Opt)[1]/2,replace=FALSE) trainingdata = Opt[train,] net.vol <- neuralnet(sigma~S0+r+strike+tau+Call+Put,trainingdata, hidden=10,
Image of page 2

Subscribe to view the full document.

Image of page 3
  • Fall '16
  • alec schimdt

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes