Skip to content

Commit

Permalink
add union cpn(#4668)
Browse files Browse the repository at this point in the history
add explicit cpn provider

Signed-off-by: Yu Wu <yolandawu131@gmail.com>
Signed-off-by: weiwee <wbwmat@gmail.com>
  • Loading branch information
nemirorox authored and sagewe committed Jul 21, 2023
1 parent 6e84935 commit 032dfce
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion python/fate/components/components/coordinated_linr.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
logger = logging.getLogger(__name__)


@cpn.component(roles=[GUEST, HOST, ARBITER])
@cpn.component(roles=[GUEST, HOST, ARBITER], provider="fate")
def coordinated_linr(ctx, role):
...

Expand Down
2 changes: 1 addition & 1 deletion python/fate/components/components/coordinated_lr.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
logger = logging.getLogger(__name__)


@cpn.component(roles=[GUEST, HOST, ARBITER])
@cpn.component(roles=[GUEST, HOST, ARBITER], provider="fate")
def coordinated_lr(ctx, role):
...

Expand Down
2 changes: 1 addition & 1 deletion python/fate/components/components/feature_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from fate.components.core import GUEST, HOST, Role, cpn, params


@cpn.component(roles=[GUEST, HOST])
@cpn.component(roles=[GUEST, HOST], provider="fate")
def feature_scale(ctx, role):
...

Expand Down
23 changes: 7 additions & 16 deletions python/fate/components/components/feature_union.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,22 @@
from fate.components.core import GUEST, HOST, Role, cpn, params


@cpn.component(roles=[GUEST, HOST])
def feature_union(ctx, role):
...


@feature_union.train()
def union_train(
@cpn.component(roles=[GUEST, HOST], provider="fate")
def feature_union(
ctx: Context,
role: Role,
train_data_list: cpn.dataframe_inputs(roles=[GUEST, HOST]),
input_data_list: cpn.dataframe_inputs(roles=[GUEST, HOST]),
axis: cpn.parameter(type=params.conint(strict=True, ge=0, le=1), default=0, optional=False,
desc="axis along which concatenation is performed, 0 for row-wise, 1 for column-wise"),
train_output_data: cpn.dataframe_output(roles=[GUEST, HOST])
output_data: cpn.dataframe_output(roles=[GUEST, HOST])
):
train(ctx, train_data_list, train_output_data, axis)


def train(ctx, train_data_list, train_output_data, axis):
from fate.ml.preprocessing import FeatureUnion
data_list = []
for data in train_data_list:
for data in input_data_list:
data = data.read()
data_list.append(data)

sub_ctx = ctx.sub_ctx("train")
union_obj = FeatureUnion(axis)
output_data = union_obj.fit(sub_ctx, data_list)
train_output_data.write(output_data)
output_df = union_obj.fit(sub_ctx, data_list)
output_data.write(output_df)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
logger = logging.getLogger(__name__)


@cpn.component(roles=[GUEST, HOST])
@cpn.component(roles=[GUEST, HOST], provider="fate")
def hetero_feature_binning(ctx, role):
...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
logger = logging.getLogger(__name__)


@cpn.component(roles=[GUEST, HOST])
@cpn.component(roles=[GUEST, HOST], provider="fate")
def hetero_feature_selection(ctx, role):
...

Expand Down

0 comments on commit 032dfce

Please sign in to comment.