forked from apache/systemds
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYSTEMDS-3696] New sliceLineDebug built-in function for usability
This patch adds a new sliceLineDebug function to present the top-k worst-slides returned from sliceLine (slicefinder) in a human readable format. This is the output for the Salaries dataset: sliceLineDebug: -- Slice #1: score=0.4041683676825298, size=248.0 ---- avg error=6.558681888351787E8, max error=8.524558818262574E9 ---- predicate: "rank" = "Prof" AND "sex" = "Male" -- Slice #2: score=0.3731763935666855, size=42.0 ---- avg error=8.271958572009121E8, max error=4.553584116646141E9 ---- predicate: "rank" = "Prof" AND "yrs.since.phd" = 31.25 -- Slice apache#3: score=0.3675193573989536, size=125.0 ---- avg error=6.758211389786526E8, max error=8.524558818262574E9 ---- predicate: "rank" = "Prof" AND "discipline" = "B" AND "sex" = "Male" -- Slice apache#4: score=0.35652331744984933, size=266.0 ---- avg error=6.307265846260264E8, max error=8.524558818262574E9 ---- predicate: "rank" = "Prof"
- Loading branch information
Showing
9 changed files
with
582 additions
and
387 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#------------------------------------------------------------- | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
#------------------------------------------------------------- | ||
|
||
# This builtin function takes the outputs of SliceLine and the | ||
# original transformencode meta data in order to print a human- | ||
# readable debug output of the resulting top-k slices. | ||
# | ||
# INPUT: | ||
# ------------------------------------------------------------------------------ | ||
# TK top-k slices (k x ncol(X) if successful) | ||
# TKC score, size, error of slices (k x 3) | ||
# tfmeta transformencode meta data | ||
# tfspec transform specification | ||
# ------------------------------------------------------------------------------ | ||
# | ||
# OUTPUT: | ||
# ------------------------------------------------------------------------------ | ||
# S debug output collected as a string | ||
# ------------------------------------------------------------------------------ | ||
|
||
m_sliceLineDebug = function(Matrix[Double] TK, | ||
Matrix[Double] TKC, Frame[Unknown] tfmeta, String tfspec) | ||
return(Matrix[Double] S) | ||
{ | ||
# FIXME: frame toString always pads to 100 rows | ||
# print("sliceLineDebug: input\n"+toString(TK)+"\n"+toString(TKC)+"\n"+toString(tfmeta)); | ||
print("sliceLineDebug:"); | ||
|
||
# prepare essential decoding info | ||
N = colnames(tfmeta); | ||
TKsafe = TK + (TK==0); # for vectorized decoding | ||
FTK = transformdecode(target=TKsafe, meta=tfmeta, spec=tfspec); | ||
|
||
# actual debug output | ||
for(i in 1:nrow(TK)) { | ||
TKi = TK[i,]; FTKi = FTK[i,]; | ||
print("-- Slice #"+i+": score="+as.scalar(TKC[i,1])+", size="+as.scalar(TKC[i,4])); | ||
print("---- avg error="+as.scalar(TKC[i,2]/TKC[i,4])+", max error="+as.scalar(TKC[i,3])); | ||
pred = ""; | ||
for(j in 1:ncol(TKi)) { | ||
if( as.scalar(TKi[1,j]) != 0 ) { | ||
tmp = as.scalar(N[1,j]) + " = " + as.scalar(FTK[i,j]); | ||
pred = ifelse(pred=="", tmp, pred+" AND "+tmp); | ||
} | ||
} | ||
print("---- predicate: "+pred); | ||
} | ||
S = TK; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.