-
Notifications
You must be signed in to change notification settings - Fork 24
/
trainhmmst.cpp
1619 lines (1498 loc) · 72.1 KB
/
trainhmmst.cpp
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
/*
Copyright (c) 2012-2017, Michael (Mikhail) Yudelson
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Michael (Mikhail) Yudelson nor the
names of other contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <string>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <map>
#include <list>
#include "utilsSt.h"
#include "InputUtilSt.h"
#include "HMMProblemSt.h"
////#include "HMMProblemPiG.h"
//#include "HMMProblemPiGK.h"
//#include "HMMProblemPiGKww.h"
//#include "HMMProblemAGK.h"
////#include "HMMProblemAGKi.h"
//#include "HMMProblemPiAGK.h"
//#include "HMMProblemPiABGK.h"
////#include "HMMProblemKT.h"
//#include "HMMProblemSlicedAB.h"
//#include "HMMProblemSlicedA.h"
//#include "StripedArray.h"
//#include "HMMProblemComp.h"
//#include "HMMProblemEloK.h"
#include "HMMProblemEloSt.h"
//#include "SparseArray2D.h"
//#include <boost/numeric/ublas/matrix_sparse.hpp>//BOOST
//#include <boost/numeric/ublas/io.hpp>//BOOST
using namespace std;
struct task task;
void exit_with_help();
void parse_arguments_step1(int argc, char **argv, char *input_file_name, char *output_file_name, char *predict_file_name, char *console_file_name); // things that do not need data file read
void parse_arguments_step2(int argc, char **argv, FILE *fid_console); // things that do need data file read, namely, number of observations
bool read_and_structure_data(const char *filename, FILE *fid_console);
NUMBER cross_validate(NUMBER* metrics, const char *filename, const char *model_file_name, clock_t *tm_fit, clock_t *tm_predict, FILE *fid_console);//SEQ
NUMBER cross_validate_item(NUMBER* metrics, const char *filename, const char *model_file_name, clock_t *tm_fit, clock_t *tm_predict, FILE *fid_console);//SEQ
NUMBER cross_validate_nstrat(NUMBER* metrics, const char *filename, const char *model_file_name, clock_t *tm_fit, clock_t *tm_predict, FILE *fid_console);//SEQ
//NUMBER cross_validate(NUMBER* metrics, const char *filename, const char *model_file_name, double *tm_fit, double *tm_predict, FILE *fid_console);//PAR
//NUMBER cross_validate_item(NUMBER* metrics, const char *filename, const char *model_file_name, double *tm_fit, double *tm_predict, FILE *fid_console);//PAR
//NUMBER cross_validate_nstrat(NUMBER* metrics, const char *filename, const char *model_file_name, double *tm_fit, double *tm_predict, FILE *fid_console);//PAR
static int max_line_length;
static char * line;
static char* readline(FILE *fid) {
int length = 0;
if(fgets(line,max_line_length,fid) == NULL)
return NULL;
while(strrchr(line,'\n') == NULL && strrchr(line,'\r') == NULL) // do take both line endings
{
max_line_length *= 2;
line = (char *) realloc(line, (size_t)max_line_length);
length = (int) strlen(line);
if(fgets(line+length,max_line_length-length,fid) == NULL)
break;
}
return line;
}
// temporary experimental: IRT-like for fitting pLo in liblinear
/*
void write_pLo_irt() {
FILE *fid0 = fopen("uopx12_irt.txt","w");
NPAR **group_skill_mask = init2D<NPAR>(task.nG, task.nK);
NCAT g_k, g, k;
NDAT t;
data *dat;
NPAR obs;
for(g=0; g<task.nG; g++) {
g_k = task.g_numk[g];
for(k=0; k<g_k; k++) {
dat = task.g_k_data[g][ k ];
t = dat->ix[0];
NCAT *ar;
int n = 0;
if(task.multiskill==0) {
k = task.dat_skill[t];
ar = &k;
n = 1;
} else {
// ar = &task.dat_multiskill->get(t)[1];
// n = task.dat_multiskill->get(t)[0];
k = task.dat_skill_stacked[ task.dat_skill_rix[t] ];
ar = &task.dat_skill_stacked[ task.dat_skill_rix[t] ];
n = task.dat_skill_rcount[t];
qsortNcat(ar, (NPAR)n);
}
obs = task.dat_obs[ dat->ix[0] ]; //->get( dat->ix[0] );
NPAR count = 0; // 557687 >> 499117
for(int l=0; l<n; l++) {
count = (NPAR)(count + (group_skill_mask[g][ ar[l] ] == 1));
if(count<n) {
fprintf(fid0,"%s %u:1", ((1-obs)==0)?"-1":"+1",dat->g+1);
for(int l=0; l<n; l++) {
fprintf(fid0, " %u:1",ar[l]+task.nG+1);
group_skill_mask[g][ ar[l] ] = 1;
}
fprintf(fid0,"\n");
}
}
}
}
fclose(fid0);
free2D(group_skill_mask, task.nG);
}*/
int main (int argc, char ** argv) {
clock_t tm_all = clock();//overall time //SEQ
// double _tm_all = omp_get_wtime(); //PAR
char input_file[1024]; // data
char output_file[1024]; // model
char colsole_file[1024]; // console copy
char predict_file[1024]; // predictions
set_task_defaults(&task);
// parse parameters, step 1
parse_arguments_step1(argc, argv, input_file, output_file, predict_file, colsole_file);
FILE *fid_console = NULL;
if(task.duplicate_console==1)
fid_console = fopen(colsole_file,"w");
if(!task.quiet) {
printf("trainhmmst starting...\n");
if(task.duplicate_console==1) fprintf(fid_console, "trainhmmst starting...\n");
}
clock_t tm_read = clock();//overall time //SEQ
// double _tm_read = omp_get_wtime(); //PAR
int read_ok = read_and_structure_data(input_file, fid_console);
tm_read = (clock_t)(clock()-tm_read);//SEQ
// _tm_read = omp_get_wtime()-_tm_read;//PAR
if( ! read_ok )
return 0;
// once we know nO (number of observations) parse parameters, step 2
parse_arguments_step2(argc, argv, fid_console);
// write_pLo_irt();
// //
// // read item mean % correct
// //
// FILE *fid = fopen("a89_kts_train01_voc_i.txt","r");
// max_line_length = 1024;
// char *col;
// string item;
// map<string,NCAT>::iterator it;
// task.item_complexity = Calloc(NUMBER, task.map_step_bwd->size());
// line = (char *)malloc(max_line_length);// Malloc(char,max_line_length);
// while( readline(fid)!=NULL) {
// // Group
// col = strtok(line,"\t\n\r");
// item = string( col );
// it = task.map_step_fwd->find(item);
// if( it==task.map_step_fwd->end() ) { // not found
// fprintf(stderr,"DID NOT FIND THE STEP!!\n");
// return false;
// }
// else {
//// if( it->second > task.map_step_bwd->size()) {
//// int z = 0 ;
//// }
// NUMBER v = atof( strtok(NULL,"\t\n\r") );
// task.item_complexity[ it->second ] = v;
// }
// }
// free(line);
// fclose(fid);
if(!task.quiet) {
printf("input read, nO=%d, nG=%d, nK=%d, nI=%d, nZ=%d\n",task.nO, task.nG, task.nK, task.nI, task.nZ);
if(task.duplicate_console==1) fprintf(fid_console, "input read, nO=%d, nG=%d, nK=%d, nI=%d, nZ=%d\n",task.nO, task.nG, task.nK, task.nI, task.nZ);
}
// // write time
// if(task.time==1) {
// const char * fn = "a89_kts_times.txt";
//// const char * fn = "a89_uskts_times.txt";
// write_time_interval_data(¶m, fn);
// }
// erase blocking labels
// zeroLabels(&task);
clock_t tm_fit = 0; //SEQ
clock_t tm_predict = 0; //SEQ
// double _tm_fit;//PAR
// double _tm_predict;//PAR
if(task.cv_folds==0) { // not cross-validation
// create problem
HMMProblemSt *hmm = NULL;
switch(task.structure)
{
case STRUCTURE_SKILL: // Conjugate Gradient Descent
// case STRUCTURE_GROUP: // Conjugate Gradient Descent
hmm = new HMMProblemSt(&task);
break;
// case STRUCTURE_PIg: // Gradient Descent: PI by group, A,B by skill
// hmm = new HMMProblemPiG(¶m);
// break;
// case STRUCTURE_SKABslc: // Conjugate Gradient Descent
// hmm = new HMMProblemSlicedAB(¶m);
// break;
// case STRUCTURE_SKAslc: // Conjugate Gradient Descent
// hmm = new HMMProblemSlicedA(¶m);
// break;
// case STRUCTURE_PIgk: // Gradient Descent, pLo=f(K,G), other by K
// hmm = new HMMProblemPiGK(¶m);
// break;
// case STRUCTURE_PIgkww: // Gradient Descent, pLo=f(K,G), other by K
// hmm = new HMMProblemPiGKww(¶m);
// break;
// case STRUCTURE_PIAgk: // Gradient Descent, pLo=f(K,G), pT=f(K,G), other by K
// hmm = new HMMProblemPiAGK(¶m);
// break;
// case STRUCTURE_Agk: // Gradient Descent, pT=f(K,G), other by K
// hmm = new HMMProblemAGK(¶m);
// break;
//// case STRUCTURE_Agki: // Gradient Descent, pT=f(K,G), other by K
//// hmm = new HMMProblemAGKi(¶m);
//// break;
// case STRUCTURE_PIABgk: // Gradient Descent, pT=f(K,G), other by K
// hmm = new HMMProblemPiABGK(¶m);
// break;
// // case BKT_GD_T: // Gradient Descent with Transfer
// // hmm = new HMMProblemKT(¶m);
// // break;
// case STRUCTURE_COMP: // Gradient Descent, pT=f(K,G), other by K
// hmm = new HMMProblemComp(¶m);
// break;
case STRUCTURE_ELO: // Gradient Descent, pT=f(K,G), other by K
hmm = new HMMProblemEloSt(&task);
break;
default:
fprintf(stderr,"Solver specified (%d) is not supported!\n",task.structure);
exit(1);
break;
}
tm_fit = clock(); //SEQ
// _tm_fit = omp_get_wtime(); //PAR
hmm->fit();
tm_fit = clock()-tm_fit;//SEQ
// _tm_fit = omp_get_wtime()-_tm_fit;//PAR
// write model
hmm->toFile(output_file);
if(task.metrics>0 || task.predictions>0) {
NUMBER* metrics = Calloc(NUMBER, (size_t)8); // LL, LLnonull, RMSE, RMSEnonull, Acc, Acc_nonull, AIC, BIC;
// takes care of predictions and metrics, writes predictions if task.predictions==1
// temporary
// if(task.per_kc_rmse_acc) {
// task.kc_counts = Calloc(NDAT, (size_t)task.nK);
// task.kc_rmse = Calloc(NUMBER, (size_t)task.nK);
// task.kc_acc = Calloc(NUMBER, (size_t)task.nK);
// }
// NUMBER l1 = hmm->getSumLogPOPara(task.nSeq, task.k_data);
// printf("hmm-style ll_no_null %15.7f\n",l1);
tm_predict = clock(); //SEQ
// _tm_predict = omp_get_wtime(); //PAR
// if(task.structure==STRUCTURE_SKAslc) {
// ((HMMProblemSlicedA *)hmm)->predict(metrics, predict_file, task.dat_obs, task.dat_group, task.dat_skill, task.dat_skill_stacked, task.dat_skill_rcount, task.dat_skill_rix);
// } else if(task.structure==STRUCTURE_SKABslc) {
// ((HMMProblemSlicedAB *)hmm)->predict(metrics, predict_file, task.dat_obs, task.dat_group, task.dat_skill, task.dat_skill_stacked, task.dat_skill_rcount, task.dat_skill_rix);
// } else {
HMMProblemSt::predict(metrics, predict_file,
//task.N, task.dat_obs, task.dat_group, task.dat_skill, task.dat_skill_stacked, task.dat_skill_rcount, task.dat_skill_rix,
&task,
&hmm, 1, NULL);
// }
tm_predict = clock()-tm_predict;//SEQ
// _tm_predict = omp_get_wtime()-_tm_predict;//PAR
if( task.metrics>0 /*&& !task.quiet*/) {
printf("trained model LL=%15.7f (%15.7f), AIC=%8.6f, BIC=%8.6f, RMSE=%8.6f (%8.6f), Acc=%8.6f (%8.6f)\n",
metrics[0], metrics[1], // ll's
2*hmm->getModelParamN() + 2*metrics[0], // AIC
hmm->getModelParamN()*safelog(task.N) + 2*metrics[0], //BIC
metrics[2], metrics[3], // rmse's
metrics[4], metrics[5]); // acc's
if(task.duplicate_console==1) fprintf(fid_console, "trained model LL=%15.7f (%15.7f), AIC=%8.6f, BIC=%8.6f, RMSE=%8.6f (%8.6f), Acc=%8.6f (%8.6f)\n",
metrics[0], metrics[1], // ll's
2*hmm->getModelParamN()+ 2*metrics[0], // AIC
hmm->getModelParamN()*safelog(task.N) + 2*metrics[0],
metrics[2], metrics[3], // rmse's
metrics[4], metrics[5]); // acc's
}
free(metrics);
// temporary
// if(task.per_kc_rmse_acc) {
// for(NCAT i=0; i<task.nK; i++) {
// printf("KC %4u RMSE=%8.6f Acc=%8.6f\n",i,task.kc_rmse[i],task.kc_acc[i]);
// if(task.duplicate_console==1) fprintf(fid_console, "KC %4u RMSE=%8.6f Acc=%8.6f\n",i,task.kc_rmse[i],task.kc_acc[i]);
// }
// free(task.kc_counts);
// free(task.kc_rmse);
// free(task.kc_acc);
// }
} // if predict or metrics
delete hmm;
} else { // cross-validation
NUMBER* metrics = Calloc(NUMBER, (size_t)7); // AIC, BIC, RMSE, RMSE no null
NUMBER n_par = 0;
switch (task.cv_strat) {
case CV_GROUP:
n_par = cross_validate(metrics, predict_file, output_file, &tm_fit, &tm_predict, fid_console);//SEQ
// n_par = cross_validate(metrics, predict_file, output_file, &_tm_fit, &_tm_predict, fid_console);//PAR
break;
case CV_ITEM:
n_par = cross_validate_item(metrics, predict_file, output_file, &tm_fit, &tm_predict, fid_console);//SEQ
// n_par = cross_validate_item(metrics, predict_file, output_file, &_tm_fit, &_tm_predict, fid_console);//PAR
break;
case CV_NSTR:
n_par = cross_validate_nstrat(metrics, predict_file, output_file, &tm_fit, &tm_predict, fid_console);//SEQ
// n_par = cross_validate_nstrat(metrics, predict_file, output_file, &_tm_fit, &_tm_predict, fid_console);//PAR
break;
default:
break;
}
printf("%d-fold cross-validation: LL=%15.7f (%15.7f), AIC=%8.6f, BIC=%8.6f, RMSE=%8.6f (%8.6f), Acc=%8.6f (%8.6f)\n",
task.cv_folds,
metrics[0], metrics[1], // ll's
2*n_par + 2*metrics[0], n_par*safelog(task.N) + 2*metrics[0],
metrics[2], metrics[3], // rmse's
metrics[4], metrics[5]); // acc's
if(task.duplicate_console==1) fprintf(fid_console, "%d-fold cross-validation: LL=%15.7f (%15.7f), AIC=%8.6f, BIC=%8.6f, RMSE=%8.6f (%8.6f), Acc=%8.6f (%8.6f)\n",
task.cv_folds,
metrics[0], metrics[1], // ll's
2*n_par + 2*metrics[0], n_par*safelog(task.N) + 2*metrics[0],
metrics[2], metrics[3], // rmse's
metrics[4], metrics[5]); // acc's
free(metrics);
}
// free data
destroy_input_data(&task);
// if(task.quiet == 0) {
printf("timing: overall %f seconds, read %f, fit %f, predict %f\n",(NUMBER)((clock()-tm_all)/CLOCKS_PER_SEC), (NUMBER)tm_read/CLOCKS_PER_SEC, (NUMBER)tm_fit/CLOCKS_PER_SEC, (NUMBER)tm_predict/CLOCKS_PER_SEC);//SEQ
if(task.duplicate_console==1) fprintf(fid_console, "timing: overall %f seconds, read %f, fit %f, predict %f\n",(NUMBER)((clock()-tm_all)/CLOCKS_PER_SEC), (NUMBER)tm_read/CLOCKS_PER_SEC, (NUMBER)tm_fit/CLOCKS_PER_SEC, (NUMBER)tm_predict/CLOCKS_PER_SEC);//SEQ
// if(task.duplicate_console==1) fprintf(fid_console, "timing: overall %lf sec, read %lf sec, fit %lf sec, predict %lf sec\n",omp_get_wtime()-_tm_all, _tm_read, _tm_fit, _tm_predict);//PAR
// printf("timing: overall %lf sec, read %lf sec, fit %lf sec, predict %lf sec\n",omp_get_wtime()-_tm_all, _tm_read, _tm_fit, _tm_predict);//PAR
// }
if(task.duplicate_console==1)
fclose(fid_console);
return 0;
}
void exit_with_help() {
printf(
"Usage: trainhmmst [options] input_file [[output_file] predicted_response_file]\n"
"options:\n"
"-s : structure.solver[.solver setting], structures: 1-by skill, 2-by user;\n"
" solvers: 1-Baum-Welch, 2-Gradient Descent, 3-Conjugate Gradient Descent;\n"
" Conjugate Gradient Descent has 3 settings: 1-Polak-Ribiere,\n"
" 2-Fletcher–Reeves, 3-Hestenes-Stiefel, 4-Dai-Yuan.\n"
" For example '-s 1.3.1' would be by skill structure (classical) with\n"
" Conjugate Gradient Descent and Hestenes-Stiefel formula, '-s 2.1' would be\n"
" by student structure fit using Baum-Welch method.\n"
"-e : tolerance of termination criterion (0.01 for parameter change default);\n"
" could be compuconvergeted by the change in log-likelihood per datapoint, e.g.\n"
" '-e 0.00001,l'.\n"
"-i : maximum iterations (200 by default)\n"
"-q : quiet mode, without output, 0-no (default), or 1-yes\n"
"-n : number of hidden states, should be 2 or more (default 2)\n"
"-0 : initial parameters comma-separated for priors, transition, and emission\n"
" probabilities skipping the last value from each vector (matrix row) since\n"
" they sum up to 1; default 0.5,1.0,0.4,0.8,0.2\n"
"-l : lower boundaries for parameters, comma-separated for priors, transition,\n"
" and emission probabilities (without skips); default 0,0,1,0,0,0,0,0,0,0\n"
"-u : upper boundaries for params, comma-separated for priors, transition,\n"
" and emission probabilities (without skips); default 0,0,1,0,0,0,0,0,0,0\n"
"-c : specification of the C weight and cetroids for L2 penalty, empty (default).\n"
" For standard BKT - 4 comma-separated numbers: C weight of the penalty and\n"
" centroids, for PI, A, and B matrices respectively. If used for iBKT with\n"
" student effects, 8 values will be used with 4 additional values for student\n"
" effect matrices. For example, '-c 1.0,0.5,0.5,0.0'.\n"
"-f : fit as one skill, 0-no (default), 1 - fit as one skill and use params as\n"
" starting point for multi-skill, 2 - force one skill\n"
"-m : report model fitting metrics (AIC, BIC, RMSE) 0-no (default), 1-yes. To \n"
" specify observation for which metrics to be reported, list it after ','.\n"
" For example '-m 0', '-m 1' (by default, observation 1 is assumed), '-m 1,2'\n"
" (compute metrics for observation 2). Incompatible with-v option.\n"
"-v : cross-validation folds, stratification, and target state to validate\n"
" against, default 0 (no cross-validation),\n"
" examples '-v 5,i,2' - 5 fold, item-stratified c.-v., predict state 2,\n"
" '-v 10' - 10-fold subject-stratified c.-v. predict state 1 by default,\n"
" alternatively '-v 10,g,1', and finally '-v 5,n,2,' - 5-fold unstratified\n"
" c.-v. predicting state 1.\n"
"-p : report model predictions on the train set 0-no (default), 1-yes; 2-yes,\n"
" plus output state probability; works with -v and -m parameters.\n"
"-U : controls how update to the probability distribution of the states is\n"
" updated. Takes the following format '-U r|g[,t|g]', where first\n"
" character controls how prediction treats known observations, second -- how\n"
" prediction treats unknown observations, and third -- whether to output\n"
" probabilities of priors. Dealing with known observations 'r' - reveal\n"
" actual observations for the update of state probability distribution (makes\n"
" sense for modeling how an actual system would work), 'g' - 'guessing' the\n"
" observation based on the predicted outcomes (arg max) -- more appropriate\n"
" when comparing models (so that no information about observation is never\n"
" revealed). Dealing with unknown observations (marked as '.' -- dot): 't' --\n"
" use transition matrix only, 'g' -- 'guess' the observation.\n"
" Default (if ommitted) is '-U r,t'.\n"
" For examle, '-U g,g would require 'guessing' of what the observation was\n"
" using model parameters and the running value of the probabilities of state\n"
" distributions.\n"
"-d : delimiter for multiple skills per observation; 0-single skill per\n"
" observation (default), otherwise -- delimiter character, e.g. '-d ~'.\n"
"-b : treat input file as binary input file (specifications TBA).\n"
"-B : block re-estimation of prior, transitions, or emissions parameters\n"
" respectively (defailt is '-B 0,0,0'), to block re-estimation of transition\n"
" probabilities specify '-B 0,1,0'.\n"
"-P : use parallel processing, defaul - 0 (no parallel processing), 1 - fit\n"
" separate skills/students separately, 2 - fit separate sequences within\n"
" skill/student separately.\n"
"-o : in addition to printing to console, print output to the file specified\n"
" default is empty.\n"
);
exit(1);
}
void parse_arguments_step1(int argc, char **argv, char *input_file_name, char *output_file_name, char *predict_file_name, char *console_file_name) {
// parse command line options, starting from 1 (0 is path to executable)
// go in pairs, looking at whether first in pair starts with '-', if not, stop parsing arguments
// at this time we do not know nO (the number of observations) yet
int i;
int n;
char *ch, *ch2;
for(i=1;i<argc;i++)
{
if(argv[i][0] != '-') break; // end of options stop parsing
if(++i>=argc)
exit_with_help();
switch(argv[i-1][1])
{
case 'e':
task.tol = atof( strtok(argv[i],",\t\n\r") );
ch = strtok(NULL,",\t\n\r"); // could be NULL
if(ch != NULL)
task.tol_mode = ch[0];
if(task.tol<0) {
fprintf(stderr,"ERROR! Fitting tolerance cannot be negative\n");
exit_with_help();
}
if(task.tol>10) {
fprintf(stderr,"ERROR! Fitting tolerance cannot be >10\n");
exit_with_help();
}
if(task.tol_mode!='p' && task.tol_mode!='l') {
fprintf(stderr,"ERROR! Tolerance mode '%c' is not allowed\n",task.tol_mode);
exit_with_help();
}
break;
case 't':
task.sliced = (NPAR)atoi(argv[i]);
if(task.sliced!=0 && task.sliced!=1) {
fprintf(stderr,"ERROR! Time parameter should be either 0 (off) or 1(on)\n");
exit_with_help();
}
break;
case 'i':
task.maxiter = atoi(argv[i]);
if(task.maxiter<10) {
fprintf(stderr,"ERROR! Maximum iterations should be at least 10\n");
exit_with_help();
}
break;
case 'q':
task.quiet = (NPAR)atoi(argv[i]);
if(task.quiet!=0 && task.quiet!=1) {
fprintf(stderr,"ERROR! Quiet param should be 0 or 1\n");
exit_with_help();
}
break;
case 'n':
task.nS = (NPAR)atoi(argv[i]);
if(task.nS<2) {
fprintf(stderr,"ERROR! Number of hidden states should be at least 2\n");
exit_with_help();
}
if(task.nS != 2) {
task.stat_specd_gt2 = true;
}
break;
case 'S':
task.is_scaled = (NPAR)atoi(argv[i]);
if(task.is_scaled < 0 || task.is_scaled > 1) {
fprintf(stderr,"ERROR! Scaling flag should be either 0 (off) or 1 (in)\n");
exit_with_help();
}
break;
case 's':
task.structure = (NPAR)atoi( strtok(argv[i],".\t\n\r") );
ch = strtok(NULL,".\t\n\r"); // could be NULL (default GD solver)
if(ch != NULL)
task.solver = (NPAR)atoi(ch);
ch = strtok(NULL,"\t\n\r"); // could be NULL (default GD solver)
if(ch != NULL)
task.solver_setting = (NPAR)atoi(ch);
if( task.structure != STRUCTURE_SKILL && // task.structure != STRUCTURE_GROUP &&
task.structure != STRUCTURE_PIg && task.structure != STRUCTURE_PIgk &&
task.structure != STRUCTURE_PIAgk && task.structure != STRUCTURE_Agk &&
task.structure != STRUCTURE_PIABgk && task.structure != STRUCTURE_Agki &&
task.structure != STRUCTURE_PIgkww && task.structure != STRUCTURE_SKABslc &&
task.structure != STRUCTURE_SKAslc && task.structure != STRUCTURE_COMP &&
task.structure != STRUCTURE_ELO ) {
fprintf(stderr, "Model Structure specified (%d) is out of range of allowed values\n",task.structure);
exit_with_help();
}
if( task.solver != METHOD_BW && task.solver != METHOD_GD &&
task.solver != METHOD_CGD && task.solver != METHOD_GDL &&
task.solver != METHOD_GBB) {
fprintf(stderr, "Method specified (%d) is out of range of allowed values\n",task.solver);
exit_with_help();
}
// if( (task.structure == STRUCTURE_SKABslc || task.structure == STRUCTURE_SKAslc) && task.solver == METHOD_BW) {
// fprintf(stderr, "Method specified (%d) is not defined for this structure (%d) \n",task.solver,task.structure);
// exit_with_help();
// }
if( task.structure == STRUCTURE_COMP && task.solver == METHOD_BW) {
fprintf(stderr, "Method specified (%d) is not defined for this structure (%d) \n",task.solver,task.structure);
exit_with_help();
}
// if( task.structure == STRUCTURE_ELO && !(task.solver == METHOD_GD || task.solver == METHOD_CGD) ) {
// fprintf(stderr, "Method specified (%d) is not defined for this structure (%d) \n",task.solver,task.structure);
// exit_with_help();
// }
if( task.solver == METHOD_BW && ( task.solver != STRUCTURE_SKILL /*&& task.solver != STRUCTURE_GROUP*/ ) ) {
fprintf(stderr, "Baum-Welch solver does not support model structure specified (%d)\n",task.solver);
exit_with_help();
}
if( task.solver == METHOD_CGD &&
( task.solver_setting != 1 && task.solver_setting != 2 &&
task.solver_setting != 3 && task.solver_setting !=4 )
) {
fprintf(stderr, "Conjugate Gradient Descent setting specified (%d) is out of range of allowed values\n",task.solver_setting);
exit_with_help();
}
break;
case 'f':
task.single_skill = (NPAR)atoi(argv[i]);
break;
case 'm':
task.metrics = atoi( strtok(argv[i],",\t\n\r"));
ch = strtok(NULL, "\t\n\r");
if(ch!=NULL) {
task.metrics_target_obs = (NPAR)(atoi(ch)-1);
}
if(task.metrics<0 || task.metrics>1) {
fprintf(stderr,"value for -m should be either 0 or 1.\n");
exit_with_help();
}
if(task.metrics_target_obs<0) {// || task.metrics_target_obs>(task.nO-1)) {
fprintf(stderr,"target observation to compute metrics against cannot be '%d'\n",task.metrics_target_obs+1);
exit_with_help();
}
break;
case 'b':
task.binaryinput = atoi( strtok(argv[i],"\t\n\r"));
break;
case 'v':
task.cv_folds = (NPAR)atoi( strtok(argv[i],",\t\n\r"));
ch2 = strtok(NULL, ",\t\n\r");
if(ch2!=NULL)
task.cv_strat = ch2[0];
ch = strtok(NULL, ",\t\n\r");
if(ch!=NULL)
task.cv_target_obs = (NPAR)(atoi(ch)-1);
ch = strtok(NULL, ",\t\n\r");
if(ch!=NULL)
strcpy(task.cv_folds_file, ch);
ch = strtok(NULL, ",\t\n\r");
if(ch!=NULL)
task.cv_inout_flag = ch[0];
if(task.cv_folds<2) {
fprintf(stderr,"number of cross-validation folds should be at least 2\n");
exit_with_help();
}
if(task.cv_folds>10) {
fprintf(stderr,"please keep number of cross-validation folds less than or equal to 10\n");
exit_with_help();
}
if(task.cv_strat != CV_GROUP && task.cv_strat != CV_ITEM && task.cv_strat != CV_NSTR){
fprintf(stderr,"cross-validation stratification parameter '%c' is illegal\n",task.cv_strat);
exit_with_help();
}
if(task.cv_target_obs<0) {// || task.cv_target_obs>(task.nO-1)) {
fprintf(stderr,"target observation to be cross-validated against cannot be '%d'\n",task.cv_target_obs+1);
exit_with_help();
}
if( task.cv_inout_flag!='i' && task.cv_inout_flag!='o') {
fprintf(stderr,"cross-validation folds input/output flag should be ither 'o' (out) or 'i' (in), while it is '%c'\n",task.cv_inout_flag);
exit_with_help();
}
break;
case 'p':
task.predictions = atoi(argv[i]);
if(task.predictions<0 || task.predictions>3) {
fprintf(stderr,"a flag of whether to report predictions for training data (-p) should be 0, 1, 2, or 3\n");
exit_with_help();
}
break;
case 'U':
task.update_known = *strtok(argv[i],",\t\n\r");
ch = strtok(NULL, ",\t\n\r");
task.update_unknown = ch[0];
if( (task.update_known!='r' && task.update_known!='g') ||
(task.update_unknown!='t' && task.update_unknown!='g') ) {
fprintf(stderr,"specification of how probabilities of states should be updated (-U) is incorrect, it sould be r|g[,t|g] \n");
exit_with_help();
}
break;
case 'd':
task.multiskill = argv[i][0]; // just grab first character (later, maybe several)
break;
case 'P':
n = atoi(argv[i]);
if(n!=0 && n!=1 && n!=2) {
fprintf(stderr,"parallel processing flag (-P) should be 0 or 1\n");
exit_with_help();
}
task.parallel = (NPAR)n;
break;
case 'r': // coordinate descend parameters
// if two first_iteration_qualify,iterations_to_qualify
// if one iterations_to_qualify (first_iteration_qualify==0)
n = atoi( strtok(argv[i],",\t\n\r") );
ch = strtok(NULL,",\t\n\r"); // could be NULL (default GD solver)
if(ch==NULL) {// one parameter
task.first_iteration_qualify = 0;
task.iterations_to_qualify = (NPAR)n;
} else {
task.first_iteration_qualify = (NPAR)n;
task.iterations_to_qualify = (NPAR)atoi(ch);
}
break;
case 'R': // coordinate descend parameter for hard iterations limit of skill/group/other fitting
n = atoi(argv[i]);
if(n<=0) {
fprintf(stderr,"skill/group gradient descent iteration limit (-R) should be an integer >0\n");
exit_with_help();
}
if(n<=0) {
fprintf(stderr,"skill/group gradient descent iteration limit (-R) should be an integer >0\n");
exit_with_help();
}
task.iterations_limit = (NPAR)n;
break;
/*
case 'c': {
// this version is with single center of gravity per Pi, A, and B
StripedArray<NUMBER> * tmp_array = new StripedArray<NUMBER>();
ch = strtok(argv[i],",\t\n\r");
while( ch != NULL ) {
tmp_array->add( atof(ch) );
ch = strtok(NULL,",\t\n\r");
}
if( (tmp_array->getSize() % 4) != 0 ) {
fprintf(stderr,"The number of regularization parameters should be a multiple of 4 and it is %d\n",tmp_array->getSize());
exit_with_help();
}
task.Cslices = (NPAR) tmp_array->getSize() / 4;
task.Cw = Calloc(NUMBER, (size_t)task.Cslices);
task.Ccenters = Calloc(NUMBER, (size_t)(task.Cslices * 3) );
int c1 = 0, c2 = 0, i = 0;
for(int l=0; l<(int)tmp_array->getSize() / 4; l++) {
task.Cw[c1++] = tmp_array->get((NDAT)i++);
for(int j=0; j<3; j++)
task.Ccenters[c2++] = tmp_array->get((NDAT)i++);
}
delete tmp_array;
}
break;
*/
case 'c': // just to keep it a valid option
break;
case 'o':
task.duplicate_console = 1;
strcpy(console_file_name,argv[i]);
break;
case '0':
task.init_reset = true;
break;
case 'l': // just to keep it a valid option
break;
case 'u': // just to keep it a valid option
break;
case 'B': // just to keep it a valid option
break;
case 'k': // just to keep it a valid option
break;
default:
fprintf(stderr,"unknown option: -%c\n", argv[i-1][1]);
exit_with_help();
break;
}
}
// post-process checks
// -v and -m collision
if(task.cv_folds>0 && task.metrics>0) { // correct for 0-start coding
fprintf(stderr,"values for -v and -m cannot be both non-zeros\n");
exit_with_help();
}
// scaling
if(task.is_scaled == 1 && task.solver != METHOD_BW) {
task.is_scaled = 0;
printf("Scaling can only be enabled for Baum-Welch method. Setting it to off\n");
}
// specifying >2 states via -n and mandatory specification of -0 (initial parameters)
if(task.nS > 2 && !task.init_reset) {
fprintf(stderr,"when >2 latent states specified via '-n', initial values of parameters have to be explicitly set via '-0'!\n");
exit_with_help();
}
// STRUCTURE_SKABslc solver and -t 1 should be set together
if( (task.sliced==1) != (task.structure == STRUCTURE_SKABslc || task.structure == STRUCTURE_SKAslc) ) {
fprintf(stderr,"Error! sliced parameter ('-t 1') and STRUCTURE_SKABslc or STRUCTURE_SKAslc structure should be either both set on or off.\n");
exit_with_help();
}
// next argument should be input file name
if(i>=argc) // if not
exit_with_help(); // leave
strcpy(input_file_name, argv[i++]); // copy and advance
if(i>=argc) { // no output file name specified
strcpy(output_file_name,"output.hmm");
strcpy(predict_file_name,"predict_hmm.txt"); // the predict file too
}
else {
strcpy(output_file_name,argv[i++]); // copy and advance
if(i>=argc) // no prediction file name specified
strcpy(predict_file_name,"predict_hmm.txt"); // the predict file too
else
strcpy(predict_file_name,argv[i]);
}
}
void parse_arguments_step2(int argc, char **argv, FILE *fid_console) {
// parse command line options, starting from 1 (0 is path to executable)
// go in pairs, looking at whether first in pair starts with '-', if not, stop parsing arguments
// at this time we do know nO (the number of observations)
int i;
int n, expected_n;
char *ch;
for(i=1;i<argc;i++)
{
if(argv[i][0] != '-') break; // end of options stop parsing
if(++i>=argc)
exit_with_help();
switch(argv[i-1][1])
{
case '0': // init_params
int len;
len = (int)strlen( argv[i] );
// count delimiters
n = 1; // start with 1
for(int j=0;j<len;j++) {
n += (argv[i][j]==',')?1:0;
if( (argv[i][j] >= 'a' && argv[i][j] <= 'z') || (argv[i][j] >= 'A' && argv[i][j] <= 'Z') ) {
strcpy(task.initfile, argv[i]);
break;
}
}
// init parameters
if(task.init_param_values!=NULL) free(task.init_param_values);
task.init_param_values = Calloc(NUMBER, (size_t)n);
task.init_param_values_n = (NPAR)n;
// read params and write to params
task.init_param_values[0] = atof( strtok(argv[i],",\t\n\r") );
for(int j=1; j<n; j++) {
task.init_param_values[j] = atof( strtok(NULL,",\t\n\r") );
}
break;
case 'l': // lower boundaries
len = (int)strlen( argv[i] );
// count delimiters
n = 1; // start with 1
for(int j=0;j<len;j++)
n += (NPAR)((argv[i][j]==',')?1:0);
// init params
if(task.param_values_lb!=NULL) free(task.param_values_lb);
task.param_values_lb = Calloc(NUMBER, (size_t)n);
// read params and write to params
task.param_values_lb[0] = atof( strtok(argv[i],",\t\n\r") );
for(int j=1; j<n; j++) {
task.param_values_lb[j] = atof( strtok(NULL,",\t\n\r") );
// if(task.param_lo[j] >0) {
// int a = 0;
// }
}
// check if the number of lower boundaries corresponds
expected_n = task.nS +
((task.sliced==1 && (task.structure==STRUCTURE_SKAslc || task.structure==STRUCTURE_SKABslc) )?task.nZ:1)*task.nS*task.nS +
((task.sliced==1 && task.structure==STRUCTURE_SKABslc )?task.nZ:1)*task.nS*task.nO;
if( n != expected_n ) {
// fprintf(stderr,"Structure=%d, nS=%d, nO=%d, nZ=%d, The expected n=%d specified=%d\n",task.structure,task.nS,task.nO,task.nZ,expected_n,n);
fprintf(stderr,"The expected number of lower parameter boundaries is %d and it is %d\n",expected_n,n);
exit_with_help();
}
task.lb_specd = true;
break;
case 'u': // upper boundaries
len = (int)strlen( argv[i] );
// count delimiters
n = 1; // start with 1
for(int j=0;j<len;j++)
n += (argv[i][j]==',')?1:0;
// init params
if(task.param_values_ub!=NULL) free(task.param_values_ub);
task.param_values_ub = Calloc(NUMBER, (size_t)n);
// read params and write to params
task.param_values_ub[0] = atof( strtok(argv[i],",\t\n\r") );
for(int j=1; j<n; j++) {
task.param_values_ub[j] = atof( strtok(NULL,",\t\n\r") );
// if(task.param_hi[j] < 1) {
// int a = 0;
// }
}
// check if the number of upper boundaries corresponds
expected_n = task.nS +
((task.sliced==1 && (task.structure==STRUCTURE_SKAslc || task.structure==STRUCTURE_SKABslc) )?task.nZ:1)*task.nS*task.nS +
((task.sliced==1 && task.structure==STRUCTURE_SKABslc )?task.nZ:1)*task.nS*task.nO;
if( n != expected_n ) {
fprintf(stderr,"The expected number of upper parameter boundaries is %d and it is %d\n",expected_n,n);
exit_with_help();
}
task.ub_specd = true;
break;
case 'B': // block fitting
// first
task.block_fitting[0] = (NPAR)atoi( strtok(argv[i],",\t\n\r") );
if(task.block_fitting[0]!=0 && task.block_fitting[0]!=1) {
fprintf(stderr,"Values of blocking the fitting flags shuld only be 0 or 1.\n");
if(task.duplicate_console==1) fprintf(fid_console,"Values of blocking the fitting flags shuld only be 0 or 1.\n");
exit_with_help();
}
// second
ch = strtok(NULL,",\t\n\r"); // could be NULL (default GD solver)
if(ch != NULL) {
task.block_fitting[1] = (NPAR)atoi(ch);
if(task.block_fitting[1]!=0 && task.block_fitting[1]!=1) {
fprintf(stderr,"Values of blocking the fitting flags shuld only be 0 or 1.\n");
if(task.duplicate_console==1) fprintf(fid_console,"Values of blocking the fitting flags shuld only be 0 or 1.\n");
exit_with_help();
}
}
else {
fprintf(stderr,"There should be 3 blockig the fitting flags specified.\n");
if(task.duplicate_console==1) fprintf(fid_console,"There should be 3 blockig the fitting flags specified.\n");
exit_with_help();
}
// third
ch = strtok(NULL,",\t\n\r"); // could be NULL (default GD solver)
if(ch != NULL) {
task.block_fitting[2] = (NPAR)atoi(ch);
if(task.block_fitting[2]!=0 && task.block_fitting[2]!=1) {
fprintf(stderr,"Values of blocking the fitting flags shuld only be 0 or 1.\n");
if(task.duplicate_console==1) fprintf(fid_console,"Values of blocking the fitting flags shuld only be 0 or 1.\n");
exit_with_help();
}
}
else {
fprintf(stderr,"There should be 3 blockig the fitting flags specified.\n");
if(task.duplicate_console==1) fprintf(fid_console,"There should be 3 blockig the fitting flags specified.\n");
exit_with_help();
}
break;
case 'c': {
// this version with per-parameter center of gravity in Pi, A, and B
NPAR nS = task.nS;
NPAR nO = task.nO;
int nPerSlice = 1 + nS + nS*nS + nS*nO; // parameters per slice
int nCenters = nS + nS*nS + nS*nO; // centers per slice
StripedArray<NUMBER> * tmp_array = new StripedArray<NUMBER>();
ch = strtok(argv[i],",\t\n\r");
while( ch != NULL ) {
tmp_array->add( atof(ch) );
ch = strtok(NULL,",\t\n\r");
}
if( (tmp_array->getSize() % nPerSlice) != 0 ) {
fprintf(stderr,"The number of regularization parameters should be a multiple of %d and it is %d\n",nPerSlice,tmp_array->getSize());
exit_with_help();
}
task.Cslices = (NPAR) ( tmp_array->getSize() / nPerSlice );
task.Cw = Calloc(NUMBER, (size_t)task.Cslices);
task.Ccenters = Calloc(NUMBER, (size_t)(task.Cslices * nCenters) );
int c1 = 0/*counter for weights*/, c2 = 0/*counter for centers*/, i = 0/*counter for tmp_array*/;
for(int l=0; l<(int)tmp_array->getSize() / nPerSlice; l++) {
task.Cw[c1++] = tmp_array->get((NDAT)i++);
for(int j=0; j<nCenters; j++)
task.Ccenters[c2++] = tmp_array->get((NDAT)i++);
}
delete tmp_array;
}
break;
case 'k':
// ELO parameters specified as a comma-delimited list of values, first is an integer, the rest are real
len = (int)strlen( argv[i] );
// count delimiters
n = 1; // start with 1
for(int j=0;j<len;j++)
n += (NPAR)((argv[i][j]==',')?1:0);
if( n < 3 ) {
fprintf(stderr,"To use Elo, one needs at lest three parameters; %d were specified\n",n);
exit_with_help();
}
// init params
task.elo_param_values_n = (NPAR)(n-2); // first parameter is Elo type
if(task.elo_param_values!=NULL) free(task.elo_param_values);
task.elo_param_values = Calloc(NUMBER, (size_t)(n-2));
// read params and write to params
task.elo_type = (NPAR)atoi( strtok(argv[i],",\t\n\r") );
task.elo_scope = (NCAT)atof( strtok(NULL,",\t\n\r") );
for(int j=2; j<n; j++) {
task.elo_param_values[j-2] = atof( strtok(NULL,",\t\n\r") );
}
break;
} // end switch
}// end for
// post parse actions
// post-argument checks
if( task.cv_target_obs>(task.nO-1)) {
fprintf(stderr,"target observation to be cross-validated against cannot be '%d'\n",task.cv_target_obs+1);
if(task.duplicate_console==1) fprintf(fid_console,"target observation to be cross-validated against cannot be '%d'\n",task.cv_target_obs+1);
exit_with_help();
}
if(task.metrics_target_obs>(task.nO-1)) {
fprintf(stderr,"target observation to compute metrics against cannot be '%d'\n",task.metrics_target_obs+1);
if(task.duplicate_console==1) fprintf(fid_console,"target observation to compute metrics against cannot be '%d'\n",task.metrics_target_obs+1);
exit_with_help();
}
if( !( (task.elo_param_values_n==0 && task.elo_type==0 && task.structure != STRUCTURE_ELO) || // not an Elo
(task.elo_param_values_n==1 && task.elo_type==1 && task.structure == STRUCTURE_ELO) || // Simple Elo
(task.elo_param_values_n==1 && task.elo_type==2 && task.structure == STRUCTURE_ELO) || // relation Uncertainty \frac{1}{1+b*n} Elo