converter_factory.py 1.2 KB

1234567891011121314151617181920212223242526
  1. import typing
  2. from federatedml.protobuf.model_migrate.converter.binning_model_converter import FeatureBinningConverter
  3. from federatedml.protobuf.model_migrate.converter.converter_base import ProtoConverterBase
  4. from federatedml.protobuf.model_migrate.converter.feature_selection_model_converter import \
  5. HeteroFeatureSelectionConverter
  6. from federatedml.protobuf.model_migrate.converter.pearson_model_converter import HeteroPearsonConverter
  7. from federatedml.protobuf.model_migrate.converter.tree_model_converter import HeteroSBTConverter
  8. from federatedml.protobuf.model_migrate.converter.data_transform_converter import DataTransformConverter
  9. def converter_factory(module_name: str) -> typing.Optional[ProtoConverterBase]:
  10. if module_name == 'HeteroSecureBoost':
  11. return HeteroSBTConverter()
  12. elif module_name == 'HeteroFastSecureBoost':
  13. return HeteroSBTConverter()
  14. elif module_name == 'HeteroPearson':
  15. return HeteroPearsonConverter()
  16. elif module_name == 'HeteroFeatureBinning':
  17. return FeatureBinningConverter()
  18. elif module_name == 'HeteroFeatureSelection':
  19. return HeteroFeatureSelectionConverter()
  20. elif module_name == "DataTransform":
  21. return DataTransformConverter()
  22. else:
  23. return None