test_binning_converter.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Copyright 2019 The FATE Authors. All Rights Reserved.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. from federatedml.protobuf.model_migrate.converter.binning_model_converter import FeatureBinningConverter
  18. from federatedml.protobuf.generated.feature_binning_meta_pb2 import FeatureBinningMeta
  19. from federatedml.protobuf.generated.feature_binning_param_pb2 import FeatureBinningParam
  20. from federatedml.protobuf.model_migrate.converter.tree_model_converter import HeteroSBTConverter
  21. from federatedml.protobuf.model_migrate.model_migrate import model_migration
  22. import copy
  23. host_old = [10000, 9999]
  24. host_new = [114, 514, ]
  25. guest_old = [10000]
  26. guest_new = [1919]
  27. param = FeatureBinningParam()
  28. old_header = ['host_10000_0', 'host_10000_1', 'host_10000_2', 'host_10000_3']
  29. param.header_anonymous = old_header
  30. rs = model_migration({'HelloParam': param, 'HelloMeta': {}}, 'HeteroSecureBoost', old_guest_list=guest_old,
  31. new_guest_list=guest_new, old_host_list=host_old, new_host_list=host_new, )
  32. print(rs)