Skip to content

Commit a4b4ac5

Browse files
committed
found new consolidations
1 parent c9547d4 commit a4b4ac5

File tree

8 files changed

+141
-26
lines changed

8 files changed

+141
-26
lines changed

scripts/builtin/fixInvalidLengthsApply.dml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
# INPUT:
2525
# ------------------------
2626
# X ---
27-
# mask ---
28-
# ql ---
29-
# qu ---
27+
# Mask ---
28+
# QL ---
29+
# QU ---
3030
# ------------------------
3131
#
3232
# OUTPUT:
@@ -35,15 +35,15 @@
3535
# M ---
3636
# ------------------------
3737

38-
f_fixInvalidLengthsApply = function(Frame[Unknown] X, Matrix[Double] mask, Matrix[Double] qLow, Matrix[Double] qUp)
38+
f_fixInvalidLengthsApply = function(Frame[Unknown] X, Matrix[Double] Mask, Matrix[Double] QL, Matrix[Double] QU)
3939
return (Frame[Unknown] X)
4040
{
4141

4242
length = map(X, "x -> x.length()")
4343
length = as.matrix(length)
44-
length = replace(target = (length * mask), pattern = NaN, replacement = 0)
45-
M = ( length < qLow | length > qUp)
46-
# # # check if mask vector has 1 in more than one column
44+
length = replace(target = (length * Mask), pattern = NaN, replacement = 0)
45+
M = ( length < QL | length > QU)
46+
# # # check if Mask vector has 1 in more than one column
4747
# # # this indicates that two values are being swapped and can be fixed
4848
rowCountSwap = rowSums(M) >= 2
4949
rowCountDangling = rowSums(M) > 0 & rowSums(M) < 2
@@ -64,7 +64,7 @@ return (Frame[Unknown] X)
6464
tmp = X[rowIdx, id1]
6565
X[rowIdx, id1] = X[rowIdx, id2]
6666
X[rowIdx, id2] = tmp
67-
# # remove the mask for fixed entries
67+
# # remove the Mask for fixed entries
6868
M[rowIdx, id1] = 0
6969
M[rowIdx, id2] = 0
7070
}
@@ -82,7 +82,7 @@ return (Frame[Unknown] X)
8282
colIdx = removeEmpty(target = colIds[rowIdx], margin="cols")
8383
id1 = as.scalar(colIdx[1, 1])
8484
X[rowIdx, id1] = ""
85-
# # remove the mask for fixed entries
85+
# # remove the Mask for fixed entries
8686
M[rowIdx, id1] = 0
8787
}
8888
}

scripts/builtin/winsorizeApply.dml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
# INPUT:
2626
# --------------------------------------------------
2727
# X Input feature matrix
28-
# qLower row vector of upper bounds per column
29-
# qUpper row vector of lower bounds per column
28+
# ql row vector of upper bounds per column
29+
# qu row vector of lower bounds per column
3030
# --------------------------------------------------
3131
#
3232
# OUTPUT:
@@ -35,9 +35,9 @@
3535
# ------------------------------------------------
3636

3737

38-
m_winsorizeApply = function(Matrix[Double] X, Matrix[Double] qLower, Matrix[Double] qUpper)
38+
m_winsorizeApply = function(Matrix[Double] X, Matrix[Double] ql, Matrix[Double] qu)
3939
return (Matrix[Double] Y)
4040
{
4141
# replace values outside [ql,qu] w/ ql and qu respectively
42-
Y = min(max(X, qLower), qUpper);
42+
Y = min(max(X, ql), qu);
4343
}

src/main/python/systemds/operator/algorithm/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
from .builtin.scaleApply import scaleApply
176176
from .builtin.scaleMinMax import scaleMinMax
177177
from .builtin.selectByVarThresh import selectByVarThresh
178+
from .builtin.ses import ses
178179
from .builtin.setdiff import setdiff
179180
from .builtin.shapExplainer import shapExplainer
180181
from .builtin.sherlock import sherlock
@@ -184,6 +185,7 @@
184185
from .builtin.skewness import skewness
185186
from .builtin.sliceLine import sliceLine
186187
from .builtin.sliceLineDebug import sliceLineDebug
188+
from .builtin.sliceLineExtract import sliceLineExtract
187189
from .builtin.slicefinder import slicefinder
188190
from .builtin.smape import smape
189191
from .builtin.smote import smote
@@ -368,6 +370,7 @@
368370
'scaleApply',
369371
'scaleMinMax',
370372
'selectByVarThresh',
373+
'ses',
371374
'setdiff',
372375
'shapExplainer',
373376
'sherlock',
@@ -377,6 +380,7 @@
377380
'skewness',
378381
'sliceLine',
379382
'sliceLineDebug',
383+
'sliceLineExtract',
380384
'slicefinder',
381385
'smape',
382386
'smote',

src/main/python/systemds/operator/algorithm/builtin/fixInvalidLengthsApply.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@
2929

3030

3131
def fixInvalidLengthsApply(X: Frame,
32-
mask: Matrix,
33-
qLow: Matrix,
34-
qUp: Matrix):
32+
Mask: Matrix,
33+
QL: Matrix,
34+
QU: Matrix):
3535
"""
3636
Fix invalid lengths
3737
3838
3939
4040
:param X: ---
41-
:param mask: ---
42-
:param ql: ---
43-
:param qu: ---
41+
:param Mask: ---
42+
:param QL: ---
43+
:param QU: ---
4444
:return: ---
4545
:return: ---
4646
"""
4747

48-
params_dict = {'X': X, 'mask': mask, 'qLow': qLow, 'qUp': qUp}
48+
params_dict = {'X': X, 'Mask': Mask, 'QL': QL, 'QU': QU}
4949
return Matrix(X.sds_context,
5050
'fixInvalidLengthsApply',
5151
named_input_nodes=params_dict)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -------------------------------------------------------------
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
# -------------------------------------------------------------
21+
22+
# Autogenerated By : src/main/python/generator/generator.py
23+
# Autogenerated From : scripts/builtin/ses.dml
24+
25+
from typing import Dict, Iterable
26+
27+
from systemds.operator import OperationNode, Matrix, Frame, List, MultiReturn, Scalar
28+
from systemds.utils.consts import VALID_INPUT_TYPES
29+
30+
31+
def ses(x: Matrix,
32+
**kwargs: Dict[str, VALID_INPUT_TYPES]):
33+
"""
34+
Builtin function for simple exponential smoothing (SES).
35+
36+
37+
38+
:param x: Time series vector [shape: n-by-1]
39+
:param h: Forecasting horizon
40+
:param alpha: Smoothing parameter yhat_t = alpha * x_y + (1-alpha) * yhat_t-1
41+
:return: Forecasts [shape: h-by-1]
42+
"""
43+
44+
params_dict = {'x': x}
45+
params_dict.update(kwargs)
46+
return Matrix(x.sds_context,
47+
'ses',
48+
named_input_nodes=params_dict)

src/main/python/systemds/operator/algorithm/builtin/sliceLineDebug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def sliceLineDebug(TK: Matrix,
4040
4141
4242
:param TK: top-k slices (k x ncol(X) if successful)
43-
:param TKC: score, size, error of slices (k x 3)
43+
:param TKC: score, total/max error, size of slices (k x 4)
4444
:param tfmeta: transformencode meta data
4545
:param tfspec: transform specification
4646
:return: debug output collected as a string
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# -------------------------------------------------------------
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
# -------------------------------------------------------------
21+
22+
# Autogenerated By : src/main/python/generator/generator.py
23+
# Autogenerated From : scripts/builtin/sliceLineExtract.dml
24+
25+
from typing import Dict, Iterable
26+
27+
from systemds.operator import OperationNode, Matrix, Frame, List, MultiReturn, Scalar
28+
from systemds.utils.consts import VALID_INPUT_TYPES
29+
30+
31+
def sliceLineExtract(X: Matrix,
32+
e: Matrix,
33+
TK: Matrix,
34+
TKC: Matrix,
35+
**kwargs: Dict[str, VALID_INPUT_TYPES]):
36+
"""
37+
This builtin function takes the outputs of SliceLine and allows
38+
39+
40+
41+
42+
:param X: Feature matrix in recoded/binned representation
43+
:param e: Error vector of trained model
44+
:param TK: top-k slices (k x ncol(X) if successful)
45+
:param TKC: score, total/max error, size of slices (k x 4)
46+
:param k2: fist k2 slices to extract with k2 <= k
47+
:return: Selected rows from X which belong to k2 top slices
48+
:return: Selected rows from e which belong to k2 top slices
49+
"""
50+
51+
params_dict = {'X': X, 'e': e, 'TK': TK, 'TKC': TKC}
52+
params_dict.update(kwargs)
53+
54+
vX_0 = Matrix(X.sds_context, '')
55+
vX_1 = Matrix(X.sds_context, '')
56+
output_nodes = [vX_0, vX_1, ]
57+
58+
op = MultiReturn(X.sds_context, 'sliceLineExtract', output_nodes, named_input_nodes=params_dict)
59+
60+
vX_0._unnamed_input_nodes = [op]
61+
vX_1._unnamed_input_nodes = [op]
62+
63+
return op

src/main/python/systemds/operator/algorithm/builtin/winsorizeApply.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@
2929

3030

3131
def winsorizeApply(X: Matrix,
32-
qLower: Matrix,
33-
qUpper: Matrix):
32+
ql: Matrix,
33+
qu: Matrix):
3434
"""
3535
winsorizeApply takes the upper and lower quantile values per column, and
3636
remove outliers by replacing them with these upper and lower bound values.
3737
3838
3939
4040
:param X: Input feature matrix
41-
:param qLower: row vector of upper bounds per column
42-
:param qUpper: row vector of lower bounds per column
41+
:param ql: row vector of upper bounds per column
42+
:param qu: row vector of lower bounds per column
4343
:return: Matrix without outlier values
4444
"""
4545

46-
params_dict = {'X': X, 'qLower': qLower, 'qUpper': qUpper}
46+
params_dict = {'X': X, 'ql': ql, 'qu': qu}
4747
return Matrix(X.sds_context,
4848
'winsorizeApply',
4949
named_input_nodes=params_dict)

0 commit comments

Comments
 (0)