-
Notifications
You must be signed in to change notification settings - Fork 0
/
MachinLearningInterface.java
1402 lines (1247 loc) · 68.4 KB
/
MachinLearningInterface.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 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.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
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.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 static weka.core.converters.ConverterUtils.DataSink.write;
import weka.core.converters.Loader;
import weka.core.converters.TextDirectoryLoader;
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 MachinLearningInterface extends javax.swing.JFrame {
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;
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 NewJFrame1
*/
public MachinLearningInterface() {
super("Machine Learning Interface");
textArea = new JTextArea();
btn = new JButton("Click Me!");
add(textArea, BorderLayout.CENTER);
add(btn, BorderLayout.SOUTH);
initComponents();
jInternalFrame2.setVisible(false);
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() {
jButton1 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jFrame1 = new javax.swing.JFrame();
jMenu6 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jPopupMenu1 = new javax.swing.JPopupMenu();
jDialog1 = new javax.swing.JDialog();
jMenu9 = new javax.swing.JMenu();
jMenu10 = new javax.swing.JMenu();
jPopupMenu2 = new javax.swing.JPopupMenu();
jInternalFrame1 = new javax.swing.JInternalFrame();
jButton3 = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jButton7 = new javax.swing.JButton();
jLabel13 = new javax.swing.JLabel();
txtdata = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
jButton5 = new javax.swing.JButton();
txtdata3 = new javax.swing.JTextField();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
jButton4 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu2 = new javax.swing.JMenu();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jInternalFrame2 = new javax.swing.JInternalFrame();
jButton10 = new javax.swing.JButton();
jLabel9 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
txtmodel = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
txtcodigo1 = new javax.swing.JTextField();
jLabel21 = new javax.swing.JLabel();
jButton11 = new javax.swing.JButton();
txtcodigo5 = new javax.swing.JTextField();
txtcodigo4 = new javax.swing.JTextField();
jLabel22 = new javax.swing.JLabel();
txtcodigo3 = new javax.swing.JTextField();
txtcodigo2 = new javax.swing.JTextField();
txtcodigo6 = new javax.swing.JTextField();
jLabel23 = new javax.swing.JLabel();
jButton6 = new javax.swing.JButton();
txtdata4 = new javax.swing.JTextField();
txtlabel = new javax.swing.JTextField();
txtpath = new javax.swing.JTextField();
jMenuBar2 = new javax.swing.JMenuBar();
jMenu8 = new javax.swing.JMenu();
jMenu1 = new javax.swing.JMenu();
jButton8 = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
txtarea = new javax.swing.JTextArea();
jScrollPane2 = new javax.swing.JScrollPane();
txtarea2 = new javax.swing.JTextArea();
jScrollPane5 = new javax.swing.JScrollPane();
editor = new javax.swing.JEditorPane();
advmachine = new javax.swing.JCheckBox();
jButton1.setText("jButton1");
jLabel4.setText("The user will be able to choose a directory and to convert all CSV files to ARFF extension ");
jLabel10.setText("Step 3 - Prediction and classification of the data ");
jLabel11.setText("Step 3 - Prediction and classification of the data ");
javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
jFrame1.getContentPane().setLayout(jFrame1Layout);
jFrame1Layout.setHorizontalGroup(
jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jFrame1Layout.setVerticalGroup(
jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
jMenu6.setText("jMenu6");
jMenuItem1.setText("jMenuItem1");
javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
jDialog1.getContentPane().setLayout(jDialog1Layout);
jDialog1Layout.setHorizontalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jDialog1Layout.setVerticalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
jMenu9.setText("jMenu9");
jMenu10.setText("jMenu10");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jInternalFrame1.setTitle("Default Machine Learning ");
jInternalFrame1.setVisible(true);
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);
}
});
jLabel6.setText("Step 1 - Directory window will be display in order");
jLabel8.setText("Step 2 - Prediction and classification of the data ");
jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/classi.png"))); // NOI18N
jButton7.setText("Step 2 - Classify data with our model of machine learning ");
jButton7.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
jLabel13.setText(" file in [step 1] using our default model ");
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);
}
});
jLabel14.setText("to select and upload the machine learning model ");
jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/picture.png"))); // NOI18N
jButton5.setText("Step 1 - Classify from Image");
jButton5.setActionCommand("Step 2.2 - Open Image");
jButton5.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
txtdata3.setEditable(false);
txtdata3.setBackground(new java.awt.Color(255, 255, 255));
txtdata3.setForeground(new java.awt.Color(153, 153, 153));
txtdata3.setText("(Image Name)");
txtdata3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtdata3ActionPerformed(evt);
}
});
jLabel15.setText("Step 1 - Directory window will be display in order");
jLabel16.setText("to select and upload the machine learning model ");
jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/picture.png"))); // NOI18N
jButton4.setText("Step 1 - Classify from Example Image");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jMenu2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/tools.png"))); // NOI18N
jMenu2.setText("Options");
jMenu2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jMenu2MouseClicked(evt);
}
});
jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/hola.png"))); // NOI18N
jMenuItem2.setText("Single file CSV convertor to ARFF");
jMenuItem2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jMenuItem2MouseClicked(evt);
}
});
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem2);
jMenuItem3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/directory.png"))); // NOI18N
jMenuItem3.setText("Directory File CSV converter to ARFF");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem3);
jMenuBar1.add(jMenu2);
jInternalFrame1.setJMenuBar(jMenuBar1);
javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
jInternalFrame1Layout.setHorizontalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator1)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel15)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtdata3, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGap(17, 17, 17)
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6))
.addGap(0, 0, Short.MAX_VALUE))))
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 297, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtdata))
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))))
.addContainerGap())
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jInternalFrame1Layout.setVerticalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel15)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel16)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton5)
.addComponent(txtdata3, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(50, 50, 50)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(43, 43, 43)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel14)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton3)
.addComponent(txtdata, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addComponent(jLabel8)
.addGap(1, 1, 1)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton7)
.addContainerGap(173, Short.MAX_VALUE))
);
jInternalFrame2.setTitle("Custom Machine Learning ");
jInternalFrame2.setVisible(true);
jButton10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/classi.png"))); // NOI18N
jButton10.setText("Step 5 - 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);
}
});
jLabel9.setText("file in [step 2] using the model upload in [step 1]");
jLabel12.setText("Step 5 - Prediction and classification of the data ");
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/model.png"))); // NOI18N
jButton2.setText("Step 3 - 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);
}
});
jLabel7.setText("Step 3 - Select a single file you want to classify ");
jLabel17.setText("3º Label ");
jLabel18.setText("4º label");
jLabel19.setText("1º Label ");
jLabel20.setText("2º Label");
txtcodigo1.setText("punctua");
txtcodigo1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtcodigo1ActionPerformed(evt);
}
});
jLabel21.setText("5º label");
jButton11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/labels.png"))); // NOI18N
jButton11.setText("Step 4 - Save new costum labels");
jButton11.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
txtcodigo5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtcodigo5ActionPerformed(evt);
}
});
txtcodigo4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtcodigo4ActionPerformed(evt);
}
});
jLabel22.setText("Step 4 - Morphological label used in your training model ");
txtcodigo3.setText("networks");
txtcodigo2.setText("rods");
txtcodigo2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtcodigo2ActionPerformed(evt);
}
});
txtcodigo6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtcodigo6ActionPerformed(evt);
}
});
jLabel23.setText("6º label");
jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/picture.png"))); // NOI18N
jButton6.setText("Step 1 - Classify 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);
}
});
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);
}
});
jMenu8.setText(" ");
jMenu8.setEnabled(false);
jMenuBar2.add(jMenu8);
jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Untitled-4.png"))); // NOI18N
jMenu1.setText("Close Plugin");
jMenu1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jMenu1MouseClicked(evt);
}
});
jMenuBar2.add(jMenu1);
jInternalFrame2.setJMenuBar(jMenuBar2);
javax.swing.GroupLayout jInternalFrame2Layout = new javax.swing.GroupLayout(jInternalFrame2.getContentPane());
jInternalFrame2.getContentPane().setLayout(jInternalFrame2Layout);
jInternalFrame2Layout.setHorizontalGroup(
jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame2Layout.createSequentialGroup()
.addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addGroup(jInternalFrame2Layout.createSequentialGroup()
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtmodel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel22)
.addGroup(jInternalFrame2Layout.createSequentialGroup()
.addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton10, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
.addComponent(jButton11, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jInternalFrame2Layout.createSequentialGroup()
.addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame2Layout.createSequentialGroup()
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtdata4, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtpath, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12)
.addGroup(jInternalFrame2Layout.createSequentialGroup()
.addGap(12, 12, 12)
.addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame2Layout.createSequentialGroup()
.addComponent(jLabel19)
.addGap(61, 61, 61)
.addComponent(jLabel20)
.addGap(66, 66, 66)
.addComponent(jLabel17))
.addGroup(jInternalFrame2Layout.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)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtcodigo3, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jInternalFrame2Layout.createSequentialGroup()
.addGroup(jInternalFrame2Layout.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(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel21)
.addComponent(txtcodigo5, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(14, 14, 14)
.addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel23)
.addComponent(txtcodigo6, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGap(0, 0, Short.MAX_VALUE))))
);
jInternalFrame2Layout.setVerticalGroup(
jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jInternalFrame2Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton2)
.addComponent(txtmodel, javax.swing.GroupLayout.PREFERRED_SIZE, 49, 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.UNRELATED)
.addComponent(jLabel22)
.addGap(29, 29, 29)
.addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel19)
.addComponent(jLabel20)
.addComponent(jLabel17))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jInternalFrame2Layout.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(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel18)
.addComponent(jLabel21)
.addComponent(jLabel23))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jInternalFrame2Layout.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(18, 18, 18)
.addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton11)
.addComponent(txtlabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(41, 41, 41)
.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)
.addComponent(jButton10)
.addGap(18, 18, 18)
.addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton6)
.addComponent(txtdata4, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(127, Short.MAX_VALUE))
);
jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/instruc.png"))); // NOI18N
jButton8.setText("Instructions ");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
jLabel3.setText(" Special thanks to the developers of WEKA ");
txtarea.setEditable(false);
txtarea.setColumns(20);
txtarea.setRows(5);
jScrollPane1.setViewportView(txtarea);
txtarea2.setColumns(20);
txtarea2.setRows(5);
jScrollPane2.setViewportView(txtarea2);
jScrollPane5.setViewportView(editor);
advmachine.setSelected(true);
advmachine.setText("Advance Machine learning");
advmachine.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
advmachineActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
.addComponent(jScrollPane1)))
.addGroup(layout.createSequentialGroup()
.addGap(68, 68, 68)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel3)
.addGroup(layout.createSequentialGroup()
.addGap(42, 42, 42)
.addComponent(jButton8))))
.addGroup(layout.createSequentialGroup()
.addGap(102, 102, 102)
.addComponent(advmachine)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jInternalFrame2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 398, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(advmachine)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3)
.addGap(23, 23, 23)
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addComponent(jInternalFrame1)
.addComponent(jInternalFrame2)
);
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:
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 jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
txtarea.setText("Converting, please wait... ");
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("TEXT FILES", "csv", "text");
chooser.setFileFilter(filter);
chooser.setMultiSelectionEnabled(true);
//chooser.setMultiSelectionEnable(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);
}
//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 jMenu1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu1MouseClicked
setVisible(false);
dispose();// TODO add your handling code here:
}//GEN-LAST:event_jMenu1MouseClicked
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
/**
* Creates new form NonModelJDialogDemo
*/
txtarea.setText("Set & open image... ");
String prova = IJ.getFilePath("");
//ImagePlus imp = IJ.openImage(prova);
IJ.open(prova);
IJ.setTool("freehand");
//imp.show();
this.name3 = IJ.getImage().getTitle();
//txtdata5.setText(prova);
this.name3 = prova.replaceFirst("[.][^.]+$", "");
setTitle(this.name3);
txtarea2.setText("the image you want to analyse is..."
+ "\n" + this.name3);
//new classifyfromimage1();
//new classifyfromimage1().setVisible(true);
classifyfromimage1 nf1 = new classifyfromimage1();
classifyfromimage1.txtlabel.setText(this.txtlabel.getText());
classifyfromimage1.txtpath.setText(this.txtpath.getText());
nf1.setVisible(true);
}//GEN-LAST:event_jButton6ActionPerformed
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
IJ.showMessage("With this plugin you will be abel to classify with a machine learning the mitochondria output. "
+ "\nobtain in the other part of the plugin. In order to classify, the data file MUST be ARFF "
+ "\n extension, otherwise, the prediction will not work. You can convert your CSV files to ARFF"
+ "\nUsing [step 1]. We have attach a trained machine learning with the J48 algorith using the "
+ "\nWEKA software with the opportunitifor the user to develop, using the WEKA, and upload(with [step 3])"
+ "\nhis own model of machine learning. For any question or suggestion contact us in this email "
+ "\[email protected]"); // TODO add your handling code here:
}//GEN-LAST:event_jButton8ActionPerformed
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
Instances data;
try {
data = new Instances(new BufferedReader(new FileReader(this.name3 + ".arff")));
Instances newData = null;
Add filter;
newData = new Instances(data);
filter = new Add();
filter.setAttributeIndex("last");
filter.setNominalLabels("rods,punctua,networks");
filter.setAttributeName("target");
filter.setInputFormat(newData);
newData = Filter.useFilter(newData, filter);
System.out.print(newData);
Vector vec = new Vector();
newData.setClassIndex(newData.numAttributes() - 1);
if (!newData.equalHeaders(newData)) {
throw new IllegalArgumentException("Train and test are not compatible!");
}
URL urlToModel = this.getClass().getResource("/" + "Final.model");
InputStream stream = urlToModel.openStream();
Classifier cls = (Classifier) weka.core.SerializationHelper.read(stream);
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) + " - ");