Is DNNClassifier unstable compared with TensorFlowDNNClassifier? - tensorflow

I'm building a DNN predicted (0 or 1) model based on skflow with TF v0.9.
My code with TensorFlowDNNClassifier is like this. I train about 26,000 records and test 6,500 one.
classifier = learn.TensorFlowDNNClassifier(hidden_units=[64, 128, 64], n_classes=2)
classifier.fit(features, labels, steps=50000)
test_pred = classifier.predict(test_features)
print(classification_report(test_labels, test_pred))
It takes about 1 minute and gets a result.
precision recall f1-score support
0 0.77 0.92 0.84 4265
1 0.75 0.47 0.58 2231
avg / total 0.76 0.76 0.75 6496
But I got
WARNING:tensorflow:TensorFlowDNNClassifier class is deprecated.
Please consider using DNNClassifier as an alternative.
So I updated my code with DNNClassifier simply.
classifier = learn.DNNClassifier(hidden_units=[64, 128, 64], n_classes=2)
classifier.fit(features, labels, steps=50000)
It also works well. But result was not the same.
precision recall f1-score support
0 0.77 0.96 0.86 4265
1 0.86 0.45 0.59 2231
avg / total 0.80 0.79 0.76 6496
1 's precision is improved.
Of course this is a good for me, but why it is improved?
And It takes about 2 hours.
This is about 120 times slower than previous example.
Do I have something wrong? or miss some parameters?
Or is DNNClassifier unstable with TF v0.9?

I give the same answer as here. You might experience that because you used the steps parameter instead of max_steps. It was just steps on TensorFlowDNNClassifier that in reality did max_steps. Now you can decide if you really want that in your case 50000 steps or auto abort earlier.

Related

Which model is the best for training oriented bounding boxes for small objects

I have a dataset of some small fibrous objects on which I tried with YOLOv5OBB method but the results are not satisfying.
The detection result is poor (P=0.3, R=0.28 for total boxes = 1200 in 120 images).
The boxes are not fit well to the objects and often there are overlapped boxes in different orientation.
The considered fibrous objects include fibrous with less than 3 microns in diameters and longer than 5 microns, therefore I can not use scaling and shearing which change the size of the objects. traslate and mosaic will also damage the results as objects are cut.
Do you have any suggestion how to improve it? hyp parameters or even a different method/model?
Some output examples:
1
2
Hyp parameters:
lr0: 0.00258
lrf: 0.017
momentum: 0.779
weight_decay: 0.00058
warmup_epochs: 1.93
warmup_momentum: 0.443
warmup_bias_lr: 0.059
box: 0.0339
cls: 0.33
cls_pw: 0.825
theta: 0.299
theta_pw: 0.825
obj: 0.632
obj_pw: 1.0
iou_t: 0.2
anchor_t: 3.44
anchors: 2.5
fl_gamma: 0.0
hsv_h: 0.0188
hsv_s: 0.354
hsv_v: 0.35
degrees: 0.03
translate: 0.05
scale: 0.02
shear: 0.0
perspective: 0.0
flipud: 0.7
fliplr: 0.7
mosaic: 0.0
mixup: 0.5
copy_paste: 0.4
cls_theta: 180
csl_radius: 2.0

Obtaining Suboptimal Solutions with Benders in GAMS

I have the following Benders code for a maximization problem on GAMS. It happens that sometimes GAMS give an suboptimal solution even though it should find the exact solution, since no heuristics exist and Benders tolerance (BdTol= Upper Bound - Lower Bound) is 0. I ensure that both the subproblem and the master problem are solved to optimality and optcr and optca values are taken as 0, too. I realized it as follows: for a dataset I solved the problem without enforcing any variable to take any value, and it provided an objective value. Then, I enforced a variable to take a certain value, and it provided a higher objective value. Shouldn't GAMS find the highest possible value automatically as it is a maximization problem? Do you think there is something wrong with the code?
Sets
i /1*100/
j /1*10/;
Parameters
p /4/
m /1/
BdTol /0/;
Table a(i,j) DATA;
Table b(i,j) DATA;
variables
q 'cut set variable'
z;
binary variables
y(j)
x(i,j);
positive variables
w(j);
scalar UB 'upperbound' /INF/;
scalar LB 'lowerbound' /-INF/;
set iter /iter1*iter1000000/;
set cutset(iter) 'dynamic set';
cutset(iter)=no;
variable z0 'relaxed master objective variable'
q 'cut set variable';
parameters
cutcoeff(iter,i,j);
*---------------------------------------------------------------------
* Benders Algorithm
*---------------------------------------------------------------------
loop(iter$((abs(UB-LB)> BdTol)),
option lp=CPLEX, optcr=0, optca=0, reslim=1000000, iterlim=1000000;
solve subproblem maximizing z using lp;
abort$(subproblem.modelstat>=2) "Subproblem not solved to optimality";
cutset(iter) = yes;
cutcoeff(iter,i,j) = b(i,j)*w.l(j);
option mip=CPLEX, optcr=0, optca=0, reslim=1000000, iterlim=1000000;
solve master maximizing z0 using mip;
abort$(master.modelstat>=2) "Masterproblem not solved to optimality";
UB = min(UB, sum((i,j),a(i,j)*x.l(i,j))+q.l);
LB = max(LB, sum((i,j),a(i,j)*x.l(i,j))+z.l);
display x.l, y.l, z0.l, w.l, UB, LB;
);
Since I believe the problem is related to the algorithm, I only share that part.
Edit: New information are added.
What really interesting is, it finds suboptimal solutions only for some instances, not all the time.
The runs for a dataset is given below. The upper ones does not involve any enforcing constraints for a variable to take a certain value. The lower one involves a single variable to take a specific value.
The following is the log output for the one without the enforced variable.
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : -12.203660
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:04.895
--- benders3.gms(358) 88 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter1
--- 4,107 rows 4,016 columns 9,820 non-zeroes
--- 1,010 discrete-columns
--- Executing CPLEX: elapsed 0:00:04.902
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3387 rows and 3387 columns.
Reduced MIP has 720 rows, 629 columns, and 1867 nonzeros.
Reduced MIP has 629 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.00 sec.
Tried aggregator 1 time.
Presolve time = 0.00 sec.
Found feasible solution after 0.00 sec. Objective = 0.0000
Probing time = 0.00 sec.
Clique table members: 719.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 362.425771
Iteration: 129 Dual objective = 96.848559
Iteration: 198 Dual objective = 94.968744
Root relaxation solution time = 0.00 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 0.0000 249 ---
* 0 0 integral 0 93.1164 93.1164 249 0.00%
Elapsed real time = 0.00 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.00
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.00 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4107 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 93.116376 (249 iterations, 0 nodes)
Final Solve: 93.116376 (0 iterations)
Best possible: 93.116376
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:04.954
--- benders3.gms(358) 89 Mb
--- Generating LP model subproblem
--- benders3.gms(360) 89 Mb
--- LOOPS iter = iter2
--- 12 rows 11 columns 25 non-zeroes
--- Executing CPLEX: elapsed 0:00:04.959
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : -2.121247
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:04.974
--- benders3.gms(358) 89 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter2
--- 4,108 rows 4,016 columns 9,863 non-zeroes
--- 1,010 discrete-columns
--- Executing CPLEX: elapsed 0:00:04.982
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3354 rows and 3354 columns.
Reduced MIP has 754 rows, 662 columns, and 2034 nonzeros.
Reduced MIP has 661 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.00 sec.
Tried aggregator 1 time.
Reduced MIP has 754 rows, 662 columns, and 2034 nonzeros.
Reduced MIP has 661 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.09 sec.
Found feasible solution after 0.09 sec. Objective = -13.6132
Probing time = 0.00 sec.
Clique table members: 751.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 365.039800
Iteration: 141 Dual objective = 96.728338
Iteration: 211 Dual objective = 94.098252
Root relaxation solution time = 0.01 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 -13.6132 246 ---
* 0 0 integral 0 93.0748 93.0748 246 0.00%
Elapsed real time = 0.11 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.01
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.01 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4108 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 93.074808 (246 iterations, 0 nodes)
Final Solve: 93.074808 (0 iterations)
Best possible: 93.074808
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:05.115
--- benders3.gms(358) 89 Mb
--- Generating LP model subproblem
--- benders3.gms(360) 89 Mb
--- LOOPS iter = iter3
--- 12 rows 11 columns 25 non-zeroes
--- Executing CPLEX: elapsed 0:00:05.120
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : -2.847644
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:05.132
--- benders3.gms(358) 89 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter3
--- 4,109 rows 4,016 columns 9,967 non-zeroes
--- 1,010 discrete-columns
--- Executing CPLEX: elapsed 0:00:05.141
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3354 rows and 3354 columns.
Reduced MIP has 755 rows, 662 columns, and 2105 nonzeros.
Reduced MIP has 661 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.00 sec.
Tried aggregator 1 time.
Reduced MIP has 755 rows, 662 columns, and 2105 nonzeros.
Reduced MIP has 661 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec.
Found feasible solution after 0.00 sec. Objective = -32.0161
Probing time = 0.00 sec.
Clique table members: 751.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 346.636915
Iteration: 142 Dual objective = 96.564506
Iteration: 214 Dual objective = 93.644333
Root relaxation solution time = 0.02 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 -32.0161 252 ---
* 0 0 integral 0 92.6192 92.6192 252 0.00%
Elapsed real time = 0.09 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.09
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.09 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4109 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.01 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 92.619154 (252 iterations, 0 nodes)
Final Solve: 92.619154 (0 iterations)
Best possible: 92.619154
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:05.283
--- benders3.gms(358) 89 Mb
--- Generating LP model subproblem
--- benders3.gms(360) 89 Mb
--- LOOPS iter = iter4
--- 12 rows 11 columns 24 non-zeroes
--- Executing CPLEX: elapsed 0:00:05.290
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : 0.000000
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:05.304
--- benders3.gms(358) 89 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter4
--- 4,110 rows 4,016 columns 10,038 non-zeroes
--- 1,010 discrete-columns
--- Executing CPLEX: elapsed 0:00:05.311
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3355 rows and 3354 columns.
Reduced MIP has 755 rows, 662 columns, and 2105 nonzeros.
Reduced MIP has 661 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.02 sec.
Tried aggregator 1 time.
Reduced MIP has 755 rows, 662 columns, and 2105 nonzeros.
Reduced MIP has 661 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.09 sec.
Found feasible solution after 0.09 sec. Objective = -32.0161
Probing time = 0.00 sec.
Clique table members: 751.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 346.636915
Iteration: 142 Dual objective = 96.564506
Iteration: 214 Dual objective = 93.644333
Root relaxation solution time = 0.00 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 -32.0161 252 ---
* 0 0 integral 0 92.6192 92.6192 252 0.00%
Elapsed real time = 0.09 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.02
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.02 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4110 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 92.619154 (252 iterations, 0 nodes)
Final Solve: 92.619154 (0 iterations)
Best possible: 92.619154
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:05.434
--- benders3.gms(358) 89 Mb
*** Status: Normal completion
--- Job benders3.gms Stop 12/10/22 14:37:01 elapsed 0:00:05.481
The following is the log output for the one with the enforced variable.
--- benders3.gms(151) 86 Mb
--- Starting execution: elapsed 0:00:04.400
--- benders3.gms(358) 88 Mb
--- Generating LP model subproblem
--- benders3.gms(360) 88 Mb
--- LOOPS iter = iter1
--- 12 rows 11 columns 31 non-zeroes
--- Executing CPLEX: elapsed 0:00:04.406
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : -12.203660
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:04.417
--- benders3.gms(358) 88 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter1
--- 4,107 rows 4,016 columns 9,820 non-zeroes
--- 1,009 discrete-columns
--- Executing CPLEX: elapsed 0:00:04.425
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3547 rows and 3500 columns.
Reduced MIP has 560 rows, 516 columns, and 1458 nonzeros.
Reduced MIP has 516 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.00 sec.
Tried aggregator 2 times.
MIP Presolve eliminated 1 rows and 1 columns.
Aggregator did 1 substitutions.
Reduced MIP has 558 rows, 514 columns, and 1454 nonzeros.
Reduced MIP has 514 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.01 sec.
Found feasible solution after 0.01 sec. Objective = 25.1590
Probing time = 0.00 sec.
Clique table members: 557.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 213.565458
Iteration: 77 Dual objective = 96.476340
Iteration: 150 Dual objective = 93.814763
Root relaxation solution time = 0.00 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 25.1590 193 ---
* 0 0 integral 0 93.1164 93.1164 193 0.00%
Elapsed real time = 0.01 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.00
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.00 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4107 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 93.116376 (193 iterations, 0 nodes)
Final Solve: 93.116376 (0 iterations)
Best possible: 93.116376
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:04.551
--- benders3.gms(358) 89 Mb
--- Generating LP model subproblem
--- benders3.gms(360) 89 Mb
--- LOOPS iter = iter2
--- 12 rows 11 columns 25 non-zeroes
--- Executing CPLEX: elapsed 0:00:04.555
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : -2.121247
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:04.568
--- benders3.gms(358) 89 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter2
--- 4,108 rows 4,016 columns 9,863 non-zeroes
--- 1,009 discrete-columns
--- Executing CPLEX: elapsed 0:00:04.576
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3460 rows and 3413 columns.
Reduced MIP has 648 rows, 603 columns, and 1781 nonzeros.
Reduced MIP has 602 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.00 sec.
Tried aggregator 1 time.
Reduced MIP has 648 rows, 603 columns, and 1781 nonzeros.
Reduced MIP has 602 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.00 sec.
Found feasible solution after 0.00 sec. Objective = -2.6132
Probing time = 0.00 sec.
Clique table members: 645.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 339.579984
Iteration: 130 Dual objective = 96.654157
Iteration: 208 Dual objective = 93.001859
Root relaxation solution time = 0.09 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 -2.6132 213 ---
* 0 0 integral 0 92.8258 92.8258 213 0.00%
Elapsed real time = 0.09 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.09
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.09 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4108 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 92.825775 (213 iterations, 0 nodes)
Final Solve: 92.825775 (0 iterations)
Best possible: 92.825775
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:04.703
--- benders3.gms(358) 89 Mb
--- Generating LP model subproblem
--- benders3.gms(360) 89 Mb
--- LOOPS iter = iter3
--- 12 rows 11 columns 24 non-zeroes
--- Executing CPLEX: elapsed 0:00:04.707
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
LP Presolve eliminated 12 rows and 11 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
LP status(1): optimal
Optimal solution found.
Objective : 0.000000
--- Reading solution for model subproblem
--- Executing after solve: elapsed 0:00:04.720
--- benders3.gms(358) 89 Mb
--- Generating MIP model master
--- benders3.gms(367) 89 Mb
--- LOOPS iter = iter3
--- 4,109 rows 4,016 columns 9,901 non-zeroes
--- 1,009 discrete-columns
--- Executing CPLEX: elapsed 0:00:04.727
IBM ILOG CPLEX Jul 4, 2012 23.9.5 WEX 36376.36401 WEI x86_64/MS Windows
--- GAMS/Cplex licensed for continuous and discrete problems.
Cplex 12.4.0.1
Reading data...
Starting Cplex...
Tried aggregator 1 time.
MIP Presolve eliminated 3461 rows and 3413 columns.
Reduced MIP has 648 rows, 603 columns, and 1781 nonzeros.
Reduced MIP has 602 binaries, 0 generals, 0 SOSs, and 0 indicators.
Probing time = 0.01 sec.
Tried aggregator 1 time.
Reduced MIP has 648 rows, 603 columns, and 1781 nonzeros.
Reduced MIP has 602 binaries, 0 generals, 0 SOSs, and 0 indicators.
Presolve time = 0.09 sec.
Found feasible solution after 0.09 sec. Objective = -2.6132
Probing time = 0.00 sec.
Clique table members: 645.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: none, using 1 thread.
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec.
Initializing dual steep norms . . .
Iteration log . . .
Iteration: 1 Dual objective = 339.579984
Iteration: 130 Dual objective = 96.654157
Iteration: 208 Dual objective = 93.001859
Root relaxation solution time = 0.00 sec.
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
* 0+ 0 -2.6132 213 ---
* 0 0 integral 0 92.8258 92.8258 213 0.00%
Elapsed real time = 0.11 sec. (tree size = 0.00 MB, solutions = 2)
Root node processing (before b&c):
Real time = 0.02
Sequential b&c:
Real time = 0.00
-------
Total (root+branch&cut) = 0.02 sec.
MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Tried aggregator 1 time.
LP Presolve eliminated 4109 rows and 4016 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec.
Fixed MIP status(1): optimal
Proven optimal solution.
MIP Solution: 92.825775 (213 iterations, 0 nodes)
Final Solve: 92.825775 (0 iterations)
Best possible: 92.825775
Absolute gap: 0.000000
Relative gap: 0.000000
--- Reading solution for model master
--- Executing after solve: elapsed 0:00:04.861
--- benders3.gms(358) 89 Mb
*** Status: Normal completion
--- Job benders3.gms Stop 12/10/22 14:25:56 elapsed 0:00:04.910

How to use bob.measure.load.split()

I'm a student studying with a focus on machine learning, and I'm interested in authentication.
I am interested in your library because I want to calculate the EER.
Sorry for the basic question, but please tell me about bob.measure.load.split().
Is the file format required by this correct in the perception that the first column is the correct label and the second column is the predicted score of the model?
like
# file.txt
|label|prob |
| -1 | 0.3 |
| 1 | 0.5 |
| -1 | 0.8 |
...
In addition, to actually calculate the EER, should I follow the following procedure?
neg, pos = bob.measure.load.split('file.txt')
eer = bob.measure.eer(neg, pos)
Sincerely.
You have two options of calculating EER with bob.measure:
Use the Python API to calculate EER using numpy arrays.
Use the command line application to generate error rates (including EER) and plots
Using Python API
First, you need to load the scores into memory and split them into positive and negative scores.
For examples:
import numpy as np
import bob.measure
positives = np.array([0.5, 0.5, 0.6, 0.7, 0.2])
negatives = np.array([0.0, 0.0, 0.6, 0.2, 0.2])
eer = bob.measure.eer(negatives, positives)
print(eer)
This will print 0.2. All you need to take care is that your positive comparison scores are higher than negative comparisons. That is your model should score higher for positive samples.
Using command line
bob.measure also comes with a suite of command line commands that can help you get the error rates. To use the command line, you need to save the scores in a text file. This file is made of two columns where columns are separated by space. For example the score file for the same example would be:
$ cat scores.txt
1 0.5
1 0.5
1 0.6
1 0.7
1 0.2
-1 0.0
-1 0.0
-1 0.6
-1 0.2
-1 0.2
and then you would call
$ bob measure metrics scores.txt
[Min. criterion: EER ] Threshold on Development set `scores.txt`: 3.500000e-01
================================ =============
.. Development
================================ =============
False Positive Rate 20.0% (1/5)
False Negative Rate 20.0% (1/5)
Precision 0.8
Recall 0.8
F1-score 0.8
Area Under ROC Curve 0.8
Area Under ROC Curve (log scale) 0.7
================================ =============
Ok it didn't print EER exactly but EER = (FPR+FNR)/2.
Using bob.bio.base command line
If your scores are the results of a biometrics experiment,
then you want to save your scores in the 4 or 5 column formats of bob.bio.base.
See an example in https://gitlab.idiap.ch/bob/bob.bio.base/-/blob/3efccd3b637ee73ec68ed0ac5fde2667a943bd6e/bob/bio/base/test/data/dev-4col.txt and documentation in https://www.idiap.ch/software/bob/docs/bob/bob.bio.base/stable/experiments.html#evaluating-experiments
Then, you would call bob bio metrics scores-4-col.txt to get biometrics related metrics.

AMPL Non-Linear least Square

Could anyone help me to find the error in this AMPL's code for a simple least-square error base on the function:
F(X)=1/1+e^-x
param N>=1;# N Number of simulations
param M>=1;# Number of inputs
param simulations {1..N};
param training{1..N,1..M};
var W{1..10};
minimize obj: sum{i in simulations , j in 1..4} (1/(1+exp-(W[9]/(1+exp(-
W[j]/(1+exp(-training[i][j]))))+ W[10]/(1+exp(-W[2*j]/(1+exp(-training[i][j]))))))-training[i][5])^2;
'###### DATA
param N:=6;
param M:=4;
param training:
1 2 3 4 5 :=
1 0.209 0.555 0.644 0.355 0.0
2 0.707 0.450 0.587 0.305 1.0
3 0.579 0.521 0.745 0.394 1.0
4 0.574 0.883 0.211 0.550 1.0
5 0.797 0.055 0.430 0.937 1.0
6 0.782 0.865 0.114 0.317 1.0 ;
Thank you!
A couple of things:
is that quote mark before ###### DATA meant to be there?
You have specified that training has dimension N x M, and your data specifies that N=6, M=4, but you then define training as 6 x 5 and your objective function also refers to column 5.
If that doesn't answer your question, you might want to give more information about what error messages you're getting.

AWK--Storing truncated values in arrays

I have a formula in my awk script which outputs non-integer numbers with variable number of decimals. So, I was wondering how I can save the outputs with a certain number of decimals, say for example 2, in an array. As an example:
awk 'BEGIN{for(i=1;i<10;i++){array[3/i]}}'
You can use sprintf():
awk 'BEGIN{for(i=1;i<10;i++){array[sprintf("%.2f", 3/i)]}}'
This will create an array with the following indexes:
1.00
0.50
0.33
0.60
0.43
1.50
3.00
0.38
0.75