Skip to content

Commit

Permalink
make input models optional for hetero feature selection(#4661)
Browse files Browse the repository at this point in the history
edit pipeline examples(#5008)

Signed-off-by: Yu Wu <yolandawu131@gmail.com>
  • Loading branch information
nemirorox committed Aug 11, 2023
1 parent 8dd7c03 commit 5f6ee9d
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def main(config="../config.yaml", namespace=""):
psi_0 = PSI("psi_0")
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

binning_0 = HeteroFeatureBinning("binning_0",
Expand Down Expand Up @@ -70,10 +70,10 @@ def main(config="../config.yaml", namespace=""):
predict_pipeline = FateFlowPipeline()

deployed_pipeline = pipeline.get_deployed_pipeline()
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

predict_pipeline.add_task(deployed_pipeline)
predict_pipeline.compile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def main(config="../config.yaml", namespace=""):
psi_0 = PSI("psi_0")
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

psi_1 = PSI("psi_1")
psi_1.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
psi_1.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
psi_1.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
Expand Down Expand Up @@ -74,10 +74,10 @@ def main(config="../config.yaml", namespace=""):
predict_pipeline = FateFlowPipeline()

deployed_pipeline = pipeline.get_deployed_pipeline()
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

predict_pipeline.add_task(deployed_pipeline)
predict_pipeline.compile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def main(config="../config.yaml", namespace=""):
psi_0 = PSI("psi_0")
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

binning_0 = HeteroFeatureBinning("binning_0",
Expand Down Expand Up @@ -69,10 +69,10 @@ def main(config="../config.yaml", namespace=""):
predict_pipeline = FateFlowPipeline()

deployed_pipeline = pipeline.get_deployed_pipeline()
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

predict_pipeline.add_task(deployed_pipeline)
predict_pipeline.compile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tasks:
script: test_feature_selection_binning.py
selection-manual:
script: test_feature_selection_manual.py
binning-statistics:
selection-statistics:
script: test_feature_selection_statistics.py
binning-multi-model:
selection-multi-model:
script: test_feature_selection_multi_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ def main(config=".../config.yaml", namespace=""):
psi_0 = PSI("psi_0")
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

binning_0 = HeteroFeatureBinning("binning_0",
method="quantile",
n_bins=10,
bin_col=["x0"],
transform_method="bin_idx",
train_data=psi_0.outputs["output_data"]
)
Expand All @@ -68,10 +67,10 @@ def main(config=".../config.yaml", namespace=""):
predict_pipeline = FateFlowPipeline()

deployed_pipeline = pipeline.get_deployed_pipeline()
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

predict_pipeline.add_task(deployed_pipeline)
predict_pipeline.compile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def main(config=".../config.yaml", namespace=""):
psi_0 = PSI("psi_0")
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

selection_0 = HeteroFeatureSelection("selection_0",
method=["statistics"],
method=["manual"],
train_data=psi_0.outputs["output_data"])
selection_0.guest.component_setting(manual_param={"keep_col": ["x0", "x1"]})
selection_0.hosts[0].component_setting(manual_param={"filter_out_col": ["x0", "x1"]})
Expand All @@ -60,10 +60,10 @@ def main(config=".../config.yaml", namespace=""):
predict_pipeline = FateFlowPipeline()

deployed_pipeline = pipeline.get_deployed_pipeline()
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

predict_pipeline.add_task(deployed_pipeline)
predict_pipeline.compile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ def main(config=".../config.yaml", namespace=""):
psi_0 = PSI("psi_0")
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

binning_0 = HeteroFeatureBinning("binning_0",
method="quantile",
n_bins=10,
bin_col=["x0"],
transform_method="bin_idx",
train_data=psi_0.outputs["output_data"]
)
Expand Down Expand Up @@ -74,10 +73,10 @@ def main(config=".../config.yaml", namespace=""):
predict_pipeline = FateFlowPipeline()

deployed_pipeline = pipeline.get_deployed_pipeline()
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

predict_pipeline.add_task(deployed_pipeline)
predict_pipeline.compile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def main(config=".../config.yaml", namespace=""):
psi_0 = PSI("psi_0")
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

statistics_0 = Statistics("statistics_0", input_data=psi_0.outputs["output_data"])
Expand All @@ -63,10 +63,10 @@ def main(config=".../config.yaml", namespace=""):
predict_pipeline = FateFlowPipeline()

deployed_pipeline = pipeline.get_deployed_pipeline()
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

predict_pipeline.add_task(deployed_pipeline)
predict_pipeline.compile()
Expand Down
6 changes: 3 additions & 3 deletions examples/pipeline/multi_model/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from fate_client.pipeline import FateFlowPipeline
from fate_client.pipeline.components.fate import PSI, HeteroFeatureSelection, HeteroFeatureBinning, \
FeatureScale, Union, DataSplit, CoordinatedLR, CoordinatedLinR, Statistics, Sample, Evaluation
FeatureScale, Union, DataSplit, CoordinatedLR, Statistics, Sample, Evaluation
from fate_client.pipeline.interface import DataWarehouseChannel
from fate_client.pipeline.utils import test_utils

Expand All @@ -38,7 +38,7 @@ def main(config="../config.yaml", namespace=""):
psi_0 = PSI("psi_0")
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

data_split_0 = DataSplit("data_split_0", input_data=psi_0.outputs["output_data"],
Expand Down Expand Up @@ -109,7 +109,7 @@ def main(config="../config.yaml", namespace=""):
predict_pipeline = FateFlowPipeline()

deployed_pipeline = pipeline.get_deployed_pipeline()
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
Expand Down
14 changes: 7 additions & 7 deletions examples/pipeline/scale/test_scale_min_max.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def main(config="../config.yaml", namespace=""):
psi_0 = PSI("psi_0")
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

psi_1 = PSI("psi_1")
psi_1.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
psi_1.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
psi_1.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
Expand All @@ -57,7 +57,7 @@ def main(config="../config.yaml", namespace=""):

statistics_0 = Statistics("statistics_0",
metrics=["max", "min", "mean", "std"],
input_data=feature_scale_1.outputs["train_output_data"])
input_data=feature_scale_1.outputs["test_output_data"])

pipeline.add_task(psi_0)
pipeline.add_task(psi_1)
Expand All @@ -77,10 +77,10 @@ def main(config="../config.yaml", namespace=""):
predict_pipeline = FateFlowPipeline()

deployed_pipeline = pipeline.get_deployed_pipeline()
psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.guest.component_setting(input_data=DataWarehouseChannel(name="breast_hetero_guest",
namespace=f"experiment{namespace}"))
deployed_pipeline.psi_0.hosts[0].component_setting(input_data=DataWarehouseChannel(name="breast_hetero_host",
namespace=f"experiment{namespace}"))

predict_pipeline.add_task(deployed_pipeline)
predict_pipeline.compile()
Expand Down
Loading

0 comments on commit 5f6ee9d

Please sign in to comment.