-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathAPI.cc
More file actions
812 lines (731 loc) · 34.2 KB
/
Copy pathAPI.cc
File metadata and controls
812 lines (731 loc) · 34.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
//----------------------------------------------------------------
// Functions implemented here:
// Embed(), MakeBlock(), Simplex(), SMap(), CCM(), Multiview()
//
// Functions implemented in Eval.cc:
// EmbedDimension(), PredictInterval(), PredictNonlinear()
//
// NOTE: Functions that implement either filepath or DataFrame
// input are overloads. The first pattern takes a filepath
// argument, creates the DataFrame object, then calls the
// second with a reference to the DataFrame.
//
// In the case of SMap, there are 4 overloads, two with
// the default SVD solver, two with a user supplied solver.
// In all cases, the final overload (4) creates the SMap
// object and executes the SMap algorithm.
//----------------------------------------------------------------
#include "API.h"
//----------------------------------------------------------------
// Embed from file path/file input
//----------------------------------------------------------------
DataFrame< double > Embed( std::string path,
std::string dataFile,
int E, // embedding dimension
int tau, // time step offset
std::string columns, // column names or indices
bool verbose ) {
DataFrame< double > dataFrame( path, dataFile );
DataFrame< double > embedded = Embed( std::ref( dataFrame ),
E, tau, columns, verbose );
return embedded;
}
//----------------------------------------------------------------
// Embed from DataFrame input
//----------------------------------------------------------------
DataFrame< double > Embed( DataFrame< double > & dataFrameIn,
int E,
int tau,
std::string columns,
bool verbose ) {
// Parameter.Validate will convert columns into a vector of names
// or a vector of column indices
Parameters parameters = Parameters( Method::Embed, "", "", "", "",
"1 1", "1 1", E, 0, 0, tau, 0, 0,
columns, "", false, false, verbose );
// Instantiate EDM object
EDM EDM_Embed = EDM( dataFrameIn, std::ref( parameters ) );
// Perform embedding : calls MakeBlock() API function
EDM_Embed.EmbedData();
return EDM_Embed.embedding;
}
//------------------------------------------------------------------------
// MakeBlock from dataFrame :: API function
// First (or last) tau * (E-1) dataFrame rows have partial data,
// deletePartial controls whether or not they are returned.
// Does not validate parameters or columns, use EmbedData()
//------------------------------------------------------------------------
DataFrame< double > MakeBlock( DataFrame< double > & dataFrame,
int E,
int tau,
std::vector<std::string> columnNames,
bool deletePartial )
{
if ( columnNames.size() != dataFrame.NColumns() ) {
std::stringstream errMsg;
errMsg << "MakeBlock: The number of columns in the dataFrame ("
<< dataFrame.NColumns() << ") is not equal to the number "
<< "of columns specified (" << columnNames.size() << ").\n";;
throw std::runtime_error( errMsg.str() );
}
if ( E < 1 ) {
std::stringstream errMsg;
errMsg << "MakeBlock(): E = " << E << " is invalid.\n" ;
throw std::runtime_error( errMsg.str() );
}
size_t NDataRows = dataFrame.NRows(); // number of input rows
size_t NPartial = abs( tau ) * (E-1); // rows of partial data
size_t NRowOut; // number of output rows
size_t NColOut = dataFrame.NColumns() * E; // number of output columns
// Create embedded data frame column names X(t-0) X(t-1)...
std::vector< std::string > newColumnNames( NColOut );
size_t newCol_i = 0;
for ( size_t col = 0; col < columnNames.size(); col ++ ) {
for ( int e = 0; e < E; e++ ) {
std::stringstream ss;
if ( tau < 0 ) {
ss << columnNames[ col ] << "(t-" << -tau * e << ")";
}
else {
ss << columnNames[ col ] << "(t+" << tau * e << ")";
}
newColumnNames[ newCol_i ] = ss.str();
newCol_i++;
}
}
// Number of rows of output data frame
if ( deletePartial ) {
if ( NPartial >= NDataRows ) {
std::stringstream errMsg;
errMsg << "MakeBlock(): Number of data rows " << NDataRows
<< " not sufficient for removal of " << NPartial
<< " rows [tau*(E-1)] of partial embedding vectors.\n" ;
throw std::runtime_error( errMsg.str() );
}
NRowOut = NDataRows - NPartial;
}
else {
NRowOut = NDataRows;
}
// Ouput data frame
DataFrame< double > embedding( NRowOut, NColOut, newColumnNames );
// To keep track of where to insert column in new data frame
size_t colCount = 0;
std::slice slice_i; // slice to write data rows
std::slice slice_NA; // slice for partial data
std::valarray< double > rowNan; // NAN for partial data if not deletePartial
if ( deletePartial ) {
if ( tau < 0 ) {
slice_i = std::slice( NPartial, NDataRows - NPartial, 1 );
}
else {
slice_i = std::slice( 0, NDataRows - NPartial, 1 );
}
}
else {
slice_i = std::slice( 0, NDataRows, 1 );
rowNan = std::valarray< double >( NAN, NRowOut );
}
// Shift column data and write to embedding data frame
for ( size_t col = 0; col < dataFrame.NColumns(); col++ ) {
// for each embedding dimension
for ( int e = 0; e < E; e++ ) {
std::valarray< double > column = dataFrame.Column( col );
// Returns a copy of the valarray object with its elements
// shifted left n spaces (or right if n is negative).
std::valarray< double > tmp = column.shift( e * tau );
if ( not deletePartial ) { // replace shift 0's with NaN
int N = e * abs( tau );
if ( tau < 0 ) {
slice_NA = std::slice( 0, N, 1 );
}
else {
slice_NA = std::slice( NDataRows - N, N, 1 );
}
tmp[ slice_NA ] = rowNan[ slice_NA ];
}
// Write shifted columns to the output embedding DataFrame
embedding.WriteColumn( colCount, tmp[ slice_i ] );
colCount++;
}
}
return embedding;
}
//----------------------------------------------------------------------
// Simplex with pathIn/dataFile input : calls Simplex( & DataFrame )
//----------------------------------------------------------------------
SimplexValues Simplex( std::string pathIn,
std::string dataFile,
std::string pathOut,
std::string predictFile,
std::string lib,
std::string pred,
int E,
int Tp,
int knn,
int tau,
int exclusionRadius,
std::string columns,
std::string target,
bool embedded,
bool const_predict,
bool verbose,
std::vector<bool> validLib,
int generateSteps,
bool generateLibrary,
bool parameterList )
{
// DataFrame constructor loads data
DataFrame< double > DF( pathIn, dataFile );
// Call Simplex( & DataFrame )
SimplexValues S = Simplex( std::ref( DF ),
pathOut,
predictFile,
lib,
pred,
E,
Tp,
knn,
tau,
exclusionRadius,
columns,
target,
embedded,
const_predict,
verbose,
validLib,
generateSteps,
generateLibrary,
parameterList );
return S;
}
//----------------------------------------------------------------------
// Simplex with DataFrame input
//----------------------------------------------------------------------
SimplexValues Simplex( DataFrame< double > & DF,
std::string pathOut,
std::string predictFile,
std::string lib,
std::string pred,
int E,
int Tp,
int knn,
int tau,
int exclusionRadius,
std::string columns,
std::string target,
bool embedded,
bool const_predict,
bool verbose,
std::vector<bool> validLib,
int generateSteps,
bool generateLibrary,
bool parameterList )
{
// Instantiate Parameters
Parameters parameters = Parameters( Method::Simplex, "", "",
pathOut, predictFile,
lib, pred, E, Tp, knn, tau, 0,
exclusionRadius,
columns, target, embedded,
const_predict, verbose, validLib,
true,
generateSteps, generateLibrary,
parameterList );
// Instantiate EDM::SimplexClass object
SimplexClass SimplexModel = SimplexClass( DF, std::ref( parameters ) );
if ( generateSteps ) {
SimplexModel.Generate();
}
else {
SimplexModel.Project();
}
SimplexValues values = SimplexValues();
values.predictions = SimplexModel.projection;
values.parameterMap = SimplexModel.parameters.Map;
return values;
}
//----------------------------------------------------------------------------
// 1) SMap with pathIn/dataFile input. Calls overload 2)
// Default SVD (LAPACK) solver assigned in SMap() overload 2)
//----------------------------------------------------------------------------
SMapValues SMap( std::string pathIn,
std::string dataFile,
std::string pathOut,
std::string predictFile,
std::string lib,
std::string pred,
int E,
int Tp,
int knn,
int tau,
double theta,
int exclusionRadius,
std::string columns,
std::string target,
std::string smapCoefFile,
std::string smapSVFile,
bool embedded,
bool const_predict,
bool verbose,
std::vector<bool> validLib,
bool ignoreNan,
int generateSteps,
bool generateLibrary,
bool parameterList )
{
// DataFrame constructor loads data
DataFrame< double > DF( pathIn, dataFile );
// Call overload 2) with DataFrame
SMapValues SMapOutput = SMap( std::ref( DF ), pathOut, predictFile,
lib, pred, E, Tp, knn, tau, theta,
exclusionRadius,
columns, target, smapCoefFile, smapSVFile,
embedded, const_predict, verbose, validLib,
ignoreNan, generateSteps, generateLibrary,
parameterList );
return SMapOutput;
}
//----------------------------------------------------------------------------
// 2) SMap with DataFrame. Calls overload 4)
// Default SVD (LAPACK) solver is assigned here in the function call to 4)
//----------------------------------------------------------------------------
SMapValues SMap( DataFrame< double > & DF,
std::string pathOut,
std::string predictFile,
std::string lib,
std::string pred,
int E,
int Tp,
int knn,
int tau,
double theta,
int exclusionRadius,
std::string columns,
std::string target,
std::string smapCoefFile,
std::string smapSVFile,
bool embedded,
bool const_predict,
bool verbose,
std::vector<bool> validLib,
bool ignoreNan,
int generateSteps,
bool generateLibrary,
bool parameterList )
{
// Call overload 4) with default SVD function
SMapValues SMapOutput = SMap( DF, pathOut, predictFile,
lib, pred, E, Tp, knn, tau, theta,
exclusionRadius,
columns, target, smapCoefFile, smapSVFile,
& SVD, // Assign LAPACK SVD default solver
embedded, const_predict, verbose, validLib,
ignoreNan, generateSteps, generateLibrary,
parameterList );
return SMapOutput;
}
//----------------------------------------------------------------------------
// 3) Data pathIn/dataFile with external solver object. Calls 4)
//----------------------------------------------------------------------------
SMapValues SMap( std::string pathIn,
std::string dataFile,
std::string pathOut,
std::string predictFile,
std::string lib,
std::string pred,
int E,
int Tp,
int knn,
int tau,
double theta,
int exclusionRadius,
std::string columns,
std::string target,
std::string smapCoefFile,
std::string smapSVFile,
SVDValues (*solver)(DataFrame < double >,
std::valarray < double >),
bool embedded,
bool const_predict,
bool verbose,
std::vector<bool> validLib,
bool ignoreNan,
int generateSteps,
bool generateLibrary,
bool parameterList )
{
// DataFrame constructor loads data
DataFrame< double > DF( pathIn, dataFile );
// Call overload 4) with DataFrame and solver object
SMapValues SMapOutput = SMap( std::ref( DF ), pathOut, predictFile,
lib, pred, E, Tp, knn, tau, theta,
exclusionRadius,
columns, target, smapCoefFile, smapSVFile,
solver, embedded, const_predict, verbose,
validLib, ignoreNan,
generateSteps, generateLibrary,
parameterList );
return SMapOutput;
}
//----------------------------------------------------------------------------
// 4) DataFrame with default SVD/BLAS or external solver object
//----------------------------------------------------------------------------
SMapValues SMap( DataFrame< double > & DF,
std::string pathOut,
std::string predictFile,
std::string lib,
std::string pred,
int E,
int Tp,
int knn,
int tau,
double theta,
int exclusionRadius,
std::string columns,
std::string target,
std::string smapCoefFile,
std::string smapSVFile,
SVDValues (*solver)(DataFrame < double >,
std::valarray < double >),
bool embedded,
bool const_predict,
bool verbose,
std::vector<bool> validLib,
bool ignoreNan,
int generateSteps,
bool generateLibrary,
bool parameterList )
{
Parameters parameters = Parameters( Method::SMap, "", "",
pathOut, predictFile,
lib, pred, E, Tp, knn, tau, theta,
exclusionRadius,
columns, target, embedded,
const_predict, verbose, validLib,
ignoreNan,
generateSteps, generateLibrary,
parameterList, smapCoefFile, smapSVFile);
//-----------------------------------------------------------------
// Detect nan : BLAS solver does not allow nan
//-----------------------------------------------------------------
std::vector< std::string > nanColsCheck = parameters.columnNames;
// Add target to nanColsCheck for DF.NanRows()
if ( not parameters.targetNames.empty() and
find( nanColsCheck.begin(), nanColsCheck.end(),
parameters.targetNames.front() ) == nanColsCheck.end() ) {
nanColsCheck.push_back( parameters.targetNames.front() );
}
DF.FindNan( nanColsCheck ); // If nan, set DF.nanFound, DF.nanRows
if ( parameters.verbose and DF.NanFound() ) {
// Issue warning
std::stringstream msg;
msg << "WARNING: SMap() " << DF.NanRows().size()
<< " nan rows detected in columns or target. "
<< "Original number of rows " << DF.NRows() << ".\n";
std::cout << msg.str();
msg.str( std::string() ); // clear msg
msg << "WARNING: SMap() nan rows: ";
std::vector< size_t >::iterator ni;
for ( ni = DF.NanRows().begin(); ni != DF.NanRows().end(); ++ni ) {
msg << *ni + 1 << " ";
} msg << "\n";
std::cout << msg.str();
}
//-----------------------------------------------------------------
// If NanFound : create new library with gaps for nan
//-----------------------------------------------------------------
if ( parameters.ignoreNan and DF.NanFound() ) {
// Use Parameters.Validate() to regenerate library with gaps
// Copy of full library indices (0-offset) from parameters
std::vector< size_t > libVec_0( parameters.library );
std::vector< size_t >::iterator ni;
std::vector< size_t >::iterator fi;
std::vector< size_t >::iterator li;
//------------------------------------------------------------
// Remove NanRows from libVec
//------------------------------------------------------------
for ( ni = DF.NanRows().begin(); ni != DF.NanRows().end(); ++ni ) {
size_t nanRow_0 = *ni; // 0-offset NanRow
fi = std::find( libVec_0.begin(), libVec_0.end(), nanRow_0 );
if ( fi != libVec_0.end() ) {
// Found nanRow_0 in libVec, erase it
libVec_0.erase( fi );
}
}
//------------------------------------------------------------
// Build new lib pairs from sequential values of libVec
//------------------------------------------------------------
std::vector< size_t > libNew_1;
libNew_1.push_back( libVec_0.front() + 1 ); // Insert first element
int previousLib_1 = (int) libVec_0.front() + 1;
int deltaRow = 0;
int previousDeltaRow = 1;
for ( li = libVec_0.begin() + 1; li != libVec_0.end(); ++li ) {
size_t libRow_1 = *li + 1;
deltaRow = (int) libRow_1 - previousLib_1;
if ( deltaRow == 1 ) {
// sequential lib_i, do not add
}
else if ( previousDeltaRow != 1 ) {
// increment previous lib row
*(libNew_1.end() - 1) = libNew_1.back() + deltaRow;
}
else {
// Insert gap start : end
libNew_1.push_back((size_t) previousLib_1);
libNew_1.push_back( libRow_1 );
}
previousLib_1 = (int) libRow_1;
previousDeltaRow = deltaRow;
}
libNew_1.push_back( libVec_0.back() + 1 ); // Insert last element
// Edge case of redundant first two indices
if ( libNew_1[0] == libNew_1[1] ) {
libNew_1.erase( libNew_1.begin(), libNew_1.begin() + 2 );
}
// Edge case of redundant last two indices
if ( *(libNew_1.end()-1) == *(libNew_1.end() - 2) ) {
libNew_1.erase( libNew_1.end() - 2, libNew_1.end() );
}
// Parse numeric vector to string for Parameters.Validate()
std::stringstream libNew_1_ss;
for ( size_t i = 0; i < libNew_1.size(); i++ ) {
libNew_1_ss << libNew_1[i] << " ";
}
std::string libNew = libNew_1_ss.str();
if ( parameters.verbose ) {
std::stringstream msg;
msg << "WARNING: SMap() New library spec to avoid nan: "
<< libNew << std::endl;
std::cout << msg.str();
}
// Using libNew string of library pairs, create new library
parameters = Parameters( Method::SMap, "", "",
pathOut, predictFile,
libNew, pred, E, Tp, knn, tau, theta,
exclusionRadius,
columns, target, embedded,
const_predict, verbose, validLib, ignoreNan,
generateSteps, generateLibrary,
parameterList, smapCoefFile, smapSVFile );
} // if ( DF.NanFound() )
// Instantiate EDM::SMapClass object
SMapClass SMapModel = SMapClass( DF, std::ref( parameters ) );
if ( generateSteps ) {
SMapModel.Generate( solver );
}
else {
SMapModel.Project( solver );
}
SMapValues values = SMapValues();
values.predictions = SMapModel.projection;
values.coefficients = SMapModel.coefficients;
values.singularValues = SMapModel.singularValues;
values.parameterMap = SMapModel.parameters.Map;
return values;
}
//----------------------------------------------------------------------
// CCM with pathin/dataFile input. Calls CCM( & DF )
//----------------------------------------------------------------------
CCMValues CCM( std::string pathIn,
std::string dataFile,
std::string pathOut,
std::string predictFile,
int E,
int Tp,
int knn,
int tau,
int exclusionRadius,
std::string columns,
std::string target,
std::string libSizes_str,
int sample,
bool random,
bool replacement,
unsigned seed,
bool embedded,
bool includeData,
bool parameterList,
bool verbose )
{
// DataFrame constructor loads data
DataFrame< double > DF( pathIn, dataFile );
CCMValues ccmValues = CCM( std::ref( DF ), pathOut, predictFile,
E, Tp, knn, tau, exclusionRadius,
columns, target, libSizes_str,
sample, random, replacement,
seed, embedded, includeData,
parameterList, verbose );
return ccmValues;
}
//----------------------------------------------------------------------
// CCM with DataFrame input
//----------------------------------------------------------------------
CCMValues CCM( DataFrame< double > & DF,
std::string pathOut,
std::string predictFile,
int E,
int Tp,
int knn,
int tau,
int exclusionRadius,
std::string columns,
std::string target,
std::string libSizes_str,
int sample,
bool random,
bool replacement,
unsigned seed,
bool embedded,
bool includeData,
bool parameterList,
bool verbose )
{
// Set library and prediction indices to entire library (embedded)
std::stringstream ss;
ss << "1 " << DF.NRows();
Parameters parameters = Parameters( Method::CCM,
"", // pathIn
"", // dataFile
pathOut, //
predictFile, //
ss.str(), // lib_str
ss.str(), // pred_str
E, //
Tp, //
knn, //
tau, //
0, // theta
exclusionRadius, //
columns, //
target, //
embedded, //
false, // const_predict
verbose, //
std::vector<bool>(), // validLib
true, // ignoreNan
0, // generateSteps
false, // generateLibrary
parameterList, //
"", // SmapOutputFile
"", // SmapSVFile
"", // blockOutputFile
0, // multiviewEnsemble
0, // multiviewD
false, // multiviewTrainLib
false, // multiviewExcludeTarg
libSizes_str, //
sample, //
random, //
replacement, //
seed, //
includeData ); //
// Instantiate EDM::Simplex::CCM object
CCMClass CCMModel = CCMClass( DF, std::ref( parameters ) );
CCMModel.Project();
CCMValues values = CCMValues();
values.AllLibStats = CCMModel.allLibStats;
values.CrossMap1 = CCMModel.colToTargetValues;
values.CrossMap2 = CCMModel.targetToColValues;
values.parameterMap = CCMModel.parameters.Map;
return values;
}
//----------------------------------------------------------------------
// Multiview with path/file input. Calls Multiview( & DF )
//----------------------------------------------------------------------
MultiviewValues Multiview( std::string pathIn,
std::string dataFile,
std::string pathOut,
std::string predictFile,
std::string lib,
std::string pred,
int D,
int E,
int Tp,
int knn,
int tau,
std::string columns,
std::string target,
int multiview,
int exclusionRadius,
bool trainLib,
bool excludeTarget,
bool parameterList,
bool verbose,
unsigned nThreads )
{
// DataFrame constructor loads data
DataFrame< double > DF( pathIn, dataFile );
MultiviewValues mvValues = Multiview( std::ref( DF ), pathOut, predictFile,
lib, pred, D, E, Tp, knn, tau,
columns, target, multiview,
exclusionRadius, trainLib,
excludeTarget, parameterList,
verbose, nThreads );
return mvValues;
}
//----------------------------------------------------------------------
// Multiview with DataFrame input
//----------------------------------------------------------------------
MultiviewValues Multiview( DataFrame< double > & DF,
std::string pathOut,
std::string predictFile,
std::string lib,
std::string pred,
int D,
int E,
int Tp,
int knn,
int tau,
std::string columns,
std::string target,
int multiview,
int exclusionRadius,
bool trainLib,
bool excludeTarget,
bool parameterList,
bool verbose,
unsigned nThreads )
{
// Note: Method::Simplex & embedded = false
// Parameters constructor calls Validate()
// If embedded = true: Validate() will set E to number of columns
// We need E to pass to PrepareEmbedding() : EmbedData()
Parameters parameters = Parameters( Method::Multiview,
"", // pathIn
"", // dataFile
pathOut, //
predictFile, //
lib, // lib_str
pred, // pred_str
E, //
Tp, //
knn, //
tau, //
0, // theta
exclusionRadius,
columns, //
target, //
false, // embedded false
false, // const_predict
verbose, //
std::vector<bool>(), // validLib
true, // ignoreNan
0, // generateSteps
false, // generateLibrary
parameterList,//
"", // SmapOutputFile
"", // SmapSVFile
"", // blockOutputFile
multiview, // multiviewEnsemble,
D, // multiviewD
trainLib, // multiviewTrainLib
excludeTarget );// multiviewExcludeTarget
// Instantiate EDM::Simplex::Multiview object
MultiviewClass MultiviewModel = MultiviewClass( DF, std::ref( parameters ) );
MultiviewModel.Project( nThreads );
// MultiviewClass MultiviewModel contians MultiviewValues MVvalues
MultiviewModel.MVvalues.parameterMap = MultiviewModel.parameters.Map;
return MultiviewModel.MVvalues;
}