File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
src/main/java/com/bhegde/ann Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 8
8
<artifactId >AnnLearn</artifactId >
9
9
<version >1.0-SNAPSHOT</version >
10
10
11
+ <build >
12
+ <plugins >
13
+ <plugin >
14
+ <groupId >org.codehaus.mojo</groupId >
15
+ <artifactId >exec-maven-plugin</artifactId >
16
+ <configuration >
17
+ <mainClass >com.bhegde.ann.MainApp</mainClass >
18
+ </configuration >
19
+ </plugin >
20
+ </plugins >
21
+ </build >
11
22
12
23
</project >
Original file line number Diff line number Diff line change 1
1
package com .bhegde .ann ;
2
2
3
+ import java .math .BigDecimal ;
4
+ import java .math .RoundingMode ;
5
+
3
6
public class MainApp {
4
7
public static void main (String [] args ) {
5
8
ANN ann = new ANN (new Integer []{2 , 1 });
@@ -28,7 +31,15 @@ public static void main(String[] args) {
28
31
29
32
for (int i = 0 ; i <targets .length ; i ++)
30
33
{
31
- System .out .println (inputs [i ][0 ]+", " +inputs [i ][1 ]+" : " +ann .predict (inputs [i ])[0 ]);
34
+ System .out .println (inputs [i ][0 ]+", " +inputs [i ][1 ]+" : " +round ( ann .predict (inputs [i ])[0 ], 4 ) );
32
35
}
33
36
}
37
+
38
+ public static double round (double value , int places ) {
39
+ if (places < 0 ) throw new IllegalArgumentException ();
40
+
41
+ BigDecimal bd = new BigDecimal (value );
42
+ bd = bd .setScale (places , RoundingMode .HALF_UP );
43
+ return bd .doubleValue ();
44
+ }
34
45
}
You can’t perform that action at this time.
0 commit comments