Skip to content

Commit c504549

Browse files
committed
[MINOR] Update Python API
1 parent a41027f commit c504549

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from .builtin.WoE import WoE
2525
from .builtin.WoEApply import WoEApply
2626
from .builtin.abstain import abstain
27+
from .builtin.adasyn import adasyn
2728
from .builtin.als import als
2829
from .builtin.alsCG import alsCG
2930
from .builtin.alsDS import alsDS
@@ -199,6 +200,7 @@
199200
__all__ = ['WoE',
200201
'WoEApply',
201202
'abstain',
203+
'adasyn',
202204
'als',
203205
'alsCG',
204206
'alsDS',
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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/adasyn.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 adasyn(X: Matrix,
32+
Y: Matrix,
33+
**kwargs: Dict[str, VALID_INPUT_TYPES]):
34+
"""
35+
Builtin function for handing class imbalance using Adaptive Synthetic Sampling (ADASYN)
36+
by Haibo He et. al. In International Joint Conference on Neural Networks (2008). 1322-1328
37+
38+
39+
40+
:param X: Feature matrix [shape: n-by-m]
41+
:param Y: Class labels [shape: n-by-1]
42+
:param k: Number of nearest neighbors
43+
:param beta: Desired balance level after generation of synthetic data [0, 1]
44+
:param dth: Distribution threshold
45+
:param seed: Seed for randomized data point selection
46+
:return: Feature matrix of n original rows followed by G = (ml-ms)*beta synthetic rows
47+
:return: Class labels aligned with output X
48+
"""
49+
50+
params_dict = {'X': X, 'Y': Y}
51+
params_dict.update(kwargs)
52+
53+
vX_0 = Matrix(X.sds_context, '')
54+
vX_1 = Matrix(X.sds_context, '')
55+
output_nodes = [vX_0, vX_1, ]
56+
57+
op = MultiReturn(X.sds_context, 'adasyn', output_nodes, named_input_nodes=params_dict)
58+
59+
vX_0._unnamed_input_nodes = [op]
60+
vX_1._unnamed_input_nodes = [op]
61+
62+
return op

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ def incSliceLine(addedX: Matrix,
6565
:param prevTK: previous top-k slices (for incremental updates)
6666
:param prevTKC: previous top-k scores (for incremental updates)
6767
:param encodeLat: flag for encoding output lattice for less memory consumption
68-
:param pruningStrat: flag for disabling certain pruning strategies
69-
(0 all, 1 all exact (score and size), 2 no score, 3 no size, 4 none)
68+
:param pruningStrat: pruning strategy: 0 all pruning, 1 all exact pruning,
69+
2 only score pruning, 3 only max score pruning,
70+
4 only size pruning, 5 no pruning
7071
:return: top-k slices (k x ncol(totalX) if successful)
7172
:return: score, size, error of slices (k x 3)
7273
:return: debug matrix, populated with enumeration stats if verbose

0 commit comments

Comments
 (0)