Skip to content

Commit

Permalink
[SYSTEMDS-3696] Minor robustness fix and pruning flags
Browse files Browse the repository at this point in the history
Closes apache#2107.
  • Loading branch information
fzoepffel authored and mboehm7 committed Sep 14, 2024
1 parent 726d21d commit 3a73b77
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions scripts/builtin/incSliceLine.dml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
# prevTK previous top-k slices (for incremental updates)
# prevTKC previous top-k scores (for incremental updates)
# encodeLat flag for encoding output lattice for less memory consumption
# pruningStrat flag for disabling certain pruning strategies
# (0 all, 1 all exact (score and size), 2 no score, 3 no size, 4 none)
# ---------------------------------------------------------------------------------------
#
# OUTPUT:
Expand Down Expand Up @@ -99,8 +101,9 @@ m_incSliceLine = function(
+ " -- see documentation for more details.");
}

disableIncScorePruning = (pruningStrat == 1 | pruningStrat == 3);
disableIncSizePruning = (pruningStrat >= 2);
disableIncScorePruning = (pruningStrat == 2 | pruningStrat == 4);
disableIncSizePruning = (pruningStrat >= 3);
disableIncApproxPruning = (pruningStrat >= 1)

t1 = time();

Expand Down Expand Up @@ -183,9 +186,9 @@ m_incSliceLine = function(
# 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);
maxscub = getMaxChangedScoreAllFeatures(nrow(X2), ncol(X2),
addedX2, removedX2, addedE, removedE, prevLattice, metaPrevLattice, prevStats,
encodeLat, differentOffsets, alpha, eAvg, minSup, prevFoffb, prevFoffe, foffb, foffe);
maxscub = getMaxChangedScoreAllFeatures(nrow(X2), ncol(X2), addedX2, removedX2,
addedE, removedE, prevLattice, metaPrevLattice, prevStats, encodeLat, differentOffsets,
alpha, eAvg, minSup, prevFoffb, prevFoffe, foffb, foffe, disableIncApproxPruning);
[S, R, selCols] = createAndScoreBasicSlicesInc(X2, changedX2, prevTK2, totalE, changedE,
eAvg, eAvgOld, eAvgNew, minSup, alpha, minsc, maxsc, maxscub, verbose, disableIncScorePruning);

Expand Down Expand Up @@ -328,7 +331,10 @@ createAndScoreBasicSlicesInc = function(Matrix[Double] X2, Matrix[Double] X2p,

# b) unchanged pruning
# (valid to prune feature if its previous max score was negative or below minsc)
selCols2 = selCols & (ncCnts > 0 | maxsc > max(0, minsc));
selCols2 = selCols;
if( !disableIncScorePruning ) {
selCols2 = selCols & (ncCnts > 0 | maxsc > max(0, minsc));
}

if( verbose ) {
n = as.integer(sum(selCols));
Expand Down Expand Up @@ -370,7 +376,11 @@ createAndScoreBasicSlicesInc = function(Matrix[Double] X2, Matrix[Double] X2p,
print("incSliceLine: dropping "+drop+"/"+n+" features below minSore = "+minsc+".");
}
cix = removeEmpty(target=attr, margin="rows", select=selCols3);
selCols = table(cix, 1, n2, 1);
if(sum(cix) != 0) {
selCols = table(cix, 1, n2, 1);
}else {
selCols = matrix(0, n2, 1);
}
}
else {
selCols = selCols2;
Expand Down Expand Up @@ -743,11 +753,12 @@ getMaxChangedScoreAllFeatures = function(Int numRows, Int numFeatures, Matrix[Do
Matrix[Double] removedX2, Matrix[Double] addedE, Matrix[Double] removedE,
List[Unknown] prevLattice, List[Unknown] metaPrevLattice, List[Unknown] prevStats,
Boolean encodeLat, Boolean differentOffsets, Double alpha, Double eAvg, Double minSup,
Matrix[Double] prevFoffb, Matrix[Double] prevFoffe, Matrix[Double] foffb, Matrix[Double] foffe)
Matrix[Double] prevFoffb, Matrix[Double] prevFoffe, Matrix[Double] foffb, Matrix[Double] foffe,
Boolean disableIncApproxPruning)
return(Matrix[Double] maxscub)
{
maxscub = matrix(-Inf, numFeatures, 1);
if( length(prevLattice) > 0 & nrow(addedX2) < 0.05*numRows ) {
if( length(prevLattice) > 0 & nrow(addedX2) < 0.05*numRows & !disableIncApproxPruning ) {
# compute upper bounds per feature for added subset
ss = t(colSums(addedX2));
se = t(t(addedE) %*% addedX2);
Expand Down

0 comments on commit 3a73b77

Please sign in to comment.