You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

train.py 1.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright 2021 The KubeEdge Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import json
  15. from interface import DATACONF, Estimator, feature_process
  16. from sedna.common.config import Context, BaseConfig
  17. from sedna.datasources import CSVDataParse
  18. from sedna.core.lifelong_learning import LifelongLearning
  19. def main():
  20. # load dataset.
  21. train_dataset_url = BaseConfig.train_dataset_url
  22. train_data = CSVDataParse(data_type="train", func=feature_process)
  23. train_data.parse(train_dataset_url, label=DATACONF["LABEL"])
  24. attribute = json.dumps({"attribute": DATACONF["ATTRIBUTES"]})
  25. early_stopping_rounds = int(
  26. Context.get_parameters(
  27. "early_stopping_rounds", 100))
  28. metric_name = Context.get_parameters("metric_name", "mlogloss")
  29. ll_job = LifelongLearning(
  30. estimator=Estimator,
  31. task_definition="TaskDefinitionByDataAttr",
  32. task_definition_param=attribute
  33. )
  34. train_experiment = ll_job.train(
  35. train_data=train_data,
  36. metric_name=metric_name,
  37. early_stopping_rounds=early_stopping_rounds
  38. )
  39. return train_experiment
  40. if __name__ == '__main__':
  41. print(main())