Skip to content

Commit

Permalink
removed last dynamic memory call, modified .Rbuildignore to ignore th…
Browse files Browse the repository at this point in the history
…e new top level directory, 'docs'
  • Loading branch information
jbrowne6 committed Jul 28, 2018
1 parent 248e10c commit 73b896f
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 6 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
^travisTest$
^docs$
^\.travis\.yml$
^.*\\.gz$
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rerf
Type: Package
Title: Randomer Forest
Version: 1.1.2
Version: 1.1.3
Date: 2018-07-05
Authors@R: c(person("James", "Browne", role = c("aut", "cre"),
email = "jbrowne6@jhu.edu"),
Expand Down
Empty file modified docs/subsampling/bootstrap_subsample.Rmd
100644 → 100755
Empty file.
Empty file modified docs/subsampling/bootstrap_subsample.html
100644 → 100755
Empty file.
Empty file modified docs/subsampling/figure.pdf
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions man/RerF.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/forestPacking.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <RcppArmadillo.h>
#include <improv8.h>
#include <vector>
// [[Rcpp::depends(RcppArmadillo)]]

using namespace Rcpp;
Expand All @@ -21,7 +22,7 @@ Rcpp::NumericVector predictRF(const NumericMatrix mat, const int numCores){
int numObservations = mat.nrow();
int numFeatures = mat.ncol();

double *currObs = new double[numFeatures];
std::vector<double> currObs(numFeatures);
Rcpp::NumericVector predictions(numObservations);

const std::string packedFileName = "forest.out";
Expand All @@ -30,10 +31,8 @@ Rcpp::NumericVector predictRF(const NumericMatrix mat, const int numCores){
for(int j = 0; j < numFeatures; j++){
currObs[j] = mat(i,j);
}
//predictions[i] = tester.makePrediction(currObs,numCores)+1;
predictions[i] = tester.makePrediction(currObs)+1;
}
delete currObs;
return predictions;
}

Expand Down
35 changes: 35 additions & 0 deletions src/forestPacking/improv8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,41 @@ void improv8::makePrediction(double* observation, double* preds, int numFeatures
}


int improv8::makePrediction(std::vector<double>& observation){

std::vector<int> predictions(numOfClasses);
std::vector<int> currentNode(forestRoots[0].numOfTreesInBin);
int numberNotInLeaf;
int k, q;

for( k=0; k < numOfBins;k++){

for( q=0; q<forestRoots[k].numOfTreesInBin; q++){
currentNode[q] = q;
__builtin_prefetch(&forestRoots[k].bin[currentNode[q]], 0, 3);
}

do{
numberNotInLeaf = forestRoots[k].numOfTreesInBin;

for( q=0; q<forestRoots[k].numOfTreesInBin; q++){

if(forestRoots[k].bin[currentNode[q]].isInternalNode()){
currentNode[q] = forestRoots[k].bin[currentNode[q]].nextNode(observation[forestRoots[k].bin[currentNode[q]].returnFeature()]);
__builtin_prefetch(&forestRoots[k].bin[currentNode[q]], 0, 3);
continue;
}
--numberNotInLeaf;
}
}while(numberNotInLeaf > 0);

for( q=0; q<forestRoots[k].numOfTreesInBin; q++){
++predictions[forestRoots[k].bin[currentNode[q]].returnRightNode()];
}
}
return returnClassPrediction(predictions, numOfClasses);
}

int improv8::makePrediction(double*& observation){

std::vector<int> predictions(numOfClasses);
Expand Down
1 change: 1 addition & 0 deletions src/forestPacking/improv8.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class improv8: public padForest
void makePredictions(const inferenceSamples& observations);
void makePrediction(double* observation, double* preds, int numFeatures, int numObservations, int numCores);
int makePrediction(double*& observation);
int makePrediction(std::vector<double>& observation);
int makePrediction(double*& observation, int numCore);
void writeForest(const std::string& forestFileName);
void changeNumBins(int newBinNum){
Expand Down

0 comments on commit 73b896f

Please sign in to comment.