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.

evaluate.py 2.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Copyright 2023 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 os
  15. from sedna.core.lifelong_learning import LifelongLearning
  16. from sedna.datasources import TxtDataParse
  17. from sedna.common.config import Context
  18. from accuracy import accuracy
  19. from interface import Estimator
  20. def _load_txt_dataset(dataset_url):
  21. # use original dataset url
  22. original_dataset_url = Context.get_parameters('original_dataset_url', "")
  23. dataset_urls = dataset_url.split()
  24. dataset_urls = [
  25. os.path.join(
  26. os.path.dirname(original_dataset_url),
  27. dataset_url) for dataset_url in dataset_urls]
  28. return dataset_urls[:-1], dataset_urls[-1]
  29. def eval():
  30. estimator = Estimator(num_class=Context.get_parameters("num_class", 24))
  31. eval_dataset_url = Context.get_parameters("test_dataset_url")
  32. eval_data = TxtDataParse(data_type="eval", func=_load_txt_dataset)
  33. eval_data.parse(eval_dataset_url, use_raw=False)
  34. task_allocation = {
  35. "method": "TaskAllocationByOrigin"
  36. }
  37. ll_job = LifelongLearning(estimator,
  38. task_definition=None,
  39. task_relationship_discovery=None,
  40. task_allocation=task_allocation,
  41. task_remodeling=None,
  42. inference_integrate=None,
  43. task_update_decision=None,
  44. unseen_task_allocation=None,
  45. unseen_sample_recognition=None,
  46. unseen_sample_re_recognition=None
  47. )
  48. ll_job.evaluate(eval_data, metrics=accuracy)
  49. if __name__ == '__main__':
  50. print(eval())