-
Notifications
You must be signed in to change notification settings - Fork 3
/
DataAnalysis.h
1329 lines (1251 loc) · 73.5 KB
/
DataAnalysis.h
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
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ALGLIB++
// Based on ALGLIB: Copyright (c) Sergey Bochkanov (ALGLIB project).
// Revisions Copyright (c) Lydia Marie Williamson, Mark Hopkins Consulting
// Source License:
// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation (www.fsf.org);
// either version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// A copy of the GNU General Public License is available at http://www.fsf.org/licensing/licenses
#ifndef OnceOnlyDataAnalysis_h
#define OnceOnlyDataAnalysis_h
#include "Statistics.h"
#include "Optimization.h"
// === PCA Package ===
// Depends on: (LinAlg) EVD, SVD
// Depends on: (Statistics) BASESTAT
namespace alglib_impl {
void pcabuildbasis(RMatrix *x, ae_int_t npoints, ae_int_t nvars, ae_int_t *info, RVector *s2, RMatrix *v);
void pcatruncatedsubspace(RMatrix *x, ae_int_t npoints, ae_int_t nvars, ae_int_t nneeded, double eps, ae_int_t maxits, RVector *s2, RMatrix *v);
void pcatruncatedsubspacesparse(sparsematrix *x, ae_int_t npoints, ae_int_t nvars, ae_int_t nneeded, double eps, ae_int_t maxits, RVector *s2, RMatrix *v);
} // end of namespace alglib_impl
namespace alglib {
void pcabuildbasis(const real_2d_array &x, const ae_int_t npoints, const ae_int_t nvars, ae_int_t &info, real_1d_array &s2, real_2d_array &v);
void pcatruncatedsubspace(const real_2d_array &x, const ae_int_t npoints, const ae_int_t nvars, const ae_int_t nneeded, const double eps, const ae_int_t maxits, real_1d_array &s2, real_2d_array &v);
void pcatruncatedsubspacesparse(const sparsematrix &x, const ae_int_t npoints, const ae_int_t nvars, const ae_int_t nneeded, const double eps, const ae_int_t maxits, real_1d_array &s2, real_2d_array &v);
} // end of namespace alglib
// === BDSS Package ===
// Depends on: (Statistics) BASESTAT
namespace alglib_impl {
struct cvreport {
double relclserror;
double avgce;
double rmserror;
double avgerror;
double avgrelerror;
};
void cvreport_init(void *_p, bool make_automatic);
void cvreport_copy(void *_dst, const void *_src, bool make_automatic);
void cvreport_free(void *_p, bool make_automatic);
void dserrallocate(ae_int_t nclasses, RVector *buf);
void dserraccumulate(RVector *buf, RVector *y, RVector *desiredy);
void dserrfinish(RVector *buf);
void dsnormalize(RMatrix *xy, ae_int_t npoints, ae_int_t nvars, ae_int_t *info, RVector *means, RVector *sigmas);
void dsnormalizec(RMatrix *xy, ae_int_t npoints, ae_int_t nvars, ae_int_t *info, RVector *means, RVector *sigmas);
double dsgetmeanmindistance(RMatrix *xy, ae_int_t npoints, ae_int_t nvars);
void dstie(RVector *a, ae_int_t n, ZVector *ties, ae_int_t *tiecount, ZVector *p1, ZVector *p2);
void dstiefasti(RVector *a, ZVector *b, ae_int_t n, ZVector *ties, ae_int_t *tiecount, RVector *bufr, ZVector *bufi);
void dsoptimalsplit2(RVector *a, ZVector *c, ae_int_t n, ae_int_t *info, double *threshold, double *pal, double *pbl, double *par, double *pbr, double *cve);
void dsoptimalsplit2fast(RVector *a, ZVector *c, ZVector *tiesbuf, ZVector *cntbuf, RVector *bufr, ZVector *bufi, ae_int_t n, ae_int_t nc, double alpha, ae_int_t *info, double *threshold, double *rms, double *cvrms);
void dssplitk(RVector *a, ZVector *c, ae_int_t n, ae_int_t nc, ae_int_t kmax, ae_int_t *info, RVector *thresholds, ae_int_t *ni, double *cve);
void dsoptimalsplitk(RVector *a, ZVector *c, ae_int_t n, ae_int_t nc, ae_int_t kmax, ae_int_t *info, RVector *thresholds, ae_int_t *ni, double *cve);
} // end of namespace alglib_impl
namespace alglib {
void dsoptimalsplit2(const real_1d_array &a, const integer_1d_array &c, const ae_int_t n, ae_int_t &info, double &threshold, double &pal, double &pbl, double &par, double &pbr, double &cve);
void dsoptimalsplit2fast(real_1d_array &a, integer_1d_array &c, integer_1d_array &tiesbuf, integer_1d_array &cntbuf, real_1d_array &bufr, integer_1d_array &bufi, const ae_int_t n, const ae_int_t nc, const double alpha, ae_int_t &info, double &threshold, double &rms, double &cvrms);
} // end of namespace alglib
// === MLPBASE Package ===
// Depends on: (AlgLibInternal) HPCCORES
// Depends on: (LinAlg) SPARSE
// Depends on: BDSS
namespace alglib_impl {
struct modelerrors {
double relclserror;
double avgce;
double rmserror;
double avgerror;
double avgrelerror;
};
void modelerrors_init(void *_p, bool make_automatic);
void modelerrors_copy(void *_dst, const void *_src, bool make_automatic);
void modelerrors_free(void *_p, bool make_automatic);
struct smlpgrad {
double f;
ae_vector g;
};
void smlpgrad_init(void *_p, bool make_automatic);
void smlpgrad_copy(void *_dst, const void *_src, bool make_automatic);
void smlpgrad_free(void *_p, bool make_automatic);
struct multilayerperceptron {
ae_int_t hlnetworktype;
ae_int_t hlnormtype;
ae_vector hllayersizes;
ae_vector hlconnections;
ae_vector hlneurons;
ae_vector structinfo;
ae_vector weights;
ae_vector columnmeans;
ae_vector columnsigmas;
ae_vector neurons;
ae_vector dfdnet;
ae_vector derror;
ae_vector x;
ae_vector y;
ae_matrix xy;
ae_vector xyrow;
ae_vector nwbuf;
ae_vector integerbuf;
modelerrors err;
ae_vector rndbuf;
ae_shared_pool buf;
ae_shared_pool gradbuf;
ae_matrix dummydxy;
sparsematrix dummysxy;
ae_vector dummyidx;
ae_shared_pool dummypool;
};
void multilayerperceptron_init(void *_p, bool make_automatic);
void multilayerperceptron_copy(void *_dst, const void *_src, bool make_automatic);
void multilayerperceptron_free(void *_p, bool make_automatic);
void mlpalloc(ae_serializer *s, multilayerperceptron *network);
void mlpserialize(ae_serializer *s, multilayerperceptron *network);
void mlpunserialize(ae_serializer *s, multilayerperceptron *network);
void mlpproperties(multilayerperceptron *network, ae_int_t *nin, ae_int_t *nout, ae_int_t *wcount);
bool mlpissoftmax(multilayerperceptron *network);
void mlprandomize(multilayerperceptron *network);
void mlprandomizefull(multilayerperceptron *network);
void mlpcreate0(ae_int_t nin, ae_int_t nout, multilayerperceptron *network);
void mlpcreate1(ae_int_t nin, ae_int_t nhid, ae_int_t nout, multilayerperceptron *network);
void mlpcreate2(ae_int_t nin, ae_int_t nhid1, ae_int_t nhid2, ae_int_t nout, multilayerperceptron *network);
void mlpcreateb0(ae_int_t nin, ae_int_t nout, double b, double d, multilayerperceptron *network);
void mlpcreateb1(ae_int_t nin, ae_int_t nhid, ae_int_t nout, double b, double d, multilayerperceptron *network);
void mlpcreateb2(ae_int_t nin, ae_int_t nhid1, ae_int_t nhid2, ae_int_t nout, double b, double d, multilayerperceptron *network);
void mlpcreater0(ae_int_t nin, ae_int_t nout, double a, double b, multilayerperceptron *network);
void mlpcreater1(ae_int_t nin, ae_int_t nhid, ae_int_t nout, double a, double b, multilayerperceptron *network);
void mlpcreater2(ae_int_t nin, ae_int_t nhid1, ae_int_t nhid2, ae_int_t nout, double a, double b, multilayerperceptron *network);
void mlpcreatec0(ae_int_t nin, ae_int_t nout, multilayerperceptron *network);
void mlpcreatec1(ae_int_t nin, ae_int_t nhid, ae_int_t nout, multilayerperceptron *network);
void mlpcreatec2(ae_int_t nin, ae_int_t nhid1, ae_int_t nhid2, ae_int_t nout, multilayerperceptron *network);
void mlpactivationfunction(double net, ae_int_t k, double *f, double *df, double *d2f);
void mlpinternalprocessvector(ZVector *structinfo, RVector *weights, RVector *columnmeans, RVector *columnsigmas, RVector *neurons, RVector *dfdnet, RVector *x, RVector *y);
void mlpprocess(multilayerperceptron *network, RVector *x, RVector *y);
void mlpprocessi(multilayerperceptron *network, RVector *x, RVector *y);
ae_int_t mlpgradsplitcost();
ae_int_t mlpgradsplitsize();
ae_int_t mlpntotal(multilayerperceptron *network);
void mlpgrad(multilayerperceptron *network, RVector *x, RVector *desiredy, double *e, RVector *grad);
void mlpgradn(multilayerperceptron *network, RVector *x, RVector *desiredy, double *e, RVector *grad);
void mlpgradbatchx(multilayerperceptron *network, RMatrix *densexy, sparsematrix *sparsexy, ae_int_t datasetsize, ae_int_t datasettype, ZVector *idx, ae_int_t subset0, ae_int_t subset1, ae_int_t subsettype, ae_shared_pool *buf, ae_shared_pool *gradbuf);
void mlpgradbatch(multilayerperceptron *network, RMatrix *xy, ae_int_t ssize, double *e, RVector *grad);
void mlpgradbatchsparse(multilayerperceptron *network, sparsematrix *xy, ae_int_t ssize, double *e, RVector *grad);
void mlpgradbatchsubset(multilayerperceptron *network, RMatrix *xy, ae_int_t setsize, ZVector *idx, ae_int_t subsetsize, double *e, RVector *grad);
void mlpgradbatchsparsesubset(multilayerperceptron *network, sparsematrix *xy, ae_int_t setsize, ZVector *idx, ae_int_t subsetsize, double *e, RVector *grad);
void mlpgradnbatch(multilayerperceptron *network, RMatrix *xy, ae_int_t ssize, double *e, RVector *grad);
void mlphessiannbatch(multilayerperceptron *network, RMatrix *xy, ae_int_t ssize, double *e, RVector *grad, RMatrix *h);
void mlphessianbatch(multilayerperceptron *network, RMatrix *xy, ae_int_t ssize, double *e, RVector *grad, RMatrix *h);
ae_int_t mlpgetinputscount(multilayerperceptron *network);
ae_int_t mlpgetoutputscount(multilayerperceptron *network);
ae_int_t mlpgetweightscount(multilayerperceptron *network);
ae_int_t mlpgetlayerscount(multilayerperceptron *network);
ae_int_t mlpgetlayersize(multilayerperceptron *network, ae_int_t k);
void mlpgetinputscaling(multilayerperceptron *network, ae_int_t i, double *mean, double *sigma);
void mlpgetoutputscaling(multilayerperceptron *network, ae_int_t i, double *mean, double *sigma);
void mlpgetneuroninfo(multilayerperceptron *network, ae_int_t k, ae_int_t i, ae_int_t *fkind, double *threshold);
double mlpgetweight(multilayerperceptron *network, ae_int_t k0, ae_int_t i0, ae_int_t k1, ae_int_t i1);
void mlpsetinputscaling(multilayerperceptron *network, ae_int_t i, double mean, double sigma);
void mlpsetoutputscaling(multilayerperceptron *network, ae_int_t i, double mean, double sigma);
void mlpsetneuroninfo(multilayerperceptron *network, ae_int_t k, ae_int_t i, ae_int_t fkind, double threshold);
void mlpsetweight(multilayerperceptron *network, ae_int_t k0, ae_int_t i0, ae_int_t k1, ae_int_t i1, double w);
void mlpcopyshared(multilayerperceptron *network1, multilayerperceptron *network2);
void mlpcopy(multilayerperceptron *network1, multilayerperceptron *network2);
bool mlpsamearchitecture(multilayerperceptron *network1, multilayerperceptron *network2);
void mlpcopytunableparameters(multilayerperceptron *network1, multilayerperceptron *network2);
void mlpexporttunableparameters(multilayerperceptron *network, RVector *p, ae_int_t *pcount);
void mlpimporttunableparameters(multilayerperceptron *network, RVector *p);
void mlpserializeold(multilayerperceptron *network, RVector *ra, ae_int_t *rlen);
void mlpunserializeold(RVector *ra, multilayerperceptron *network);
void mlpinitpreprocessor(multilayerperceptron *network, RMatrix *xy, ae_int_t ssize);
void mlpinitpreprocessorsparse(multilayerperceptron *network, sparsematrix *xy, ae_int_t ssize);
void mlpinitpreprocessorsubset(multilayerperceptron *network, RMatrix *xy, ae_int_t setsize, ZVector *idx, ae_int_t subsetsize);
void mlpinitpreprocessorsparsesubset(multilayerperceptron *network, sparsematrix *xy, ae_int_t setsize, ZVector *idx, ae_int_t subsetsize);
void mlpallerrorsx(multilayerperceptron *network, RMatrix *densexy, sparsematrix *sparsexy, ae_int_t datasetsize, ae_int_t datasettype, ZVector *idx, ae_int_t subset0, ae_int_t subset1, ae_int_t subsettype, ae_shared_pool *buf, modelerrors *rep);
double mlperror(multilayerperceptron *network, RMatrix *xy, ae_int_t npoints);
double mlperrorsparse(multilayerperceptron *network, sparsematrix *xy, ae_int_t npoints);
double mlperrorn(multilayerperceptron *network, RMatrix *xy, ae_int_t ssize);
ae_int_t mlpclserror(multilayerperceptron *network, RMatrix *xy, ae_int_t npoints);
double mlprelclserror(multilayerperceptron *network, RMatrix *xy, ae_int_t npoints);
double mlprelclserrorsparse(multilayerperceptron *network, sparsematrix *xy, ae_int_t npoints);
double mlpavgce(multilayerperceptron *network, RMatrix *xy, ae_int_t npoints);
double mlpavgcesparse(multilayerperceptron *network, sparsematrix *xy, ae_int_t npoints);
double mlprmserror(multilayerperceptron *network, RMatrix *xy, ae_int_t npoints);
double mlprmserrorsparse(multilayerperceptron *network, sparsematrix *xy, ae_int_t npoints);
double mlpavgerror(multilayerperceptron *network, RMatrix *xy, ae_int_t npoints);
double mlpavgerrorsparse(multilayerperceptron *network, sparsematrix *xy, ae_int_t npoints);
double mlpavgrelerror(multilayerperceptron *network, RMatrix *xy, ae_int_t npoints);
double mlpavgrelerrorsparse(multilayerperceptron *network, sparsematrix *xy, ae_int_t npoints);
void mlpallerrorssubset(multilayerperceptron *network, RMatrix *xy, ae_int_t setsize, ZVector *subset, ae_int_t subsetsize, modelerrors *rep);
void mlpallerrorssparsesubset(multilayerperceptron *network, sparsematrix *xy, ae_int_t setsize, ZVector *subset, ae_int_t subsetsize, modelerrors *rep);
double mlperrorsubset(multilayerperceptron *network, RMatrix *xy, ae_int_t setsize, ZVector *subset, ae_int_t subsetsize);
double mlperrorsparsesubset(multilayerperceptron *network, sparsematrix *xy, ae_int_t setsize, ZVector *subset, ae_int_t subsetsize);
} // end of namespace alglib_impl
namespace alglib {
DecClass(modelerrors, double &relclserror; double &avgce; double &rmserror; double &avgerror; double &avgrelerror;);
DecClass(multilayerperceptron, );
void mlpserialize(multilayerperceptron &obj, std::string &s_out);
void mlpserialize(multilayerperceptron &obj, std::ostream &s_out);
void mlpunserialize(const std::string &s_in, multilayerperceptron &obj);
void mlpunserialize(const std::istream &s_in, multilayerperceptron &obj);
void mlpproperties(const multilayerperceptron &network, ae_int_t &nin, ae_int_t &nout, ae_int_t &wcount);
bool mlpissoftmax(const multilayerperceptron &network);
void mlprandomize(const multilayerperceptron &network);
void mlprandomizefull(const multilayerperceptron &network);
void mlpcreate0(const ae_int_t nin, const ae_int_t nout, multilayerperceptron &network);
void mlpcreate1(const ae_int_t nin, const ae_int_t nhid, const ae_int_t nout, multilayerperceptron &network);
void mlpcreate2(const ae_int_t nin, const ae_int_t nhid1, const ae_int_t nhid2, const ae_int_t nout, multilayerperceptron &network);
void mlpcreateb0(const ae_int_t nin, const ae_int_t nout, const double b, const double d, multilayerperceptron &network);
void mlpcreateb1(const ae_int_t nin, const ae_int_t nhid, const ae_int_t nout, const double b, const double d, multilayerperceptron &network);
void mlpcreateb2(const ae_int_t nin, const ae_int_t nhid1, const ae_int_t nhid2, const ae_int_t nout, const double b, const double d, multilayerperceptron &network);
void mlpcreater0(const ae_int_t nin, const ae_int_t nout, const double a, const double b, multilayerperceptron &network);
void mlpcreater1(const ae_int_t nin, const ae_int_t nhid, const ae_int_t nout, const double a, const double b, multilayerperceptron &network);
void mlpcreater2(const ae_int_t nin, const ae_int_t nhid1, const ae_int_t nhid2, const ae_int_t nout, const double a, const double b, multilayerperceptron &network);
void mlpcreatec0(const ae_int_t nin, const ae_int_t nout, multilayerperceptron &network);
void mlpcreatec1(const ae_int_t nin, const ae_int_t nhid, const ae_int_t nout, multilayerperceptron &network);
void mlpcreatec2(const ae_int_t nin, const ae_int_t nhid1, const ae_int_t nhid2, const ae_int_t nout, multilayerperceptron &network);
void mlpactivationfunction(const double net, const ae_int_t k, double &f, double &df, double &d2f);
void mlpprocess(const multilayerperceptron &network, const real_1d_array &x, real_1d_array &y);
void mlpprocessi(const multilayerperceptron &network, const real_1d_array &x, real_1d_array &y);
void mlpgrad(const multilayerperceptron &network, const real_1d_array &x, const real_1d_array &desiredy, double &e, real_1d_array &grad);
void mlpgradn(const multilayerperceptron &network, const real_1d_array &x, const real_1d_array &desiredy, double &e, real_1d_array &grad);
void mlpgradbatch(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t ssize, double &e, real_1d_array &grad);
void mlpgradbatchsparse(const multilayerperceptron &network, const sparsematrix &xy, const ae_int_t ssize, double &e, real_1d_array &grad);
void mlpgradbatchsubset(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t setsize, const integer_1d_array &idx, const ae_int_t subsetsize, double &e, real_1d_array &grad);
void mlpgradbatchsparsesubset(const multilayerperceptron &network, const sparsematrix &xy, const ae_int_t setsize, const integer_1d_array &idx, const ae_int_t subsetsize, double &e, real_1d_array &grad);
void mlpgradnbatch(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t ssize, double &e, real_1d_array &grad);
void mlphessiannbatch(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t ssize, double &e, real_1d_array &grad, real_2d_array &h);
void mlphessianbatch(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t ssize, double &e, real_1d_array &grad, real_2d_array &h);
ae_int_t mlpgetinputscount(const multilayerperceptron &network);
ae_int_t mlpgetoutputscount(const multilayerperceptron &network);
ae_int_t mlpgetweightscount(const multilayerperceptron &network);
ae_int_t mlpgetlayerscount(const multilayerperceptron &network);
ae_int_t mlpgetlayersize(const multilayerperceptron &network, const ae_int_t k);
void mlpgetinputscaling(const multilayerperceptron &network, const ae_int_t i, double &mean, double &sigma);
void mlpgetoutputscaling(const multilayerperceptron &network, const ae_int_t i, double &mean, double &sigma);
void mlpgetneuroninfo(const multilayerperceptron &network, const ae_int_t k, const ae_int_t i, ae_int_t &fkind, double &threshold);
double mlpgetweight(const multilayerperceptron &network, const ae_int_t k0, const ae_int_t i0, const ae_int_t k1, const ae_int_t i1);
void mlpsetinputscaling(const multilayerperceptron &network, const ae_int_t i, const double mean, const double sigma);
void mlpsetoutputscaling(const multilayerperceptron &network, const ae_int_t i, const double mean, const double sigma);
void mlpsetneuroninfo(const multilayerperceptron &network, const ae_int_t k, const ae_int_t i, const ae_int_t fkind, const double threshold);
void mlpsetweight(const multilayerperceptron &network, const ae_int_t k0, const ae_int_t i0, const ae_int_t k1, const ae_int_t i1, const double w);
void mlpcopy(const multilayerperceptron &network1, multilayerperceptron &network2);
void mlpcopytunableparameters(const multilayerperceptron &network1, const multilayerperceptron &network2);
void mlpinitpreprocessor(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t ssize);
double mlperror(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t npoints);
double mlperrorsparse(const multilayerperceptron &network, const sparsematrix &xy, const ae_int_t npoints);
double mlperrorn(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t ssize);
ae_int_t mlpclserror(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t npoints);
double mlprelclserror(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t npoints);
double mlprelclserrorsparse(const multilayerperceptron &network, const sparsematrix &xy, const ae_int_t npoints);
double mlpavgce(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t npoints);
double mlpavgcesparse(const multilayerperceptron &network, const sparsematrix &xy, const ae_int_t npoints);
double mlprmserror(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t npoints);
double mlprmserrorsparse(const multilayerperceptron &network, const sparsematrix &xy, const ae_int_t npoints);
double mlpavgerror(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t npoints);
double mlpavgerrorsparse(const multilayerperceptron &network, const sparsematrix &xy, const ae_int_t npoints);
double mlpavgrelerror(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t npoints);
double mlpavgrelerrorsparse(const multilayerperceptron &network, const sparsematrix &xy, const ae_int_t npoints);
void mlpallerrorssubset(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t setsize, const integer_1d_array &subset, const ae_int_t subsetsize, modelerrors &rep);
void mlpallerrorssparsesubset(const multilayerperceptron &network, const sparsematrix &xy, const ae_int_t setsize, const integer_1d_array &subset, const ae_int_t subsetsize, modelerrors &rep);
double mlperrorsubset(const multilayerperceptron &network, const real_2d_array &xy, const ae_int_t setsize, const integer_1d_array &subset, const ae_int_t subsetsize);
double mlperrorsparsesubset(const multilayerperceptron &network, const sparsematrix &xy, const ae_int_t setsize, const integer_1d_array &subset, const ae_int_t subsetsize);
} // end of namespace alglib
// === MLPE Package ===
// Depends on: MLPBASE
namespace alglib_impl {
struct mlpensemble {
ae_int_t ensemblesize;
ae_vector weights;
ae_vector columnmeans;
ae_vector columnsigmas;
multilayerperceptron network;
ae_vector y;
};
void mlpensemble_init(void *_p, bool make_automatic);
void mlpensemble_copy(void *_dst, const void *_src, bool make_automatic);
void mlpensemble_free(void *_p, bool make_automatic);
void mlpealloc(ae_serializer *s, mlpensemble *ensemble);
void mlpeserialize(ae_serializer *s, mlpensemble *ensemble);
void mlpeunserialize(ae_serializer *s, mlpensemble *ensemble);
void mlpecreatefromnetwork(multilayerperceptron *network, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecreate0(ae_int_t nin, ae_int_t nout, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecreate1(ae_int_t nin, ae_int_t nhid, ae_int_t nout, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecreate2(ae_int_t nin, ae_int_t nhid1, ae_int_t nhid2, ae_int_t nout, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecreateb0(ae_int_t nin, ae_int_t nout, double b, double d, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecreateb1(ae_int_t nin, ae_int_t nhid, ae_int_t nout, double b, double d, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecreateb2(ae_int_t nin, ae_int_t nhid1, ae_int_t nhid2, ae_int_t nout, double b, double d, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecreater0(ae_int_t nin, ae_int_t nout, double a, double b, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecreater1(ae_int_t nin, ae_int_t nhid, ae_int_t nout, double a, double b, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecreater2(ae_int_t nin, ae_int_t nhid1, ae_int_t nhid2, ae_int_t nout, double a, double b, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecreatec0(ae_int_t nin, ae_int_t nout, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecreatec1(ae_int_t nin, ae_int_t nhid, ae_int_t nout, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecreatec2(ae_int_t nin, ae_int_t nhid1, ae_int_t nhid2, ae_int_t nout, ae_int_t ensemblesize, mlpensemble *ensemble);
void mlpecopy(mlpensemble *ensemble1, mlpensemble *ensemble2);
void mlperandomize(mlpensemble *ensemble);
void mlpeproperties(mlpensemble *ensemble, ae_int_t *nin, ae_int_t *nout);
bool mlpeissoftmax(mlpensemble *ensemble);
void mlpeprocess(mlpensemble *ensemble, RVector *x, RVector *y);
void mlpeprocessi(mlpensemble *ensemble, RVector *x, RVector *y);
void mlpeallerrorsx(mlpensemble *ensemble, RMatrix *densexy, sparsematrix *sparsexy, ae_int_t datasetsize, ae_int_t datasettype, ZVector *idx, ae_int_t subset0, ae_int_t subset1, ae_int_t subsettype, ae_shared_pool *buf, modelerrors *rep);
void mlpeallerrorssparse(mlpensemble *ensemble, sparsematrix *xy, ae_int_t npoints, double *relcls, double *avgce, double *rms, double *avg, double *avgrel);
double mlperelclserror(mlpensemble *ensemble, RMatrix *xy, ae_int_t npoints);
double mlpeavgce(mlpensemble *ensemble, RMatrix *xy, ae_int_t npoints);
double mlpermserror(mlpensemble *ensemble, RMatrix *xy, ae_int_t npoints);
double mlpeavgerror(mlpensemble *ensemble, RMatrix *xy, ae_int_t npoints);
double mlpeavgrelerror(mlpensemble *ensemble, RMatrix *xy, ae_int_t npoints);
} // end of namespace alglib_impl
namespace alglib {
DecClass(mlpensemble, );
void mlpeserialize(mlpensemble &obj, std::string &s_out);
void mlpeserialize(mlpensemble &obj, std::ostream &s_out);
void mlpeunserialize(const std::string &s_in, mlpensemble &obj);
void mlpeunserialize(const std::istream &s_in, mlpensemble &obj);
void mlpecreatefromnetwork(const multilayerperceptron &network, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlpecreate0(const ae_int_t nin, const ae_int_t nout, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlpecreate1(const ae_int_t nin, const ae_int_t nhid, const ae_int_t nout, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlpecreate2(const ae_int_t nin, const ae_int_t nhid1, const ae_int_t nhid2, const ae_int_t nout, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlpecreateb0(const ae_int_t nin, const ae_int_t nout, const double b, const double d, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlpecreateb1(const ae_int_t nin, const ae_int_t nhid, const ae_int_t nout, const double b, const double d, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlpecreateb2(const ae_int_t nin, const ae_int_t nhid1, const ae_int_t nhid2, const ae_int_t nout, const double b, const double d, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlpecreater0(const ae_int_t nin, const ae_int_t nout, const double a, const double b, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlpecreater1(const ae_int_t nin, const ae_int_t nhid, const ae_int_t nout, const double a, const double b, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlpecreater2(const ae_int_t nin, const ae_int_t nhid1, const ae_int_t nhid2, const ae_int_t nout, const double a, const double b, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlpecreatec0(const ae_int_t nin, const ae_int_t nout, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlpecreatec1(const ae_int_t nin, const ae_int_t nhid, const ae_int_t nout, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlpecreatec2(const ae_int_t nin, const ae_int_t nhid1, const ae_int_t nhid2, const ae_int_t nout, const ae_int_t ensemblesize, mlpensemble &ensemble);
void mlperandomize(const mlpensemble &ensemble);
void mlpeproperties(const mlpensemble &ensemble, ae_int_t &nin, ae_int_t &nout);
bool mlpeissoftmax(const mlpensemble &ensemble);
void mlpeprocess(const mlpensemble &ensemble, const real_1d_array &x, real_1d_array &y);
void mlpeprocessi(const mlpensemble &ensemble, const real_1d_array &x, real_1d_array &y);
double mlperelclserror(const mlpensemble &ensemble, const real_2d_array &xy, const ae_int_t npoints);
double mlpeavgce(const mlpensemble &ensemble, const real_2d_array &xy, const ae_int_t npoints);
double mlpermserror(const mlpensemble &ensemble, const real_2d_array &xy, const ae_int_t npoints);
double mlpeavgerror(const mlpensemble &ensemble, const real_2d_array &xy, const ae_int_t npoints);
double mlpeavgrelerror(const mlpensemble &ensemble, const real_2d_array &xy, const ae_int_t npoints);
} // end of namespace alglib
// === CLUSTERING Package ===
// Depends on: (AlgLibInternal) BLAS
// Depends on: (AlgLibMisc) HQRND
// Depends on: (Statistics) BASESTAT
namespace alglib_impl {
struct kmeansbuffers {
ae_matrix ct;
ae_matrix ctbest;
ae_vector xycbest;
ae_vector xycprev;
ae_vector d2;
ae_vector csizes;
apbuffers initbuf;
ae_shared_pool updatepool;
};
void kmeansbuffers_init(void *_p, bool make_automatic);
void kmeansbuffers_copy(void *_dst, const void *_src, bool make_automatic);
void kmeansbuffers_free(void *_p, bool make_automatic);
struct clusterizerstate {
ae_int_t npoints;
ae_int_t nfeatures;
ae_int_t disttype;
ae_matrix xy;
ae_matrix d;
ae_int_t ahcalgo;
ae_int_t kmeansrestarts;
ae_int_t kmeansmaxits;
ae_int_t kmeansinitalgo;
bool kmeansdbgnoits;
ae_int_t seed;
ae_matrix tmpd;
apbuffers distbuf;
kmeansbuffers kmeanstmp;
};
void clusterizerstate_init(void *_p, bool make_automatic);
void clusterizerstate_copy(void *_dst, const void *_src, bool make_automatic);
void clusterizerstate_free(void *_p, bool make_automatic);
struct ahcreport {
ae_int_t terminationtype;
ae_int_t npoints;
ae_vector p;
ae_matrix z;
ae_matrix pz;
ae_matrix pm;
ae_vector mergedist;
};
void ahcreport_init(void *_p, bool make_automatic);
void ahcreport_copy(void *_dst, const void *_src, bool make_automatic);
void ahcreport_free(void *_p, bool make_automatic);
struct kmeansreport {
ae_int_t npoints;
ae_int_t nfeatures;
ae_int_t terminationtype;
ae_int_t iterationscount;
double energy;
ae_int_t k;
ae_matrix c;
ae_vector cidx;
};
void kmeansreport_init(void *_p, bool make_automatic);
void kmeansreport_copy(void *_dst, const void *_src, bool make_automatic);
void kmeansreport_free(void *_p, bool make_automatic);
void kmeansinitbuf(kmeansbuffers *buf);
void kmeansupdatedistances(RMatrix *xy, ae_int_t idx0, ae_int_t idx1, ae_int_t nvars, RMatrix *ct, ae_int_t cidx0, ae_int_t cidx1, ZVector *xyc, RVector *xydist2, ae_shared_pool *bufferpool);
void kmeansgenerateinternal(RMatrix *xy, ae_int_t npoints, ae_int_t nvars, ae_int_t k, ae_int_t initalgo, ae_int_t seed, ae_int_t maxits, ae_int_t restarts, bool kmeansdbgnoits, ae_int_t *info, ae_int_t *iterationscount, RMatrix *ccol, bool needccol, RMatrix *crow, bool needcrow, ZVector *xyc, double *energy, kmeansbuffers *buf);
void clusterizercreate(clusterizerstate *s);
void clusterizersetpoints(clusterizerstate *s, RMatrix *xy, ae_int_t npoints, ae_int_t nfeatures, ae_int_t disttype);
void clusterizersetdistances(clusterizerstate *s, RMatrix *d, ae_int_t npoints, bool isupper);
void clusterizersetahcalgo(clusterizerstate *s, ae_int_t algo);
void clusterizersetkmeanslimits(clusterizerstate *s, ae_int_t restarts, ae_int_t maxits);
void clusterizersetkmeansinit(clusterizerstate *s, ae_int_t initalgo);
void clusterizersetseed(clusterizerstate *s, ae_int_t seed);
void clusterizergetdistancesbuf(apbuffers *buf, RMatrix *xy, ae_int_t npoints, ae_int_t nfeatures, ae_int_t disttype, RMatrix *d);
void clusterizergetdistances(RMatrix *xy, ae_int_t npoints, ae_int_t nfeatures, ae_int_t disttype, RMatrix *d);
void clusterizerrunahc(clusterizerstate *s, ahcreport *rep);
void clusterizerrunkmeans(clusterizerstate *s, ae_int_t k, kmeansreport *rep);
void clusterizergetkclusters(ahcreport *rep, ae_int_t k, ZVector *cidx, ZVector *cz);
void clusterizerseparatedbydist(ahcreport *rep, double r, ae_int_t *k, ZVector *cidx, ZVector *cz);
void clusterizerseparatedbycorr(ahcreport *rep, double r, ae_int_t *k, ZVector *cidx, ZVector *cz);
} // end of namespace alglib_impl
namespace alglib {
DecClass(clusterizerstate, );
DecClass(ahcreport, ae_int_t &terminationtype; ae_int_t &npoints; integer_1d_array p; integer_2d_array z; integer_2d_array pz; integer_2d_array pm; real_1d_array mergedist;);
DecClass(kmeansreport, ae_int_t &npoints; ae_int_t &nfeatures; ae_int_t &terminationtype; ae_int_t &iterationscount; double &energy; ae_int_t &k; real_2d_array c; integer_1d_array cidx;);
void clusterizercreate(clusterizerstate &s);
void clusterizersetpoints(const clusterizerstate &s, const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nfeatures, const ae_int_t disttype);
void clusterizersetpoints(const clusterizerstate &s, const real_2d_array &xy, const ae_int_t disttype);
void clusterizersetdistances(const clusterizerstate &s, const real_2d_array &d, const ae_int_t npoints, const bool isupper);
void clusterizersetdistances(const clusterizerstate &s, const real_2d_array &d, const bool isupper);
void clusterizersetahcalgo(const clusterizerstate &s, const ae_int_t algo);
void clusterizersetkmeanslimits(const clusterizerstate &s, const ae_int_t restarts, const ae_int_t maxits);
void clusterizersetkmeansinit(const clusterizerstate &s, const ae_int_t initalgo);
void clusterizersetseed(const clusterizerstate &s, const ae_int_t seed);
void clusterizergetdistances(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nfeatures, const ae_int_t disttype, real_2d_array &d);
void clusterizerrunahc(const clusterizerstate &s, ahcreport &rep);
void clusterizerrunkmeans(const clusterizerstate &s, const ae_int_t k, kmeansreport &rep);
void clusterizergetkclusters(const ahcreport &rep, const ae_int_t k, integer_1d_array &cidx, integer_1d_array &cz);
void clusterizerseparatedbydist(const ahcreport &rep, const double r, ae_int_t &k, integer_1d_array &cidx, integer_1d_array &cz);
void clusterizerseparatedbycorr(const ahcreport &rep, const double r, ae_int_t &k, integer_1d_array &cidx, integer_1d_array &cz);
} // end of namespace alglib
// === DFOREST Package ===
// Depends on: (AlgLibInternal) SCODES
// Depends on: (AlgLibMisc) HQRND
// Depends on: BDSS
namespace alglib_impl {
struct decisionforestbuilder {
ae_int_t dstype;
ae_int_t npoints;
ae_int_t nvars;
ae_int_t nclasses;
ae_vector dsdata;
ae_vector dsrval;
ae_vector dsival;
ae_int_t rdfalgo;
double rdfratio;
double rdfvars;
ae_int_t rdfglobalseed;
ae_int_t rdfsplitstrength;
ae_int_t rdfimportance;
ae_vector dsmin;
ae_vector dsmax;
ae_vector dsbinary;
double dsravg;
ae_vector dsctotals;
ae_int_t rdfprogress;
ae_int_t rdftotal;
ae_shared_pool workpool;
ae_shared_pool votepool;
ae_shared_pool treepool;
ae_shared_pool treefactory;
bool neediobmatrix;
ae_matrix iobmatrix;
ae_vector varimpshuffle2;
};
void decisionforestbuilder_init(void *_p, bool make_automatic);
void decisionforestbuilder_copy(void *_dst, const void *_src, bool make_automatic);
void decisionforestbuilder_free(void *_p, bool make_automatic);
struct dfworkbuf {
ae_vector classpriors;
ae_vector varpool;
ae_int_t varpoolsize;
ae_vector trnset;
ae_int_t trnsize;
ae_vector trnlabelsr;
ae_vector trnlabelsi;
ae_vector oobset;
ae_int_t oobsize;
ae_vector ooblabelsr;
ae_vector ooblabelsi;
ae_vector treebuf;
ae_vector curvals;
ae_vector bestvals;
ae_vector tmp0i;
ae_vector tmp1i;
ae_vector tmp0r;
ae_vector tmp1r;
ae_vector tmp2r;
ae_vector tmp3r;
ae_vector tmpnrms2;
ae_vector classtotals0;
ae_vector classtotals1;
ae_vector classtotals01;
};
void dfworkbuf_init(void *_p, bool make_automatic);
void dfworkbuf_copy(void *_dst, const void *_src, bool make_automatic);
void dfworkbuf_free(void *_p, bool make_automatic);
struct dfvotebuf {
ae_vector trntotals;
ae_vector oobtotals;
ae_vector trncounts;
ae_vector oobcounts;
ae_vector giniimportances;
};
void dfvotebuf_init(void *_p, bool make_automatic);
void dfvotebuf_copy(void *_dst, const void *_src, bool make_automatic);
void dfvotebuf_free(void *_p, bool make_automatic);
struct dfpermimpbuf {
ae_vector losses;
ae_vector xraw;
ae_vector xdist;
ae_vector xcur;
ae_vector y;
ae_vector yv;
ae_vector targety;
ae_vector startnodes;
};
void dfpermimpbuf_init(void *_p, bool make_automatic);
void dfpermimpbuf_copy(void *_dst, const void *_src, bool make_automatic);
void dfpermimpbuf_free(void *_p, bool make_automatic);
struct dftreebuf {
ae_vector treebuf;
ae_int_t treeidx;
};
void dftreebuf_init(void *_p, bool make_automatic);
void dftreebuf_copy(void *_dst, const void *_src, bool make_automatic);
void dftreebuf_free(void *_p, bool make_automatic);
struct decisionforestbuffer {
ae_vector x;
ae_vector y;
};
void decisionforestbuffer_init(void *_p, bool make_automatic);
void decisionforestbuffer_copy(void *_dst, const void *_src, bool make_automatic);
void decisionforestbuffer_free(void *_p, bool make_automatic);
struct decisionforest {
ae_int_t forestformat;
bool usemantissa8;
ae_int_t nvars;
ae_int_t nclasses;
ae_int_t ntrees;
ae_int_t bufsize;
ae_vector trees;
decisionforestbuffer buffer;
ae_vector trees8;
};
void decisionforest_init(void *_p, bool make_automatic);
void decisionforest_copy(void *_dst, const void *_src, bool make_automatic);
void decisionforest_free(void *_p, bool make_automatic);
void dfalloc(ae_serializer *s, decisionforest *forest);
void dfserialize(ae_serializer *s, decisionforest *forest);
void dfunserialize(ae_serializer *s, decisionforest *forest);
struct dfreport {
double relclserror;
double avgce;
double rmserror;
double avgerror;
double avgrelerror;
double oobrelclserror;
double oobavgce;
double oobrmserror;
double oobavgerror;
double oobavgrelerror;
ae_vector topvars;
ae_vector varimportances;
};
void dfreport_init(void *_p, bool make_automatic);
void dfreport_copy(void *_dst, const void *_src, bool make_automatic);
void dfreport_free(void *_p, bool make_automatic);
struct dfinternalbuffers {
ae_vector treebuf;
ae_vector idxbuf;
ae_vector tmpbufr;
ae_vector tmpbufr2;
ae_vector tmpbufi;
ae_vector classibuf;
ae_vector sortrbuf;
ae_vector sortrbuf2;
ae_vector sortibuf;
ae_vector varpool;
ae_vector evsbin;
ae_vector evssplits;
};
void dfinternalbuffers_init(void *_p, bool make_automatic);
void dfinternalbuffers_copy(void *_dst, const void *_src, bool make_automatic);
void dfinternalbuffers_free(void *_p, bool make_automatic);
void dfcreatebuffer(decisionforest *model, decisionforestbuffer *buf);
void dfbuildercreate(decisionforestbuilder *s);
void dfbuildersetdataset(decisionforestbuilder *s, RMatrix *xy, ae_int_t npoints, ae_int_t nvars, ae_int_t nclasses);
void dfbuildersetrndvars(decisionforestbuilder *s, ae_int_t rndvars);
void dfbuildersetrndvarsratio(decisionforestbuilder *s, double f);
void dfbuildersetrndvarsauto(decisionforestbuilder *s);
void dfbuildersetsubsampleratio(decisionforestbuilder *s, double f);
void dfbuildersetseed(decisionforestbuilder *s, ae_int_t seedval);
void dfbuildersetrdfalgo(decisionforestbuilder *s, ae_int_t algotype);
void dfbuildersetrdfsplitstrength(decisionforestbuilder *s, ae_int_t splitstrength);
void dfbuildersetimportancetrngini(decisionforestbuilder *s);
void dfbuildersetimportanceoobgini(decisionforestbuilder *s);
void dfbuildersetimportancepermutation(decisionforestbuilder *s);
void dfbuildersetimportancenone(decisionforestbuilder *s);
double dfbuilderpeekprogress(decisionforestbuilder *s);
double dfbuildergetprogress(decisionforestbuilder *s);
void dfbuilderbuildrandomforest(decisionforestbuilder *s, ae_int_t ntrees, decisionforest *df, dfreport *rep);
double dfbinarycompression(decisionforest *df);
double dfbinarycompression8(decisionforest *df);
void dfprocess(decisionforest *df, RVector *x, RVector *y);
void dfprocessi(decisionforest *df, RVector *x, RVector *y);
double dfprocess0(decisionforest *model, RVector *x);
ae_int_t dfclassify(decisionforest *model, RVector *x);
void dftsprocess(decisionforest *df, decisionforestbuffer *buf, RVector *x, RVector *y);
double dfrelclserror(decisionforest *df, RMatrix *xy, ae_int_t npoints);
double dfavgce(decisionforest *df, RMatrix *xy, ae_int_t npoints);
double dfrmserror(decisionforest *df, RMatrix *xy, ae_int_t npoints);
double dfavgerror(decisionforest *df, RMatrix *xy, ae_int_t npoints);
double dfavgrelerror(decisionforest *df, RMatrix *xy, ae_int_t npoints);
void dfcopy(decisionforest *df1, decisionforest *df2);
void dfbuildinternal(RMatrix *xy, ae_int_t npoints, ae_int_t nvars, ae_int_t nclasses, ae_int_t ntrees, ae_int_t samplesize, ae_int_t nfeatures, ae_int_t flags, ae_int_t *info, decisionforest *df, dfreport *rep);
void dfbuildrandomdecisionforest(RMatrix *xy, ae_int_t npoints, ae_int_t nvars, ae_int_t nclasses, ae_int_t ntrees, double r, ae_int_t *info, decisionforest *df, dfreport *rep);
void dfbuildrandomdecisionforestx1(RMatrix *xy, ae_int_t npoints, ae_int_t nvars, ae_int_t nclasses, ae_int_t ntrees, ae_int_t nrndvars, double r, ae_int_t *info, decisionforest *df, dfreport *rep);
} // end of namespace alglib_impl
namespace alglib {
DecClass(decisionforestbuilder, );
DecClass(decisionforestbuffer, );
DecClass(decisionforest, );
DecClass(dfreport, double &relclserror; double &avgce; double &rmserror; double &avgerror; double &avgrelerror; double &oobrelclserror; double &oobavgce; double &oobrmserror; double &oobavgerror; double &oobavgrelerror; integer_1d_array topvars; real_1d_array varimportances;);
void dfserialize(decisionforest &obj, std::string &s_out);
void dfserialize(decisionforest &obj, std::ostream &s_out);
void dfunserialize(const std::string &s_in, decisionforest &obj);
void dfunserialize(const std::istream &s_in, decisionforest &obj);
void dfcreatebuffer(const decisionforest &model, decisionforestbuffer &buf);
void dfbuildercreate(decisionforestbuilder &s);
void dfbuildersetdataset(const decisionforestbuilder &s, const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nvars, const ae_int_t nclasses);
void dfbuildersetrndvars(const decisionforestbuilder &s, const ae_int_t rndvars);
void dfbuildersetrndvarsratio(const decisionforestbuilder &s, const double f);
void dfbuildersetrndvarsauto(const decisionforestbuilder &s);
void dfbuildersetsubsampleratio(const decisionforestbuilder &s, const double f);
void dfbuildersetseed(const decisionforestbuilder &s, const ae_int_t seedval);
void dfbuildersetrdfalgo(const decisionforestbuilder &s, const ae_int_t algotype);
void dfbuildersetrdfsplitstrength(const decisionforestbuilder &s, const ae_int_t splitstrength);
void dfbuildersetimportancetrngini(const decisionforestbuilder &s);
void dfbuildersetimportanceoobgini(const decisionforestbuilder &s);
void dfbuildersetimportancepermutation(const decisionforestbuilder &s);
void dfbuildersetimportancenone(const decisionforestbuilder &s);
double dfbuilderpeekprogress(const decisionforestbuilder &s);
double dfbuildergetprogress(const decisionforestbuilder &s);
void dfbuilderbuildrandomforest(const decisionforestbuilder &s, const ae_int_t ntrees, decisionforest &df, dfreport &rep);
double dfbinarycompression(const decisionforest &df);
void dfprocess(const decisionforest &df, const real_1d_array &x, real_1d_array &y);
void dfprocessi(const decisionforest &df, const real_1d_array &x, real_1d_array &y);
double dfprocess0(const decisionforest &model, const real_1d_array &x);
ae_int_t dfclassify(const decisionforest &model, const real_1d_array &x);
void dftsprocess(const decisionforest &df, const decisionforestbuffer &buf, const real_1d_array &x, real_1d_array &y);
double dfrelclserror(const decisionforest &df, const real_2d_array &xy, const ae_int_t npoints);
double dfavgce(const decisionforest &df, const real_2d_array &xy, const ae_int_t npoints);
double dfrmserror(const decisionforest &df, const real_2d_array &xy, const ae_int_t npoints);
double dfavgerror(const decisionforest &df, const real_2d_array &xy, const ae_int_t npoints);
double dfavgrelerror(const decisionforest &df, const real_2d_array &xy, const ae_int_t npoints);
void dfbuildrandomdecisionforest(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nvars, const ae_int_t nclasses, const ae_int_t ntrees, const double r, ae_int_t &info, decisionforest &df, dfreport &rep);
void dfbuildrandomdecisionforestx1(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nvars, const ae_int_t nclasses, const ae_int_t ntrees, const ae_int_t nrndvars, const double r, ae_int_t &info, decisionforest &df, dfreport &rep);
} // end of namespace alglib
// === LINREG Package ===
// Depends on: (SpecialFunctions) IGAMMAF
// Depends on: (LinAlg) SVD
// Depends on: (Statistics) BASESTAT
namespace alglib_impl {
struct linearmodel {
ae_vector w;
};
void linearmodel_init(void *_p, bool make_automatic);
void linearmodel_copy(void *_dst, const void *_src, bool make_automatic);
void linearmodel_free(void *_p, bool make_automatic);
struct lrreport {
ae_matrix c;
double rmserror;
double avgerror;
double avgrelerror;
double cvrmserror;
double cvavgerror;
double cvavgrelerror;
ae_int_t ncvdefects;
ae_vector cvdefects;
};
void lrreport_init(void *_p, bool make_automatic);
void lrreport_copy(void *_dst, const void *_src, bool make_automatic);
void lrreport_free(void *_p, bool make_automatic);
double lrrmserror(linearmodel *lm, RMatrix *xy, ae_int_t npoints);
double lravgerror(linearmodel *lm, RMatrix *xy, ae_int_t npoints);
double lravgrelerror(linearmodel *lm, RMatrix *xy, ae_int_t npoints);
void lrbuilds(RMatrix *xy, RVector *s, ae_int_t npoints, ae_int_t nvars, ae_int_t *info, linearmodel *lm, lrreport *ar);
void lrbuild(RMatrix *xy, ae_int_t npoints, ae_int_t nvars, ae_int_t *info, linearmodel *lm, lrreport *ar);
void lrbuildzs(RMatrix *xy, RVector *s, ae_int_t npoints, ae_int_t nvars, ae_int_t *info, linearmodel *lm, lrreport *ar);
void lrbuildz(RMatrix *xy, ae_int_t npoints, ae_int_t nvars, ae_int_t *info, linearmodel *lm, lrreport *ar);
void lrunpack(linearmodel *lm, RVector *v, ae_int_t *nvars);
void lrpack(RVector *v, ae_int_t nvars, linearmodel *lm);
double lrprocess(linearmodel *lm, RVector *x);
void lrcopy(linearmodel *lm1, linearmodel *lm2);
void lrlines(RMatrix *xy, RVector *s, ae_int_t n, ae_int_t *info, double *a, double *b, double *vara, double *varb, double *covab, double *corrab, double *p);
void lrline(RMatrix *xy, ae_int_t n, ae_int_t *info, double *a, double *b);
} // end of namespace alglib_impl
namespace alglib {
DecClass(linearmodel, );
DecClass(lrreport, real_2d_array c; double &rmserror; double &avgerror; double &avgrelerror; double &cvrmserror; double &cvavgerror; double &cvavgrelerror; ae_int_t &ncvdefects; integer_1d_array cvdefects;);
double lrrmserror(const linearmodel &lm, const real_2d_array &xy, const ae_int_t npoints);
double lravgerror(const linearmodel &lm, const real_2d_array &xy, const ae_int_t npoints);
double lravgrelerror(const linearmodel &lm, const real_2d_array &xy, const ae_int_t npoints);
void lrbuilds(const real_2d_array &xy, const real_1d_array &s, const ae_int_t npoints, const ae_int_t nvars, ae_int_t &info, linearmodel &lm, lrreport &ar);
void lrbuild(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nvars, ae_int_t &info, linearmodel &lm, lrreport &ar);
void lrbuildzs(const real_2d_array &xy, const real_1d_array &s, const ae_int_t npoints, const ae_int_t nvars, ae_int_t &info, linearmodel &lm, lrreport &ar);
void lrbuildz(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nvars, ae_int_t &info, linearmodel &lm, lrreport &ar);
void lrunpack(const linearmodel &lm, real_1d_array &v, ae_int_t &nvars);
void lrpack(const real_1d_array &v, const ae_int_t nvars, linearmodel &lm);
double lrprocess(const linearmodel &lm, const real_1d_array &x);
} // end of namespace alglib
// === FILTERS Package ===
// Depends on: LINREG
namespace alglib_impl {
void filtersma(RVector *x, ae_int_t n, ae_int_t k);
void filterema(RVector *x, ae_int_t n, double alpha);
void filterlrma(RVector *x, ae_int_t n, ae_int_t k);
} // end of namespace alglib_impl
namespace alglib {
void filtersma(real_1d_array &x, const ae_int_t n, const ae_int_t k);
void filtersma(real_1d_array &x, const ae_int_t k);
void filterema(real_1d_array &x, const ae_int_t n, const double alpha);
void filterema(real_1d_array &x, const double alpha);
void filterlrma(real_1d_array &x, const ae_int_t n, const ae_int_t k);
void filterlrma(real_1d_array &x, const ae_int_t k);
} // end of namespace alglib
// === SSA Package ===
// Depends on: (LinAlg) EVD, SVD
namespace alglib_impl {
struct ssamodel {
ae_int_t nsequences;
ae_vector sequenceidx;
ae_vector sequencedata;
ae_int_t algotype;
ae_int_t windowwidth;
ae_int_t rtpowerup;
ae_int_t topk;
ae_int_t precomputedwidth;
ae_int_t precomputednbasis;
ae_matrix precomputedbasis;
ae_int_t defaultsubspaceits;
ae_int_t memorylimit;
bool arebasisandsolvervalid;
ae_matrix basis;
ae_matrix basist;
ae_vector sv;
ae_vector forecasta;
ae_int_t nbasis;
eigsubspacestate solver;
ae_matrix xxt;
hqrndstate rs;
ae_int_t rngseed;
ae_vector rtqueue;
ae_int_t rtqueuecnt;
ae_int_t rtqueuechunk;
ae_int_t dbgcntevd;
ae_vector tmp0;
ae_vector tmp1;
eigsubspacereport solverrep;
ae_vector alongtrend;
ae_vector alongnoise;
ae_matrix aseqtrajectory;
ae_matrix aseqtbproduct;
ae_vector aseqcounts;
ae_vector fctrend;
ae_vector fcnoise;
ae_matrix fctrendm;
ae_matrix uxbatch;
ae_int_t uxbatchwidth;
ae_int_t uxbatchsize;
ae_int_t uxbatchlimit;
};
void ssamodel_init(void *_p, bool make_automatic);
void ssamodel_copy(void *_dst, const void *_src, bool make_automatic);
void ssamodel_free(void *_p, bool make_automatic);
void ssacreate(ssamodel *s);
void ssasetwindow(ssamodel *s, ae_int_t windowwidth);
void ssasetseed(ssamodel *s, ae_int_t seed);
void ssasetpoweruplength(ssamodel *s, ae_int_t pwlen);
void ssasetmemorylimit(ssamodel *s, ae_int_t memlimit);
void ssaaddsequence(ssamodel *s, RVector *x, ae_int_t n);
void ssaappendpointandupdate(ssamodel *s, double x, double updateits);
void ssaappendsequenceandupdate(ssamodel *s, RVector *x, ae_int_t nticks, double updateits);
void ssasetalgoprecomputed(ssamodel *s, RMatrix *a, ae_int_t windowwidth, ae_int_t nbasis);
void ssasetalgotopkdirect(ssamodel *s, ae_int_t topk);
void ssasetalgotopkrealtime(ssamodel *s, ae_int_t topk);
void ssacleardata(ssamodel *s);
void ssagetbasis(ssamodel *s, RMatrix *a, RVector *sv, ae_int_t *windowwidth, ae_int_t *nbasis);
void ssagetlrr(ssamodel *s, RVector *a, ae_int_t *windowwidth);
void ssaanalyzelastwindow(ssamodel *s, RVector *trend, RVector *noise, ae_int_t *nticks);
void ssaanalyzelast(ssamodel *s, ae_int_t nticks, RVector *trend, RVector *noise);
void ssaanalyzesequence(ssamodel *s, RVector *data, ae_int_t nticks, RVector *trend, RVector *noise);
void ssaforecastlast(ssamodel *s, ae_int_t nticks, RVector *trend);
void ssaforecastsequence(ssamodel *s, RVector *data, ae_int_t datalen, ae_int_t forecastlen, bool applysmoothing, RVector *trend);
void ssaforecastavglast(ssamodel *s, ae_int_t m, ae_int_t nticks, RVector *trend);
void ssaforecastavgsequence(ssamodel *s, RVector *data, ae_int_t datalen, ae_int_t m, ae_int_t forecastlen, bool applysmoothing, RVector *trend);
} // end of namespace alglib_impl
namespace alglib {
DecClass(ssamodel, );
void ssacreate(ssamodel &s);
void ssasetwindow(const ssamodel &s, const ae_int_t windowwidth);
void ssasetseed(const ssamodel &s, const ae_int_t seed);
void ssasetpoweruplength(const ssamodel &s, const ae_int_t pwlen);
void ssasetmemorylimit(const ssamodel &s, const ae_int_t memlimit);
void ssaaddsequence(const ssamodel &s, const real_1d_array &x, const ae_int_t n);
void ssaaddsequence(const ssamodel &s, const real_1d_array &x);
void ssaappendpointandupdate(const ssamodel &s, const double x, const double updateits);
void ssaappendsequenceandupdate(const ssamodel &s, const real_1d_array &x, const ae_int_t nticks, const double updateits);
void ssaappendsequenceandupdate(const ssamodel &s, const real_1d_array &x, const double updateits);
void ssasetalgoprecomputed(const ssamodel &s, const real_2d_array &a, const ae_int_t windowwidth, const ae_int_t nbasis);
void ssasetalgoprecomputed(const ssamodel &s, const real_2d_array &a);
void ssasetalgotopkdirect(const ssamodel &s, const ae_int_t topk);
void ssasetalgotopkrealtime(const ssamodel &s, const ae_int_t topk);
void ssacleardata(const ssamodel &s);
void ssagetbasis(const ssamodel &s, real_2d_array &a, real_1d_array &sv, ae_int_t &windowwidth, ae_int_t &nbasis);
void ssagetlrr(const ssamodel &s, real_1d_array &a, ae_int_t &windowwidth);
void ssaanalyzelastwindow(const ssamodel &s, real_1d_array &trend, real_1d_array &noise, ae_int_t &nticks);
void ssaanalyzelast(const ssamodel &s, const ae_int_t nticks, real_1d_array &trend, real_1d_array &noise);
void ssaanalyzesequence(const ssamodel &s, const real_1d_array &data, const ae_int_t nticks, real_1d_array &trend, real_1d_array &noise);
void ssaanalyzesequence(const ssamodel &s, const real_1d_array &data, real_1d_array &trend, real_1d_array &noise);
void ssaforecastlast(const ssamodel &s, const ae_int_t nticks, real_1d_array &trend);
void ssaforecastsequence(const ssamodel &s, const real_1d_array &data, const ae_int_t datalen, const ae_int_t forecastlen, const bool applysmoothing, real_1d_array &trend);
void ssaforecastsequence(const ssamodel &s, const real_1d_array &data, const ae_int_t forecastlen, real_1d_array &trend);
void ssaforecastavglast(const ssamodel &s, const ae_int_t m, const ae_int_t nticks, real_1d_array &trend);
void ssaforecastavgsequence(const ssamodel &s, const real_1d_array &data, const ae_int_t datalen, const ae_int_t m, const ae_int_t forecastlen, const bool applysmoothing, real_1d_array &trend);
void ssaforecastavgsequence(const ssamodel &s, const real_1d_array &data, const ae_int_t m, const ae_int_t forecastlen, real_1d_array &trend);
} // end of namespace alglib
// === LDA Package ===
// Depends on: (LinAlg) EVD, MATINV
namespace alglib_impl {
void fisherldan(RMatrix *xy, ae_int_t npoints, ae_int_t nvars, ae_int_t nclasses, ae_int_t *info, RMatrix *w);
void fisherlda(RMatrix *xy, ae_int_t npoints, ae_int_t nvars, ae_int_t nclasses, ae_int_t *info, RVector *w);
} // end of namespace alglib_impl
namespace alglib {
void fisherldan(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nvars, const ae_int_t nclasses, ae_int_t &info, real_2d_array &w);
void fisherlda(const real_2d_array &xy, const ae_int_t npoints, const ae_int_t nvars, const ae_int_t nclasses, ae_int_t &info, real_1d_array &w);
} // end of namespace alglib
// === MCPD Package ===
// Depends on: (Optimization) MINBLEIC
namespace alglib_impl {
struct mcpdstate {
ae_int_t n;
ae_vector states;
ae_int_t npairs;
ae_matrix data;
ae_matrix ec;
ae_matrix bndl;
ae_matrix bndu;
ae_matrix c;
ae_vector ct;
ae_int_t ccnt;
ae_vector pw;
ae_matrix priorp;
double regterm;
minbleicstate bs;
ae_int_t repinneriterationscount;
ae_int_t repouteriterationscount;
ae_int_t repnfev;
ae_int_t repterminationtype;
minbleicreport br;
ae_vector tmpp;
ae_vector effectivew;
ae_vector effectivebndl;
ae_vector effectivebndu;
ae_matrix effectivec;
ae_vector effectivect;
ae_vector h;
ae_matrix p;
};
void mcpdstate_init(void *_p, bool make_automatic);
void mcpdstate_copy(void *_dst, const void *_src, bool make_automatic);
void mcpdstate_free(void *_p, bool make_automatic);
struct mcpdreport {
ae_int_t inneriterationscount;
ae_int_t outeriterationscount;
ae_int_t nfev;
ae_int_t terminationtype;
};
void mcpdreport_init(void *_p, bool make_automatic);
void mcpdreport_copy(void *_dst, const void *_src, bool make_automatic);
void mcpdreport_free(void *_p, bool make_automatic);
void mcpdcreate(ae_int_t n, mcpdstate *s);
void mcpdcreateentry(ae_int_t n, ae_int_t entrystate, mcpdstate *s);
void mcpdcreateexit(ae_int_t n, ae_int_t exitstate, mcpdstate *s);
void mcpdcreateentryexit(ae_int_t n, ae_int_t entrystate, ae_int_t exitstate, mcpdstate *s);
void mcpdaddtrack(mcpdstate *s, RMatrix *xy, ae_int_t k);
void mcpdsetec(mcpdstate *s, RMatrix *ec);
void mcpdaddec(mcpdstate *s, ae_int_t i, ae_int_t j, double c);
void mcpdsetbc(mcpdstate *s, RMatrix *bndl, RMatrix *bndu);
void mcpdaddbc(mcpdstate *s, ae_int_t i, ae_int_t j, double bndl, double bndu);
void mcpdsetlc(mcpdstate *s, RMatrix *c, ZVector *ct, ae_int_t k);
void mcpdsettikhonovregularizer(mcpdstate *s, double v);
void mcpdsetprior(mcpdstate *s, RMatrix *pp);
void mcpdsetpredictionweights(mcpdstate *s, RVector *pw);
void mcpdsolve(mcpdstate *s);
void mcpdresults(mcpdstate *s, RMatrix *p, mcpdreport *rep);
} // end of namespace alglib_impl
namespace alglib {
DecClass(mcpdstate, );
DecClass(mcpdreport, ae_int_t &inneriterationscount; ae_int_t &outeriterationscount; ae_int_t &nfev; ae_int_t &terminationtype;);
void mcpdcreate(const ae_int_t n, mcpdstate &s);
void mcpdcreateentry(const ae_int_t n, const ae_int_t entrystate, mcpdstate &s);
void mcpdcreateexit(const ae_int_t n, const ae_int_t exitstate, mcpdstate &s);
void mcpdcreateentryexit(const ae_int_t n, const ae_int_t entrystate, const ae_int_t exitstate, mcpdstate &s);
void mcpdaddtrack(const mcpdstate &s, const real_2d_array &xy, const ae_int_t k);
void mcpdaddtrack(const mcpdstate &s, const real_2d_array &xy);
void mcpdsetec(const mcpdstate &s, const real_2d_array &ec);
void mcpdaddec(const mcpdstate &s, const ae_int_t i, const ae_int_t j, const double c);
void mcpdsetbc(const mcpdstate &s, const real_2d_array &bndl, const real_2d_array &bndu);
void mcpdaddbc(const mcpdstate &s, const ae_int_t i, const ae_int_t j, const double bndl, const double bndu);
void mcpdsetlc(const mcpdstate &s, const real_2d_array &c, const integer_1d_array &ct, const ae_int_t k);
void mcpdsetlc(const mcpdstate &s, const real_2d_array &c, const integer_1d_array &ct);
void mcpdsettikhonovregularizer(const mcpdstate &s, const double v);
void mcpdsetprior(const mcpdstate &s, const real_2d_array &pp);
void mcpdsetpredictionweights(const mcpdstate &s, const real_1d_array &pw);
void mcpdsolve(const mcpdstate &s);
void mcpdresults(const mcpdstate &s, real_2d_array &p, mcpdreport &rep);
} // end of namespace alglib
// === LOGIT Package ===
// Depends on: (Solvers) DIRECTDENSESOLVERS
// Depends on: MLPBASE
namespace alglib_impl {
struct logitmodel {
ae_vector w;
};
void logitmodel_init(void *_p, bool make_automatic);
void logitmodel_copy(void *_dst, const void *_src, bool make_automatic);
void logitmodel_free(void *_p, bool make_automatic);
struct logitmcstate {
bool brackt;
bool stage1;
ae_int_t infoc;
double dg;
double dgm;
double dginit;
double dgtest;
double dgx;