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.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 sedna.datasources import CSVDataParse
  16. from sedna.common.config import Context, BaseConfig
  17. from sedna.core.lifelong_learning import LifelongLearning
  18. from interface import DATACONF, Estimator, feature_process
  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("early_stopping_rounds", 100)
  27. )
  28. metric_name = Context.get_parameters("metric_name", "mlogloss")
  29. task_definition = {
  30. "method": "TaskDefinitionByDataAttr",
  31. "param": attribute
  32. }
  33. ll_job = LifelongLearning(
  34. estimator=Estimator,
  35. task_definition=task_definition,
  36. task_relationship_discovery=None,
  37. task_mining=None,
  38. task_remodeling=None,
  39. inference_integrate=None,
  40. unseen_task_detect=None
  41. )
  42. train_experiment = ll_job.train(
  43. train_data=train_data,
  44. metric_name=metric_name,
  45. early_stopping_rounds=early_stopping_rounds
  46. )
  47. return train_experiment
  48. if __name__ == '__main__':
  49. print(main())