Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] An implementation of discontiguous sampling of the SRerf variant; we call it MTORF(?) #353

Open
wants to merge 47 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
dd381ae
Implemented multivariate time series projection. TODO: Check random n…
ChesterHuynh Mar 18, 2020
1abf75c
Revert "Implemented multivariate time series projection. TODO: Check …
ChesterHuynh Mar 18, 2020
5896228
Implemented multivariate time series projection. TODO: Check random s…
ChesterHuynh Mar 18, 2020
e99fcc3
Adding mtorf demo.
adam2392 Mar 20, 2020
5335e6a
Adding demo of mtorf.
adam2392 Mar 20, 2020
2cb4a96
Adding updatees to mtorf.
adam2392 Mar 20, 2020
2c1990d
Adding mtorf.
adam2392 Mar 20, 2020
d1edc00
Adding simulation for mtorf as a function of covariance factor.
adam2392 Mar 20, 2020
c638142
Adding deescription to the notebook.
adam2392 Mar 20, 2020
bfe4082
Ran a few more experiments.
adam2392 Mar 21, 2020
8bc0ee0
Adding MT-MORF.
adam2392 Mar 21, 2020
e80f0db
Adding kuramoto model.
adam2392 Mar 23, 2020
36cccfc
Fixing the demo to include more info.
adam2392 Mar 24, 2020
ff9ab77
Adding deepESN model
ChesterHuynh Mar 26, 2020
9085695
Removing .DS_Store
ChesterHuynh Mar 26, 2020
d60c905
Adding MVAR(1) experiments
ChesterHuynh Apr 2, 2020
22c3373
Adding updated mts morf autoregressive exploration.
adam2392 Apr 5, 2020
4d8d60c
Run ar experiment.
adam2392 Apr 6, 2020
cedd168
Adding experiment output.
adam2392 Apr 6, 2020
e23ed7a
Adding experiment output.
adam2392 Apr 6, 2020
d94179c
Adding updated experimeents.
adam2392 Apr 6, 2020
9eabe54
added experiments with substituting white noise channels with 6x6 A m…
ChesterHuynh Apr 8, 2020
cddc8ce
Adding bids conversion and io to read in epochs for decision making.
adam2392 Apr 8, 2020
b525ef0
Adding updated simulation experiment.
adam2392 Apr 8, 2020
f590f26
Adding refactored reading funcs.
adam2392 Apr 8, 2020
7a78e13
Changing demo to use discrete linear time system.
adam2392 Apr 10, 2020
6acd870
Adding temporarily bette rexperimeint.'
adam2392 Apr 10, 2020
538041f
Adding updated example to load in data.
adam2392 Apr 10, 2020
c022cef
Merge branch 'dev/mtorf' of https://github.com/adam2392/SPORF into de…
adam2392 Apr 10, 2020
7295eaf
Running experiment and demoing loading of data.
adam2392 Apr 15, 2020
3ee5dbd
Running experiment and demoing loading of data.
adam2392 Apr 15, 2020
a6afafc
Here's the interesting sim.
adam2392 Apr 15, 2020
ec954b8
adding high-low card experiment and refactor simulation notebook
ChesterHuynh Apr 26, 2020
2ce56ee
Code to run high-low card experiment on efri06. Added notebook with s…
ChesterHuynh May 15, 2020
8b225eb
fixed seeding for shuffling row indices in mtsmorf, changing high_low…
ChesterHuynh May 18, 2020
19d0ea9
Adding read and utils for cv experiment.
adam2392 May 18, 2020
fcc829b
Merge branch 'dev/mtorf' of https://github.com/adam2392/SPORF into de…
adam2392 May 18, 2020
b4d5681
Adding read and utils for cv experiment.
adam2392 May 18, 2020
a989056
Moving label binarizer.
adam2392 May 18, 2020
fdc660d
Adding updated notebook to run through analyses.
adam2392 May 27, 2020
490e7e2
Removing data files.
adam2392 May 27, 2020
d0b1a96
Syncing to run MOVE multiclass experiment with feature importance.
ChesterHuynh Oct 19, 2020
a0ac907
Adding MOVE experiment scripts
ChesterHuynh Oct 19, 2020
cfb59ce
Adding code changes to install venv.
adam2392 Oct 20, 2020
51c0f1f
Adding updated exp.
adam2392 Oct 20, 2020
e08bf1a
Fixing plot issues.
adam2392 Oct 22, 2020
fcfabaa
Deleting all experiment files and putting into separate repository.:
adam2392 Dec 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .idea/.gitignore

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

18 changes: 18 additions & 0 deletions .idea/SPORF.iml

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

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

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

4 changes: 4 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

4 changes: 4 additions & 0 deletions .idea/rSettings.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

9 changes: 7 additions & 2 deletions Python/rerf/rerfClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def fit(self, X, y):
else:
forestType = "binnedBaseTern"
self.method_to_use_ = 1
elif self.projection_matrix == "S-RerF":
elif self.projection_matrix in ["S-RerF", "MT-MORF"]:
if self.oob_score:
warn(
"OOB is not currently implemented for the S-RerF"
Expand All @@ -241,7 +241,12 @@ def fit(self, X, y):
self.oob_score = False

forestType = "binnedBaseTern" # this should change
self.method_to_use_ = 2

if self.projection_matrix == 'S-RerF':
self.method_to_use_ = 2
elif self.projection_matrix == 'MT-MORF':
self.method_to_use_ = 3

# Check that image_height and image_width are divisors of
# the num_features. This is the most we can do to
# prevent an invalid value being passed in.
Expand Down
Empty file modified Python/tests/__init__.py
100644 → 100755
Empty file.
5 changes: 3 additions & 2 deletions packedForest/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#Compiler and Linker
#CC := g++-mp-4.7
CC := g++ -std=c++11
#CC := g++-6 -std=c++11
# CC := gcc-9 -std=c++11 -c
# CC := g++-6 -std=c++11

#The Target Binary Program
TARGET := fp
Expand All @@ -21,7 +22,7 @@ OBJEXT := o
CFLAGS := -fopenmp -Wall -O3 -DNDEBUG -ffast-math
CFLAGS := -fopenmp -Wall -O3 -ffast-math
#LIB := -fopenmp -lm -lnuma
LIB := -fopenmp -lm -O3
LIB := -fopenmp -lm -O3
INC := -I$(INCDIR) -I/usr/local/include -I/usr/local/include/eigen3
INCDEP := -I$(INCDIR)

Expand Down
83 changes: 82 additions & 1 deletion packedForest/src/forestTypes/binnedTree/processingNodeBin.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace fp{
inline void calcMtryForNode(std::vector<weightedFeature>& featuresToTry){
featuresToTry.resize(fpSingleton::getSingleton().returnMtry());
int methodToUse = fpSingleton::getSingleton().returnMethodToUse();
assert(methodToUse == 1 || methodToUse == 2);
assert(methodToUse == 1 || methodToUse == 2 || methodToUse == 3 || methodToUse == 4);

switch(methodToUse){
case 1:{
Expand All @@ -92,6 +92,13 @@ namespace fp{
randMatImagePatch(featuresToTry, paramsRandMatImagePatch());
break;
}
case 3:{
randMatMultivariateTimePatch(featuresToTry, paramsRandMatImagePatch());
break;
case 4:{
randMatMultivariateTimePatchv2(featuresToTry, paramsRandMatImagePatch());
}
}
}
}

Expand Down Expand Up @@ -176,6 +183,80 @@ namespace fp{
} // END randMatStructured


inline void randMatMultivariateTimePatch(std::vector<weightedFeature>& featuresToTry, std::vector<std::vector<int> > patchPositions){
assert((int)(patchPositions[0].size()) == fpSingleton::getSingleton().returnMtry());

// Preset parameters
const int& imageHeight = fpSingleton::getSingleton().returnImageHeight();
const int& imageWidth = fpSingleton::getSingleton().returnImageWidth();

std::default_random_engine generator(randNum->gen());

int pixelIndex = -1;
for (int k = 0; k < fpSingleton::getSingleton().returnMtry(); k++) {
const int& numRowsInPatch = patchPositions[0][k];

// fill with values 0, 1, ..., imageHeight - 1
std::vector<int> rowInds(imageHeight);
std::iota(std::begin(rowInds), std::end(rowInds), 0);

// shuffle and select row indices
std::shuffle(rowInds.begin(), rowInds.end(), generator);
std::vector<int> selectedRows(rowInds.begin(), rowInds.begin() + numRowsInPatch);

assert((int) selectedRows.size() == numRowsInPatch);

for (int row = 0; row < numRowsInPatch; row++) {
for (int col = 0; col < patchPositions[1][k]; col++) {
pixelIndex = (patchPositions[2][k] % imageWidth) + col + (selectedRows[row] * imageWidth);
featuresToTry[k].returnFeatures().push_back(pixelIndex);
featuresToTry[k].returnWeights().push_back(1); // weight hard-coded to 1.
}
} // Could possibly turn this into one for-loop somehow later. [JLP]
}
} // END randMatStructured


inline void randMatMultivariateTimePatchv2(std::vector<weightedFeature>& featuresToTry, std::vector<std::vector<int> > patchPositions){
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this version can be safely ignored. I need to get rid of this one.

assert((int)(patchPositions[0].size()) == fpSingleton::getSingleton().returnMtry());

// Preset parameters
const int& imageHeight = fpSingleton::getSingleton().returnImageHeight();
const int& imageWidth = fpSingleton::getSingleton().returnImageWidth();

std::default_random_engine generator(randNum->gen());

int pixelIndex = -1;
for (int k = 0; k < fpSingleton::getSingleton().returnMtry(); k++) {
const int& numRowsInPatch = patchPositions[0][k];
const int& numColsInPatch = patchPositions[1][k];

// fill with values 0, 1, ..., imageHeight - 1
std::vector<int> rowInds(imageHeight);
std::iota(std::begin(rowInds), std::end(rowInds), 0);

// fill with values 0, 1, ..., imageWidth - 1
std::vector<int> colInds(imageWidth);
std::iota(std::begin(colInds), std::end(colInds), 0);

// shuffle and select indices
std::shuffle(rowInds.begin(), rowInds.end(), generator);
std::shuffle(colInds.begin(), colInds.end(), generator);
std::vector<int> selectedRows(rowInds.begin(), rowInds.begin() + numRowsInPatch);
std::vector<int> selectedCols(colInds.begin(), colInds.begin() + numColsInPatch);

assert((int) selectedRows.size() == numRowsInPatch);

for (int row = 0; row < numRowsInPatch; row++) {
for (int col = 0; col < numColsInPatch; col++) {
pixelIndex = (patchPositions[2][k] % imageWidth) + (selectedCols[col] * imageHeight) + (selectedRows[row] * imageWidth);
featuresToTry[k].returnFeatures().push_back(pixelIndex);
featuresToTry[k].returnWeights().push_back(1); // weight hard-coded to 1.
}
} // Could possibly turn this into one for-loop somehow later. [JLP]
}
} // END randMatStructured

inline void resetLeftNode(){
propertiesOfLeftNode.resetClassTotals();
}
Expand Down
27 changes: 27 additions & 0 deletions packedForest/src/fp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,33 @@ int main(int argc, char* argv[]) {
case 14:
forest.setParameter("forestType", "urerf");
break;
case 15:
forest.setParameter("forestType", "binnedBaseTern");
forest.setParameter("numTreeBins", numCores);
forest.setParameter("methodToUse", 3);
forest.setParameter("imageHeight", 28);
forest.setParameter("imageWidth", 28);
forest.setParameter("patchHeightMax", 5);
forest.setParameter("patchHeightMin", 5);
forest.setParameter("patchWidthMax", 5);
forest.setParameter("patchWidthMin", 5);
std::cout << "\nForcing dataset to be MNIST:\n";
dataSet = 3;
break;

case 16:
forest.setParameter("forestType", "binnedBaseTern");
forest.setParameter("numTreeBins", numCores);
forest.setParameter("methodToUse", 4);
forest.setParameter("imageHeight", 28);
forest.setParameter("imageWidth", 28);
forest.setParameter("patchHeightMax", 5);
forest.setParameter("patchHeightMin", 5);
forest.setParameter("patchWidthMax", 5);
forest.setParameter("patchWidthMin", 5);
std::cout << "\nForcing dataset to be MNIST:\n";
dataSet = 3;
break;

default:
std::cout << "unknown alg selected" << std::endl;
Expand Down
6 changes: 3 additions & 3 deletions packedForest/src/fpSingleton/fpInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ namespace fp {
useRowMajor = (bool)parameterValue;
}else if(parameterName == "methodToUse"){
methodToUse = parameterValue;
if(!(methodToUse == 1 || methodToUse == 2)){
throw std::runtime_error("methodToUse outside allowable parameters {1,2}.");
if(!(methodToUse == 1 || methodToUse == 2 || methodToUse == 3)){
throw std::runtime_error("methodToUse outside allowable parameters {1,2,3}.");
}
}else if(parameterName == "imageHeight"){
imageHeight = parameterValue;
Expand Down Expand Up @@ -363,7 +363,7 @@ namespace fp {
std::cout << "seed -> " << seed << "\n";
std::cout << "numTreeBins -> " << numTreeBins << "\n";

if(methodToUse == 2){
if(methodToUse == 2 || methodToUse == 3){
std::cout << "imageHeight -> " << imageHeight << "\n";
std::cout << "imageWidth -> " << imageWidth << "\n";
std::cout << "patchHeightMax -> " << patchHeightMax << "\n";
Expand Down
2 changes: 1 addition & 1 deletion packedForest/src/fpSingleton/fpSingleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ namespace fp {

inline void checkDataDependentParameters(){
// For Structured RerF
if(fpForestInfo.returnMethodToUse() == 2){
if(fpForestInfo.returnMethodToUse() == 2 || fpForestInfo.returnMethodToUse() == 3){
if((fpSingleton::getSingleton().returnNumFeatures() % fpSingleton::getSingleton().returnImageHeight()) != 0){
throw std::runtime_error("Specified image height is not a multiple of the number of features." );
}
Expand Down
Empty file modified packedForest/test/googletest/googletest/build-aux/.keep
100644 → 100755
Empty file.