|
29 | 29 | # k Number of nearest neighbors |
30 | 30 | # beta Desired balance level after generation of synthetic data [0, 1] |
31 | 31 | # dth Distribution threshold |
| 32 | +# seed Seed for randomized data point selection |
32 | 33 | # -------------------------------------------------------------------------------------- |
33 | 34 | # |
34 | 35 | # OUTPUT: |
|
38 | 39 | # ------------------------------------------------------------------------------------- |
39 | 40 |
|
40 | 41 | m_adasyn = function(Matrix[Double] X, Matrix[Double] Y, Integer k = 2, |
41 | | - Double beta = 1.0, Double dth = 0.9) |
| 42 | + Double beta = 1.0, Double dth = 0.9, Integer seed = -1) |
42 | 43 | return (Matrix[Double] Xp, Matrix[Double] Yp) |
43 | 44 | { |
44 | 45 | if(k < 1) { |
@@ -74,7 +75,7 @@ m_adasyn = function(Matrix[Double] X, Matrix[Double] Y, Integer k = 2, |
74 | 75 | Ynonmajor = removeEmpty(target=Y, margin="rows", select=(Y!=majorIdx)) |
75 | 76 | NNR = knnbf(Xnonmajor, Xnonmajor, k+1) |
76 | 77 | NNR = matrix(NNR, rows=length(NNR), cols=1) |
77 | | - I = rand(rows=nrow(NNR), cols=1) < (G/nrow(NNR)) |
| 78 | + I = rand(rows=nrow(NNR), cols=1, seed=seed) < (G/nrow(NNR)) |
78 | 79 | NNRg = removeEmpty(target=NNR, margin="rows", select=I); |
79 | 80 | P = table(seq(1, nrow(NNRg)), NNRg, nrow(NNRg), nrow(Xnonmajor)); |
80 | 81 | Xp = rbind(X, P %*% Xnonmajor); |
|
0 commit comments