-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntropy.java
More file actions
88 lines (77 loc) · 2.94 KB
/
Copy pathEntropy.java
File metadata and controls
88 lines (77 loc) · 2.94 KB
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
package decision;
import java.lang.*;
import java.util.*;
import java.math.*;
public class Entropy {
public static void main(String[] args) {
String data[][]=new String[100][100];
int i=0,j=0,n=0,n1=0,nclass=0,k=0;
double t=0,tl=0,t1=0,tl1=0,ig=0;
int pc=0,nc=0;
String parameter[]=new String[10];
String vclass[]=new String[10];
String par;
Scanner sc = new Scanner(System.in);
System.out.println("ENTER THE TOTAL NUMBER OF RECORDS TO BE ENTERED:");
n=sc.nextInt();
System.out.println("ENTER THE TOTAL NUMBER OF PARAMETERS TO BE CONSIDERED:");
n1=sc.nextInt();
System.out.println("ENTER WHICH PARAMETERS TO BE CONSIDERED:");
for(i=0;i<n1;i++)
{
parameter[i]=sc.next();
}
System.out.println("FOR WHICH PARAMETER INFORMATION GAIN IS TO BE CONSIDERED:");
par=sc.next();
//System.out.println("ENTER NUMBER OF UNIQUE CLASS VALUES :");
// nclass=sc.nextInt();
System.out.println("ENTER UNIQUE CLASS VALUES TO BE CONSIDERED :");
for(i=0;i<2;i++)
{
vclass[i]=sc.next();
}
System.out.println("ENTER DATA SET TO BE CONSIDERED :");
for(i=0;i<n;i++)
{
for(j=0;j<n1;j++)
{p
data[i][j]=sc.next();
}
}
for(i=0;i<n1;i++)
{
if(par.equals(parameter[i]))
{
for(j=0;j<n;j++)
{
if((data[j][i]).equals(vclass[0]))
{
pc=pc+1;
}
else
nc=nc+1;
}
}
}
System.out.println(pc + " "+nc);
t=pc/(n);
System.out.println(t);
tl=Math.log(t);
System.out.println(tl);
t1=nc/(n);
System.out.println(t1);
tl1=Math.log(t1);
System.out.println(tl1);
ig=(-(t*tl)-(tl*tl1));
System.out.println("CONSIDERED DATA SET IS:");
for(i=0;i<n;i++)
{n
for(j=0;j<n1;j++)
{
System.out.print("\t"+data[i][j]);
}
System.out.println();
}
System.out.println("INFORMATION GAIN FOR"+" "+par+" IS:"+ig);
}
}