-
Notifications
You must be signed in to change notification settings - Fork 0
/
A_AdvanceMachineLearning.java
1128 lines (1021 loc) · 55.2 KB
/
A_AdvanceMachineLearning.java
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import ij.plugin.filter.GaussianBlur;
import ij.process.ImageProcessor;
import org.scijava.plugin.Plugin;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JTextArea;
import org.pentaho.packageManagement.PackageManager;
import weka.core.Instances;
import weka.core.converters.ArffSaver;
import weka.core.converters.CSVLoader;
import weka.core.WekaPackageManager;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import weka.core.Instances;
import java.io.File;
import ij.IJ;
import static ij.IJ.URL;
import static ij.IJ.getDirectory;
import static ij.IJ.selectWindow;
import static ij.IJ.write;
import ij.ImagePlus;
import ij.Macro;
import ij.Prefs;
import static ij.Prefs.set;
import ij.gui.Roi;
import ij.gui.WaitForUserDialog;
import ij.io.OpenDialog;
import ij.io.Opener;
import static ij.measure.CurveFitter.f;
import ij.plugin.RoiRotator;
import ij.plugin.frame.RoiManager;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Desktop;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Image;
import static java.awt.SystemColor.window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import static java.io.File.separator;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import static javax.management.Query.value;
import javax.rmi.CORBA.Util;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.filechooser.FileNameExtensionFilter;
import weka.classifiers.Classifier;
import weka.classifiers.Evaluation;
import weka.classifiers.bayes.NaiveBayes;
import weka.classifiers.evaluation.output.prediction.PlainText;
import weka.classifiers.functions.SMOreg;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.converters.ConverterUtils.DataSource;
import weka.classifiers.rules.DecisionTable;
import weka.core.Debug.Random;
import weka.core.Range;
import weka.core.converters.ArffSaver;
import weka.core.converters.CSVLoader;
import weka.core.pmml.jaxbbindings.NaiveBayesModel;
import weka.classifiers.bayes.NaiveBayes;
import weka.classifiers.evaluation.Prediction;
import weka.classifiers.functions.MultilayerPerceptron;
import weka.classifiers.misc.SerializedClassifier;
import weka.classifiers.trees.J48;
import weka.classifiers.functions.MultilayerPerceptron;
import weka.core.Attribute;
import static weka.core.Debug.DBO.p;
import weka.core.Environment;
import weka.core.FastVector;
import weka.core.SerializationHelper;
import static weka.core.SerializationHelper.write;
import weka.core.Utils;
import weka.core.converters.ArffLoader.ArffReader;
import static weka.core.converters.ConverterUtils.DataSink.write;
import weka.core.converters.Loader;
import weka.core.converters.TextDirectoryLoader;
import weka.core.pmml.Function;
import weka.filters.Filter;
import weka.filters.unsupervised.attribute.Add;
import weka.filters.unsupervised.attribute.StringToWordVector;
import static weka.gui.explorer.ExplorerDefaults.set;
/**
*
* @author usuario
*/
public class A_AdvanceMachineLearning extends javax.swing.JInternalFrame {
private JTextArea textArea;
private JButton btn;
private String model;
private String file;
private Object nb;
private String file2;
private String path;
private String pathway;
private String out;
int codigo;
String nombre;
private String valor;
private String valor1;
private String valor2;
private String valor3;
private String valor4;
private String valor5;
private String label;
public ArrayList<String> classif = new ArrayList<String>();
private ArrayList<String> list = new ArrayList<String>();
public String liststring;
private ArrayList<String> target = new ArrayList<String>();
private String target2;
private String name1;
private String name2;
private String file3;
private String name3;
public String nf1;
/**
* Creates new form AdvanceMachineLearning
*/
public A_AdvanceMachineLearning() {
super("Advanced Machine Learning Interface");
initComponents();
textArea = new JTextArea();
btn = new JButton("Click Me!");
add(textArea, BorderLayout.CENTER);
add(btn, BorderLayout.SOUTH);
initComponents();
txtlabel.setVisible(false);
txtpath.setVisible(false);
editor.setEditorKit(JEditorPane.createEditorKitForContentType("text/html"));
editor.setEditable(false);
editor.setOpaque(false);
editor.setText("Welcome to <a href='http://www.cs.waikato.ac.nz/ml/weka/'>WEKA homepage</a>.");
editor.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent hle) {
if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {
System.out.println(hle.getURL());
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(hle.getURL().toURI());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
});
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel7 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
txtmodel = new javax.swing.JTextField();
txtlabel = new javax.swing.JTextField();
txtpath = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
txtarea = new javax.swing.JTextArea();
jScrollPane2 = new javax.swing.JScrollPane();
txtarea2 = new javax.swing.JTextArea();
jLabel3 = new javax.swing.JLabel();
editor = new javax.swing.JEditorPane();
jTabbedPane2 = new javax.swing.JTabbedPane();
jPanel4 = new javax.swing.JPanel();
txtcodigo7 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
txtcodigo5 = new javax.swing.JTextField();
jLabel18 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
txtcodigo2 = new javax.swing.JTextField();
jLabel22 = new javax.swing.JLabel();
txtcodigo3 = new javax.swing.JTextField();
txtcodigo4 = new javax.swing.JTextField();
jLabel20 = new javax.swing.JLabel();
jLabel21 = new javax.swing.JLabel();
txtcodigo1 = new javax.swing.JTextField();
jLabel23 = new javax.swing.JLabel();
txtcodigo6 = new javax.swing.JTextField();
jPanel5 = new javax.swing.JPanel();
jLabel24 = new javax.swing.JLabel();
interval2 = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
interval1 = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jLabel25 = new javax.swing.JLabel();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jLabel8 = new javax.swing.JLabel();
jButton6 = new javax.swing.JButton();
txtdata4 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jLabel9 = new javax.swing.JLabel();
jButton10 = new javax.swing.JButton();
jLabel12 = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
txtdata = new javax.swing.JTextField();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0));
setTitle("Advance Machine Learning");
setMinimumSize(new java.awt.Dimension(38, 33));
setPreferredSize(new java.awt.Dimension(891, 662));
jLabel7.setText("Select a single file you want to classify ");
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/model.png"))); // NOI18N
jButton2.setText(" New model premade with WEKA software");
jButton2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
txtmodel.setEditable(false);
txtmodel.setBackground(new java.awt.Color(255, 255, 255));
txtmodel.setForeground(new java.awt.Color(153, 153, 153));
txtmodel.setText("(Model of prediction name)");
txtmodel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtmodelActionPerformed(evt);
}
});
txtlabel.setEditable(false);
txtlabel.setForeground(new java.awt.Color(232, 232, 232));
txtlabel.setText("txtlabel");
txtlabel.setBorder(null);
txtlabel.setCaretColor(new java.awt.Color(232, 232, 232));
txtlabel.setDisabledTextColor(new java.awt.Color(232, 232, 232));
txtlabel.setEnabled(false);
txtlabel.setSelectedTextColor(new java.awt.Color(232, 232, 232));
txtlabel.setSelectionColor(new java.awt.Color(232, 232, 232));
txtlabel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtlabelActionPerformed(evt);
}
});
txtpath.setEditable(false);
txtpath.setForeground(new java.awt.Color(232, 232, 232));
txtpath.setText("txtlabel");
txtpath.setBorder(null);
txtpath.setCaretColor(new java.awt.Color(232, 232, 232));
txtpath.setDisabledTextColor(new java.awt.Color(232, 232, 232));
txtpath.setEnabled(false);
txtpath.setSelectedTextColor(new java.awt.Color(232, 232, 232));
txtpath.setSelectionColor(new java.awt.Color(232, 232, 232));
txtpath.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtpathActionPerformed(evt);
}
});
txtarea.setEditable(false);
txtarea.setColumns(20);
txtarea.setRows(5);
jScrollPane1.setViewportView(txtarea);
txtarea2.setEditable(false);
txtarea2.setColumns(20);
txtarea2.setRows(5);
jScrollPane2.setViewportView(txtarea2);
jLabel3.setText(" Special thanks to the developers of WEKA ");
jTabbedPane2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
txtcodigo7.setText("target");
jLabel1.setText("Set attribute name :");
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(txtcodigo7, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(341, 341, 341))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtcodigo7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(147, Short.MAX_VALUE))
);
jTabbedPane2.addTab("Attribute name :", jPanel4);
txtcodigo5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtcodigo5ActionPerformed(evt);
}
});
jLabel18.setText("4º label");
jLabel17.setText("3º Label ");
jLabel19.setText("1º Label ");
txtcodigo2.setText("rods");
txtcodigo2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtcodigo2ActionPerformed(evt);
}
});
jLabel22.setText("Morphological label used in your training model ");
txtcodigo3.setText("networks");
txtcodigo4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtcodigo4ActionPerformed(evt);
}
});
jLabel20.setText("2º Label");
jLabel21.setText("5º label");
txtcodigo1.setText("punctua");
txtcodigo1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtcodigo1ActionPerformed(evt);
}
});
jLabel23.setText("6º label");
txtcodigo6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtcodigo6ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel22)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtcodigo4, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel18))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtcodigo5, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel21))
.addGap(14, 14, 14)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel23)
.addComponent(txtcodigo6)))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(txtcodigo1, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtcodigo2, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel19)
.addGap(61, 61, 61)
.addComponent(jLabel20)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel17)
.addComponent(txtcodigo3, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE))))
.addGap(22, 22, 22))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel22)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel19)
.addComponent(jLabel20)
.addComponent(jLabel17))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtcodigo3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtcodigo2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtcodigo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel18)
.addComponent(jLabel23)
.addComponent(jLabel21))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtcodigo5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtcodigo6)
.addComponent(txtcodigo4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(71, 71, 71))
);
jTabbedPane2.addTab("Morphological label :", jPanel3);
jLabel24.setText("Select your pixel interval :");
jLabel24.setMaximumSize(new java.awt.Dimension(228, 14));
jLabel24.setMinimumSize(new java.awt.Dimension(228, 14));
interval2.setForeground(new java.awt.Color(153, 153, 153));
interval2.setText("1.000E16");
jLabel10.setText("Upper limit");
interval1.setForeground(new java.awt.Color(153, 153, 153));
interval1.setText("20.000");
jLabel11.setText("Lower limit");
jLabel25.setText("Option only available for \"Classification From Image\"");
jLabel25.setMaximumSize(new java.awt.Dimension(228, 14));
jLabel25.setMinimumSize(new java.awt.Dimension(228, 14));
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(interval2, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
.addComponent(interval1))
.addGap(35, 35, 35)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel11)
.addComponent(jLabel10)))
.addComponent(jLabel25, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(138, 138, Short.MAX_VALUE))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel25, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, Short.MAX_VALUE)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(interval1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11))
.addGap(18, 18, 18)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(interval2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10))
.addGap(56, 56, 56))
);
jTabbedPane2.addTab("Display selection :", jPanel5);
jTabbedPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jLabel8.setText("Select a single file you want to classify ");
jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/picture.png"))); // NOI18N
jButton6.setText("Classify directly from Image");
jButton6.setActionCommand("Step 2.2 - Open Image");
jButton6.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
txtdata4.setEditable(false);
txtdata4.setBackground(new java.awt.Color(255, 255, 255));
txtdata4.setForeground(new java.awt.Color(153, 153, 153));
txtdata4.setText("(Image Name)");
txtdata4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtdata4ActionPerformed(evt);
}
});
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/loadfile.png"))); // NOI18N
jButton1.setText("Display an example of training data, used for generation WEKA models");
jButton1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtdata4))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 415, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(33, 33, 33)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton6)
.addComponent(txtdata4, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(47, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Clasification From Image", jPanel1);
jLabel9.setText("using your settings");
jButton10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/classi.png"))); // NOI18N
jButton10.setText("Step 2 - Make Prediction with custom model ");
jButton10.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});
jLabel12.setText("Classificy your [CSV] fiel data ");
jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/load.png"))); // NOI18N
jButton3.setText("Step 1 - Upload previews output files [CSV]");
jButton3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
txtdata.setEditable(false);
txtdata.setBackground(new java.awt.Color(255, 255, 255));
txtdata.setForeground(new java.awt.Color(153, 153, 153));
txtdata.setText("(Data Field name)");
txtdata.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtdataActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 313, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtdata, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton3)
.addComponent(txtdata, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
.addComponent(jButton10)
.addGap(40, 40, 40))
);
jTabbedPane1.addTab("Classification from [CSV] files", jPanel2);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane2)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(txtlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jTabbedPane1)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton2)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtmodel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(296, 296, 296)
.addComponent(txtpath, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE)))
.addGap(5, 5, 5)
.addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(25, 25, 25)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(13, 13, 13))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(editor, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(68, 68, 68))
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(1, 1, 1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton2)
.addComponent(txtmodel, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addComponent(txtpath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtlabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 398, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(editor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
//select model
//IJ.showMessage("upload a model of machine learning "); // TODO add your handling code here:
UIManager.put("OptionPane.yesButtonText", "Confirm");
UIManager.put("OptionPane.noButtonText", "Cancel");
int dialogButton = JOptionPane.YES_NO_OPTION;
int dialogResult = JOptionPane.showConfirmDialog(this, "We strongly recommend to use the algorith J48 in your model", "Advance Machine learning", dialogButton, JOptionPane.WARNING_MESSAGE);
if (dialogResult == 0) {
System.out.println("Yes option");
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("MODEL FILES", "model", "text");
chooser.setFileFilter(filter);
chooser.setMultiSelectionEnabled(false);
//chooser.setMultiSelectionEnable(true);
int result = chooser.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = chooser.getSelectedFile();
System.out.println("Selected file: " + selectedFile.getAbsolutePath());
txtpath.setText(selectedFile.getAbsolutePath());
this.model = chooser.getSelectedFile().getAbsolutePath();
txtarea.setText("You have choose to load the model: " + chooser.getSelectedFile().getName());
txtmodel.setText(chooser.getSelectedFile().getName());
}
} else {
System.out.println("No Option");
}
}//GEN-LAST:event_jButton2ActionPerformed
private void txtmodelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtmodelActionPerformed
txtmodel.setEditable(false);
txtmodel.setEnabled(false); // TODO add your handling code here:
}//GEN-LAST:event_txtmodelActionPerformed
private void txtcodigo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtcodigo1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtcodigo1ActionPerformed
private void txtcodigo2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtcodigo2ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtcodigo2ActionPerformed
private void txtcodigo4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtcodigo4ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtcodigo4ActionPerformed
private void txtcodigo5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtcodigo5ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtcodigo5ActionPerformed
private void txtcodigo6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtcodigo6ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtcodigo6ActionPerformed
private void txtlabelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtlabelActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtlabelActionPerformed
private void txtpathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtpathActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtpathActionPerformed
private void txtdataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtdataActionPerformed
txtdata.setEditable(false);
txtdata.setEnabled(false); // TODO add your handling code here:
}//GEN-LAST:event_txtdataActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("TEXT FILES", "csv", "text");
chooser.setFileFilter(filter);
chooser.setMultiSelectionEnabled(true);
int result = chooser.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = chooser.getSelectedFile();
System.out.println("Selected file: " + selectedFile.getAbsolutePath());
this.file2 = chooser.getSelectedFile().getAbsolutePath();
try {
CSVLoader loader = new CSVLoader();
loader.setSource(new File(this.file2));
Instances data = loader.getDataSet();
System.out.println(data);
// save ARFF
this.file2 = this.file2.replaceFirst("[.][^.]+$", "");
String arffile = this.file2 + ".arff";
System.out.println(arffile);
ArffSaver saver = new ArffSaver();
saver.setInstances(data);
saver.setFile(new File(arffile));
saver.writeBatch();
} catch (IOException ex) {
Logger.getLogger(MachinLearningInterface.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println(this.file2);
//txtdata2.setText(this.file2);
}
txtarea.setText("Succesfully converted " + this.file2);
try {
FileReader reader = new FileReader(this.file2 + ".arff");
BufferedReader br = new BufferedReader(reader);
txtarea2.read(br, null);
br.close();
txtarea2.requestFocus();
} catch (Exception e2) {
System.out.println(e2);
}
txtdata.setText(chooser.getSelectedFile().getName());
txtarea.setText("You have choose to load the file: " + chooser.getSelectedFile().getName());
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
UIManager.put("OptionPane.yesButtonText", "Confirm");
UIManager.put("OptionPane.noButtonText", "Cancel");
int dialogButton = JOptionPane.YES_NO_OPTION;
int dialogResult = JOptionPane.showConfirmDialog(this, "The labels must be the same used in the weka model", "Advance Machine learning", dialogButton, JOptionPane.WARNING_MESSAGE);
if (dialogResult == 0) {
this.list.clear();
//txtcodigo1.setText("hola");
this.valor = txtcodigo1.getText();
this.valor1 = txtcodigo2.getText();
this.valor2 = txtcodigo3.getText();
this.valor3 = txtcodigo4.getText();
this.valor4 = txtcodigo5.getText();
this.valor5 = txtcodigo6.getText();
//IJ.showMessage("your label 1 is = "+valor+", "+valor1+", "+valor2+", "+valor3+", "+valor4);
// Array list
this.list.add(this.valor);
this.list.add(this.valor1);
this.list.add(this.valor2);
this.list.add(this.valor3);
this.list.add(this.valor4);
this.list.add(this.valor5);
this.list.removeAll(Arrays.asList("", null));
System.out.println(this.list);
this.liststring = "";
for (String s : this.list) {
this.liststring += s + ",";
}
txtlabel.setText(this.liststring);
System.out.println(this.liststring);
txtarea.setText("Your labels are = " + this.list + "\nThe labels had been saved");
//txtarea.setText("The labels had been saved");
System.out.println(label);
} else {
System.out.println("No Option");
}
Instances data;
try {
System.out.println(this.file2 + "arff");
FileReader reader = new FileReader(this.file2 + ".arff");
BufferedReader br = new BufferedReader(reader);
data = new Instances(br);
System.out.println(data);
Instances newData = null;
Add filter;
newData = new Instances(data);
filter = new Add();
filter.setAttributeIndex("last");
filter.setNominalLabels(this.liststring);
filter.setAttributeName(txtcodigo7.getText());
filter.setInputFormat(newData);
newData = Filter.useFilter(newData, filter);
System.out.print("hola" + newData);
Vector vec = new Vector();
newData.setClassIndex(newData.numAttributes() - 1);
if (!newData.equalHeaders(newData)) {
throw new IllegalArgumentException("Train and test are not compatible!");
}
Classifier cls = (Classifier) weka.core.SerializationHelper.read(this.model);
System.out.println("PROVANT MODEL.classifyInstance");
for (int i = 0; i < newData.numInstances(); i++) {
double pred = cls.classifyInstance(newData.instance(i));
double[] dist = cls.distributionForInstance(newData.instance(i));
System.out.print((i + 1) + " - ");
System.out.print(newData.classAttribute().value((int) pred) + " - ");
//txtarea2.setText(Utils.arrayToString(dist));
System.out.println(Utils.arrayToString(dist));
vec.add(newData.classAttribute().value((int) pred));
classif.add(newData.classAttribute().value((int) pred));
}
classif.removeAll(Arrays.asList("", null));
System.out.println(classif);
String vecstring = "";
for (Object s : classif) {
vecstring += s + ",";
}
Map<String, Integer> seussCount = new HashMap<String, Integer>();
for (String t : classif) {
Integer i = seussCount.get(t);
if (i == null) {
i = 0;
}
seussCount.put(t, i + 1);
}
String s = vecstring;
String in = vecstring;
int i = 0;
Pattern p = Pattern.compile(this.valor1);
Matcher m = p.matcher( in );
while (m.find()) {
i++;
}
System.out.println("hola "+ i); // Prints 2
System.out.println(seussCount);
txtarea2.append("Your file:" + this.file2 + "arff"
+ "\n is composed by" + seussCount);
IJ.showMessage("Your file:" + this.file2 + "arff"
+ "\n is composed by" + seussCount);
} catch (Exception ex) {
Logger.getLogger(MachinLearningInterface.class.getName()).log(Level.SEVERE, null, ex);
}
//IJ.showMessage("analysing complete ");// TODO add your handling code here:
}//GEN-LAST:event_jButton10ActionPerformed
private void txtdata4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtdata4ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtdata4ActionPerformed
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
UIManager.put("OptionPane.yesButtonText", "Confirm");
UIManager.put("OptionPane.noButtonText", "Cancel");
int dialogButton = JOptionPane.YES_NO_OPTION;
int dialogResult = JOptionPane.showConfirmDialog(this, "The labels must be the same used in the weka model", "Advance Machine learning", dialogButton, JOptionPane.WARNING_MESSAGE);
if (dialogResult == 0) {
this.list.clear();
//txtcodigo1.setText("hola");
this.valor = txtcodigo1.getText();
this.valor1 = txtcodigo2.getText();
this.valor2 = txtcodigo3.getText();
this.valor3 = txtcodigo4.getText();