File: avoid_using_jafama.patch

package info (click to toggle)
xgboost-predictor-java 0.3.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,120 kB
  • sloc: java: 1,718; makefile: 32
file content (83 lines) | stat: -rw-r--r-- 2,746 bytes parent folder | download | duplicates (2)
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
Description: don't use unpackaged jafama to compute exp, use Math instead
Author: Pierre Gruet <pgt@debian.org>
Forwarded: not-needed
Last-Update: 2022-03-27

--- a/xgboost-predictor/build.gradle
+++ b/xgboost-predictor/build.gradle
@@ -1,8 +1,6 @@
 description = "Pure Java implementation of XGBoost predictor for online prediction tasks"
 
 dependencies {
-    compile group: 'net.jafama', name: 'jafama', version: '2.1.0'
-
     testCompile project(':xgboost-predictor-test')
     testCompile(group: 'junit', name: 'junit', version: '4.12') {
         exclude group: 'org.hamcrest', module: 'hamcrest-core'
--- a/xgboost-predictor/src/main/java/biz/k11i/xgboost/learner/ObjFunction.java
+++ b/xgboost-predictor/src/main/java/biz/k11i/xgboost/learner/ObjFunction.java
@@ -1,7 +1,6 @@
 package biz.k11i.xgboost.learner;
 
 import biz.k11i.xgboost.config.PredictorConfiguration;
-import net.jafama.FastMath;
 
 import java.io.Serializable;
 import java.util.HashMap;
@@ -55,16 +54,9 @@
      *                  or {@code false} if you don't want to use it but JDK's {@link Math#exp(double)}.
      */
     public static void useFastMathExp(boolean useJafama) {
-        if (useJafama) {
-            register("binary:logistic", new RegLossObjLogistic_Jafama());
-            register("reg:logistic", new RegLossObjLogistic_Jafama());
-            register("multi:softprob", new SoftmaxMultiClassObjProb_Jafama());
-
-        } else {
-            register("binary:logistic", new RegLossObjLogistic());
-            register("reg:logistic", new RegLossObjLogistic());
-            register("multi:softprob", new SoftmaxMultiClassObjProb());
-        }
+        register("binary:logistic", new RegLossObjLogistic());
+        register("reg:logistic", new RegLossObjLogistic());
+        register("multi:softprob", new SoftmaxMultiClassObjProb());
     }
 
     /**
@@ -112,18 +104,6 @@
     }
 
     /**
-     * Logistic regression.
-     * <p>
-     * Jafama's {@link FastMath#exp(double)} version.
-     * </p>
-     */
-    static class RegLossObjLogistic_Jafama extends RegLossObjLogistic {
-        double sigmoid(double x) {
-            return (1 / (1 + FastMath.exp(-x)));
-        }
-    }
-
-    /**
      * Multiclass classification.
      */
     static class SoftmaxMultiClassObjClassify extends ObjFunction {
@@ -180,17 +160,4 @@
             return Math.exp(x);
         }
     }
-
-    /**
-     * Multiclass classification (predicted probability).
-     * <p>
-     * Jafama's {@link FastMath#exp(double)} version.
-     * </p>
-     */
-    static class SoftmaxMultiClassObjProb_Jafama extends SoftmaxMultiClassObjProb {
-        @Override
-        double exp(double x) {
-            return FastMath.exp(x);
-        }
-    }
 }