Giter Club home page Giter Club logo

randomforestfml's Introduction

randomForestFML

This is based on the randomForest package 4.6-14 from the following website: https://cran.r-project.org/web/packages/randomForest/

I couldn't find the repo for the most current version of randomForest, so I had to gracely steal the codes from the above link.

The option of using sequential bootstrap (see: Advances in Financial Machine Learning, Marcos Lopez de Prado, 2018), instead of the ordinary bootstrap for random forests / bagging has been added.

Currently, sequential bootstrap relies on an index vector (SB) that is generated by some R codes (see below), but could be very time consuming; C codes should be able to dramatically increase the speed of generating SB.

How to install

devtools::install_github("larryleihua/randomForestFML")

How to use

library(randomForestFML)
ntree <- 10 # use a small number for experiment, about 13 sec for 1 tree
seedvec <- seq(1,ntree)
data(trainSet)
indMat <- getIndMat(trainSet$tFea, trainSet$tLabel)
iRun <- function(i)
{
  set.seed(seedvec[i])
  return(seqBoot(indMat))
}
iRun <- Vectorize(iRun, "i")

# check how much for 1 tree on your computer
sm <- Sys.time(); iRun(1); Sys.time() - sm

library(parallel)
cc <- makeCluster(detectCores()-1)
clusterExport(cc, c("indMat", "seedvec", "seqBoot"))
i_sB <- tryCatch(parLapply(cc, 1:ntree, iRun), error=function(e) NA, warning=function(w) NA)
clusterEvalQ(cc, {gc()})
stopCluster(cc)
    
sBmat <- NULL
for(i in 1:ntree)  sBmat <- cbind(sBmat, i_sB[[i]])
SB <- as.vector(as.matrix(sBmat)) 
bag <- randomForestFML(Y ~ C+V, data = trainSet, mtry = 2, importance = TRUE, ntree = ntree, SB=SB)

To do

Implement a function for generating SB for the C functions (rf.c and regrf.c in src/)

randomforestfml's People

Contributors

larryleihua avatar

Stargazers

NCraft avatar  avatar  avatar nicole cui avatar

Watchers

James Cloos avatar  avatar  avatar

randomforestfml's Issues

unable to install on mac os version 10.13.3

error message when trying to run (devtools::install_github("larryleihua/randomForestFML")):

ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [randomForestFML.so] Error 1
ERROR: compilation failed for package ‘randomForestFML’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/randomForestFML’
Error in i.p(...) : 
  (converted from warning) installation of package ‘/var/folders/8d/n163vg3d2zx7_650xhwwpvv00000gn/T//RtmpRXusT2/file656342e9efd7/randomForestFML_4.6-14.tar.gz’ had non-zero exit status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.