Skip to content

Commit

Permalink
v1.12.0 Add exclusionRadius validLib to EmbedDimension, PredictInterv…
Browse files Browse the repository at this point in the history
…al, PredictNonlinear
  • Loading branch information
SoftwareLiteracy committed May 8, 2022
1 parent 8424b3b commit ab0f75c
Show file tree
Hide file tree
Showing 7 changed files with 267 additions and 166 deletions.
Binary file modified doc/cppEDM.pdf
Binary file not shown.
34 changes: 20 additions & 14 deletions etc/Test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,12 @@ int main( int argc, char *argv[] ) {
10, // maxE
1, // Tp
-1, // tau
0, // exclusionRadius
"TentMap", // colNames
"", // targetName
false, // embedded
false, // verbose
std::vector<bool>(),// validLib
4 ); // nThreads

std::cout << "EmbedDimension TentMap_rEDM.csv:\n";
Expand All @@ -303,10 +305,12 @@ int main( int argc, char *argv[] ) {
10, // maxTp
2, // E
-1, // tau
0, // exclusionRadius
"TentMap", // colNames
"", // targetName,
false, // embedded
false, // verbose
std::vector<bool>(), // validLib
4 ); // nThreads

std::cout << "PredictInterval TentMap_rEDM.csv:\n";
Expand All @@ -317,22 +321,24 @@ int main( int argc, char *argv[] ) {
//----------------------------------------------------------
//----------------------------------------------------------
DataFrame< double > NL =
PredictNonlinear( "../data/", // pathIn,
PredictNonlinear( "../data/", // pathIn,
"TentMapNoise_rEDM.csv", // dataFile,
"./", // pathOut,
"./", // pathOut,
"PredictNonlinearOut.csv", // predictFile,
"1 100", // lib,
"201 500", // pred,
"", // theta,
2, // E,
1, // Tp,
0, // knn,
-1, // tau,
"TentMap", // colNames,
"", // targetName,
false, // embedded,
false, // verbose,
4 ); // nThreads
"1 100", // lib,
"201 500", // pred,
"", // theta,
2, // E,
1, // Tp,
0, // knn,
-1, // tau,
0, // exclusionRadius
"TentMap", // colNames,
"", // targetName,
false, // embedded,
false, // verbose,
std::vector<bool>(), // validLib
4 ); // nThreads

NL.MaxRowPrint() = 15;
std::cout << "PredictNonlinear TentMapNoise_rEDM.csv:\n";
Expand Down
52 changes: 42 additions & 10 deletions etc/dataFrame.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// g++ dataFrame.cc -o dataFrame -std=c++11 -g -I../src -L../lib -lstdc++ -lEDM -llapack -pthread
// g++ dataFrame.cc -o dataFrame -std=c++11 -g -I../src -L../lib -lstdc++ -lEDM

#include "API.h"
#include "DataFrame.h"
Expand All @@ -10,19 +10,19 @@
int main( int argc, char *argv[] ) {

std::string dataFile = "../data/block_3sp.csv";
std::string columns = "x_t";
std::string fileOut = "out.csv";
std::string columns = "x_t y_t z_t";
std::string fileOut = "";
bool verbose = false; // 'y' = true

if ( argc > 1 ) { dataFile = argv[1]; }
if ( argc > 2 ) { columns = argv[2]; }
if ( argc > 3 ) { fileOut = argv[3]; }
if ( argc > 4 ){ verbose = ( *argv[4] == 'y' ? true : false ); }

if ( verbose ) {
std::cout << dataFile << " cols " << columns << std::endl;
std::cout << dataFile << " columns " << columns << std::endl;
}

try {
//----------------------------------------------------------
//----------------------------------------------------------
Expand All @@ -37,25 +37,57 @@ int main( int argc, char *argv[] ) {
std::cout << DF;
}

// Data Frame From Row Index
size_t rowi[] = { 0,2,4,6,8,10 };
std::vector< size_t > rows( rowi, rowi + sizeof(rowi)/sizeof(size_t) );
DataFrame < double > DFrows = DF.DataFrameFromRowIndex( rows );
std::cout << ">>>>>>> DataFrameFromRowIndex\n";
std::cout << DFrows;

size_t coli[] = { 1 };
// Data Frame From Column Index
size_t coli[] = { 1, 4, 7 };
std::vector< size_t > cols( coli, coli + sizeof(coli)/sizeof(size_t) );
DataFrame < double > DFcols = DF.DataFrameFromColumnIndex( cols );
std::cout << ">>>>>>> DataFrameFromColumnIndex\n";
std::cout << DFcols;

// Data Frame From Column Names
std::vector<std::string> colNames = SplitString( columns, " \t\n" );
DataFrame < double > DFrowscols =
DFrows.DataFrameFromColumnIndex( cols );
DFrows.DataFrameFromColumnNames( colNames );
std::cout << ">>>>>>> DataFrameFromColumnNames\n";
std::cout << DFrowscols;

// Data Frame Remove Nan Rows
// Set nan in DF
DF( 185, 0 ) = nan("dataFrame"); // x_t
DF( 188, 5 ) = nan("dataFrame"); // y_t-2
DF( 189, 3 ) = nan("dataFrame"); // y_t
DF( 190, 0 ) = nan("dataFrame"); // x_t
DF( 193, 2 ) = nan("dataFrame"); // x_t-2
DF( 195, 4 ) = nan("dataFrame"); // y_t-1

bool nanFound = DF.NanRows( colNames ); // set DF validRows
DataFrame < double > DFnan = DF.DataFrameRemoveNanRows();
std::cout << ">>>>>>> DataFrameRemoveNanRows\n";
std::cout << "---------- nan rows: ";
for ( auto n : DF.NanRows() ) { std::cout << n << " "; }
std::cout << std::endl;
std::cout << DFnan;

// Copy constructor
DFrows( 0, 0 ) = -999.0;
DataFrame< double > DFC = DFrows;
DFrows( 1, 0 ) = -888.0;
std::cout << ">>>>>>> DFRows copy\n";
std::cout << DFC;


if ( fileOut.size() ) {
DF.WriteData( "", fileOut );
}
}

catch ( const std::exception& e ) {
std::cout << "Exception caught in main:\n";
std::cout << e.what() << std::endl;
Expand All @@ -67,6 +99,6 @@ int main( int argc, char *argv[] ) {
}

std::cout << "normal termination\n";

return 0;
}
6 changes: 6 additions & 0 deletions etc/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ int main( int argc, char *argv[] ) {
10, // maxE <<<<< CONSTANT
Tp, // Tp
-1, // tau <<<<< CONSTANT
exclusionR, // exclusionRadius
columns, // colNames
target, // targetName
embedded, // embedded
verbose, // verbose
std::vector<bool>(), // validLib
nThreads ); // nThreads

std::cout << "EmbedDimension:\n";
Expand All @@ -86,10 +88,12 @@ int main( int argc, char *argv[] ) {
10, // maxTp <<<<< CONSTANT
E, // E
-1, // tau <<<<< CONSTANT
exclusionR, // exclusionRadius
columns, // colNames
target, // targetName
embedded, // embedded
verbose, // verbose
std::vector<bool>(), // validLib
nThreads ); // nThreads

std::cout << "PredictInterval:\n";
Expand All @@ -113,10 +117,12 @@ int main( int argc, char *argv[] ) {
Tp, // Tp
0, // knn
-1, // tau <<<<< CONSTANT
exclusionR, // exclusionRadius
columns, // colNames
target, // targetName
embedded, // embedded
verbose, // verbose
std::vector<bool>(), // validLib
nThreads ); // nThreads

NL.MaxRowPrint() = 15;
Expand Down
Loading

0 comments on commit ab0f75c

Please sign in to comment.