[SYSTEMDS-3696] Fix incremental SliceLine naming conflicts in namespace
This patch fixes the SliceLine builtin in order to allow joint use of
SliceLine and incSliceLine without any naming conflicts in the
.builtin namespace.
diff --git a/scripts/builtin/incSliceLine.dml b/scripts/builtin/incSliceLine.dml
index 08567f0..f00b3d8 100644
--- a/scripts/builtin/incSliceLine.dml
+++ b/scripts/builtin/incSliceLine.dml
@@ -180,7 +180,7 @@
# create and score basic slices (conjunctions of 1 feature)
maxsc = getMaxScoreAllFeatures(nrow(X2), ncol(X2), prevLattice, metaPrevLattice,
prevStats, encodeLat, differentOffsets, alpha, eAvg, prevFoffb, prevFoffe, foffb, foffe);
- [S, R, selCols] = createAndScoreBasicSlices(X2, changedX2, prevTK2, totalE, changedE,
+ [S, R, selCols] = createAndScoreBasicSlicesInc(X2, changedX2, prevTK2, totalE, changedE,
eAvg, eAvgOld, eAvgNew, minSup, alpha, minsc, maxsc, verbose, disableIncScorePruning);
# initialize lattice and statistics for incremental updates
@@ -194,10 +194,10 @@
Stats = list(R);
# initialize top-k
- [TK, TKC] = maintainTopK(S, R, prevTK2, prevTKC2, k, minSup, foffb, foffe);
+ [TK, TKC] = maintainTopKInc(S, R, prevTK2, prevTKC2, k, minSup, foffb, foffe);
if( verbose ) {
- [maxsc2, minsc2] = analyzeTopK(TKC);
+ [maxsc2, minsc2] = analyzeTopKInc(TKC);
print("incSliceLine: initial top-K: count="+nrow(TK)+", max="+maxsc2+", min="+minsc2+" (time="+(time()-t1)+")")
D = rbind(D, t(as.matrix(list(1, n2, nrow(S), maxsc2, minsc2))));
}
@@ -217,7 +217,7 @@
# enumerate candidate join pairs, incl size/error pruning
nrS = nrow(S);
- S = getPairedCandidates(S, R, TKC, level, eAvg, minSup, alpha, n2, foffb, foffe);
+ S = getPairedCandidatesInc(S, R, TKC, level, eAvg, minSup, alpha, n2, foffb, foffe);
S2 = S;
# prepare and store output lattice for next run
@@ -264,21 +264,21 @@
parfor( i in 1:ceil(nrow(S)/tpBlksz), check=0 ) {
beg = (i-1)*tpBlksz + 1;
end = min(i*tpBlksz, nrow(R));
- R[beg:end,] = evalSlice(X2, totalE, eAvg, t(S2[beg:end,]), level, alpha);
+ R[beg:end,] = evalSliceInc(X2, totalE, eAvg, t(S2[beg:end,]), level, alpha);
}
}
else { # data-parallel
- R = evalSlice(X2, totalE, eAvg, t(S2), level, alpha);
+ R = evalSliceInc(X2, totalE, eAvg, t(S2), level, alpha);
}
# update output statistics
Stats = append(Stats, R);
# maintain top-k after evaluation
- [TK, TKC] = maintainTopK(S, R, TK, TKC, k, minSup, foffb, foffe);
+ [TK, TKC] = maintainTopKInc(S, R, TK, TKC, k, minSup, foffb, foffe);
if(verbose) {
- [maxsc2, minsc2] = analyzeTopK(TKC);
+ [maxsc2, minsc2] = analyzeTopKInc(TKC);
valid = as.integer(sum(R[,2]>0 & R[,4]>=minSup));
print(" -- valid slices after eval: "+valid+"/"+nrow(S));
print(" -- top-K: count="+nrow(TK)+", max="+maxsc2+", min="+minsc2);
@@ -299,7 +299,7 @@
}
}
-createAndScoreBasicSlices = function(Matrix[Double] X2, Matrix[Double] X2p,
+createAndScoreBasicSlicesInc = function(Matrix[Double] X2, Matrix[Double] X2p,
Matrix[Double] prevTK2, Matrix[Double] e, Matrix[Double] ep,
Double eAvg, Double eAvgOld, Double eAvgNew, Double minSup, Double alpha,
Double minsc, Matrix[Double] maxsc, Boolean verbose, Boolean disableIncScorePruning)
@@ -338,13 +338,13 @@
S = table(seq(1,nrow(attr)), attr, nrow(attr), n2);
# score 1-slices and create initial top-k
- sc = score(ss, se, eAvg, alpha, nrow(X2));
+ sc = scoreInc(ss, se, eAvg, alpha, nrow(X2));
R = cbind(sc, se, sm, ss);
# c) score pruning
# compute upper bound scores for all remaining slices
if(minsc > -Inf & !disableIncScorePruning) {
- ubSc = scoreUB(ss, se, sm, eAvg, minSup, alpha, nrow(X2));
+ ubSc = scoreUBInc(ss, se, sm, eAvg, minSup, alpha, nrow(X2));
selCols3 = (ubSc > max(0, minsc));
S = removeEmpty(target=S, margin="rows", select=selCols3);
R = removeEmpty(target=R, margin="rows", select=selCols3);
@@ -361,14 +361,14 @@
}
}
-score = function(Matrix[Double] ss, Matrix[Double] se, Double eAvg, Double alpha, Integer n)
+scoreInc = function(Matrix[Double] ss, Matrix[Double] se, Double eAvg, Double alpha, Integer n)
return(Matrix[Double] sc)
{
sc = alpha * ((se/ss) / eAvg - 1) - (1-alpha) * (n/ss - 1);
sc = replace(target=sc, pattern=NaN, replacement=-Inf);
}
-scoreUB = function(Matrix[Double] ss, Matrix[Double] se, Matrix[Double] sm,
+scoreUBInc = function(Matrix[Double] ss, Matrix[Double] se, Matrix[Double] sm,
Double eAvg, Integer minSup, Double alpha, Integer n)
return(Matrix[Double] sc)
{
@@ -384,7 +384,7 @@
}
-maintainTopK = function(Matrix[Double] S, Matrix[Double] R,
+maintainTopKInc = function(Matrix[Double] S, Matrix[Double] R,
Matrix[Double] TK, Matrix[Double] TKC, Integer k,
Integer minSup, Matrix[Double] foffb, Matrix[Double] foffe)
return(Matrix[Double] TK, Matrix[Double] TKC)
@@ -419,7 +419,7 @@
}
}
-analyzeTopK = function(Matrix[Double] TKC) return(Double maxsc, Double minsc) {
+analyzeTopKInc = function(Matrix[Double] TKC) return(Double maxsc, Double minsc) {
maxsc = -Inf;
minsc = -Inf;
if( nrow(TKC)>0 ) {
@@ -428,7 +428,7 @@
}
}
-getPairedCandidates = function(Matrix[Double] S,
+getPairedCandidatesInc = function(Matrix[Double] S,
Matrix[Double] R, Matrix[Double] TKC, Integer level,
Double eAvg, Integer minSup, Double alpha, Integer n2,
Matrix[Double] foffb, Matrix[Double] foffe)
@@ -490,8 +490,8 @@
ubError = replace(target=ubError, pattern=Inf, replacement=0);
ubMError = 1/rowMaxs(map * (1/t(sm)));
ubMError = replace(target=ubMError, pattern=Inf, replacement=0);
- ubScores = scoreUB(ubSizes, ubError, ubMError, eAvg, minSup, alpha, n2);
- [maxsc, minsc] = analyzeTopK(TKC);
+ ubScores = scoreUBInc(ubSizes, ubError, ubMError, eAvg, minSup, alpha, n2);
+ [maxsc, minsc] = analyzeTopKInc(TKC);
# score pruning
fScores = (ubScores > minsc & ubScores > 0)
@@ -512,7 +512,7 @@
}
}
-evalSlice = function(Matrix[Double] X, Matrix[Double] e, Double eAvg,
+evalSliceInc = function(Matrix[Double] X, Matrix[Double] e, Double eAvg,
Matrix[Double] tS, Integer l, Double alpha)
return(Matrix[Double] R)
@@ -525,7 +525,7 @@
sm = t(colMaxs(I * e)); # maximum tuple error in slice
# score of relative error and relative size
- sc = score(ss, se, eAvg, alpha, nrow(X));
+ sc = scoreInc(ss, se, eAvg, alpha, nrow(X));
R = cbind(sc, se, sm, ss);
}
@@ -602,7 +602,7 @@
sm = t(colMaxs(I * totalE)); # maximum tuple error in slice
# score slice and if applicable set min score for pruning
- sc = score(ss, se, eAvg, alpha, nrow(X2));
+ sc = scoreInc(ss, se, eAvg, alpha, nrow(X2));
sc = replace(target=sc, pattern=-Inf, replacement=0)
R = cbind(sc, se, sm, ss);
minsc = min(sc);
@@ -711,7 +711,7 @@
if( length(prevStats) >= level ) {
R = as.matrix(prevStats[level]);
# rescaling of scores according to new size of X and eAvg
- sc = score(R[,4], R[,2], eAvg, alpha, numRows);
+ sc = scoreInc(R[,4], R[,2], eAvg, alpha, numRows);
# robustness for S * sc creating NaNs because 0 * -Inf = NaN
sc = replace(target=sc, pattern=-Inf, replacement=0);
maxsc = max(maxsc, t(colMaxs(S*sc)));