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.

build_test_detection_algorithm_PyodMoGaal.py 2.2 kB

first commit Former-commit-id: 08bc23ba02cffbce3cf63962390a65459a132e48 [formerly 0795edd4834b9b7dc66db8d10d4cbaf42bbf82cb] [formerly b5010b42541add7e2ea2578bf2da537efc457757 [formerly a7ca09c2c34c4fc8b3d8e01fcfa08eeeb2cae99d]] [formerly 615058473a2177ca5b89e9edbb797f4c2a59c7e5 [formerly 743d8dfc6843c4c205051a8ab309fbb2116c895e] [formerly bb0ea98b1e14154ef464e2f7a16738705894e54b [formerly 960a69da74b81ef8093820e003f2d6c59a34974c]]] [formerly 2fa3be52c1b44665bc81a7cc7d4cea4bbf0d91d5 [formerly 2054589f0898627e0a17132fd9d4cc78efc91867] [formerly 3b53730e8a895e803dfdd6ca72bc05e17a4164c1 [formerly 8a2fa8ab7baf6686d21af1f322df46fd58c60e69]] [formerly 87d1e3a07a19d03c7d7c94d93ab4fa9f58dada7c [formerly f331916385a5afac1234854ee8d7f160f34b668f] [formerly 69fb3c78a483343f5071da4f7e2891b83a49dd18 [formerly 386086f05aa9487f65bce2ee54438acbdce57650]]]] Former-commit-id: a00aed8c934a6460c4d9ac902b9a74a3d6864697 [formerly 26fdeca29c2f07916d837883983ca2982056c78e] [formerly 0e3170d41a2f99ecf5c918183d361d4399d793bf [formerly 3c12ad4c88ac5192e0f5606ac0d88dd5bf8602dc]] [formerly d5894f84f2fd2e77a6913efdc5ae388cf1be0495 [formerly ad3e7bc670ff92c992730d29c9d3aa1598d844e8] [formerly 69fb3c78a483343f5071da4f7e2891b83a49dd18]] Former-commit-id: 3c19c9fae64f6106415fbc948a4dc613b9ee12f8 [formerly 467ddc0549c74bb007e8f01773bb6dc9103b417d] [formerly 5fa518345d958e2760e443b366883295de6d991c [formerly 3530e130b9fdb7280f638dbc2e785d2165ba82aa]] Former-commit-id: 9f5d473d42a435ec0d60149939d09be1acc25d92 [formerly be0b25c4ec2cde052a041baf0e11f774a158105d] Former-commit-id: 9eca71cb73ba9edccd70ac06a3b636b8d4093b04
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from d3m import index
  2. from d3m.metadata.base import ArgumentType
  3. from d3m.metadata.pipeline import Pipeline, PrimitiveStep
  4. from d3m.metadata import hyperparams
  5. import copy
  6. # -> dataset_to_dataframe -> column_parser -> extract_columns_by_semantic_types(attributes) -> imputer -> random_forest
  7. # extract_columns_by_semantic_types(targets) -> ^
  8. # Creating pipeline
  9. pipeline_description = Pipeline()
  10. pipeline_description.add_input(name='inputs')
  11. # Step 0: dataset_to_dataframe
  12. primitive_0 = index.get_primitive('d3m.primitives.tods.data_processing.dataset_to_dataframe')
  13. step_0 = PrimitiveStep(primitive=primitive_0)
  14. step_0.add_argument(name='inputs', argument_type=ArgumentType.CONTAINER, data_reference='inputs.0')
  15. step_0.add_output('produce')
  16. pipeline_description.add_step(step_0)
  17. # # Step 1: column_parser
  18. primitive_1 = index.get_primitive('d3m.primitives.data_transformation.column_parser.Common')
  19. step_1 = PrimitiveStep(primitive=primitive_1)
  20. step_1.add_argument(name='inputs', argument_type=ArgumentType.CONTAINER, data_reference='steps.0.produce')
  21. step_1.add_output('produce')
  22. pipeline_description.add_step(step_1)
  23. # # Step 2: test primitive
  24. primitive_2 = index.get_primitive('d3m.primitives.tods.detection_algorithm.pyod_mogaal')
  25. step_2 = PrimitiveStep(primitive=primitive_2)
  26. step_2.add_hyperparameter(name='contamination', argument_type=ArgumentType.VALUE, data=0.1)
  27. step_2.add_hyperparameter(name='use_semantic_types', argument_type=ArgumentType.VALUE, data=True)
  28. step_2.add_hyperparameter(name='use_columns', argument_type=ArgumentType.VALUE, data=(2,)) # There is sth wrong with multi-dimensional
  29. step_2.add_hyperparameter(name='return_result', argument_type=ArgumentType.VALUE, data='append')
  30. step_2.add_argument(name='inputs', argument_type=ArgumentType.CONTAINER, data_reference='steps.1.produce')
  31. step_2.add_output('produce')
  32. pipeline_description.add_step(step_2)
  33. # Final Output
  34. pipeline_description.add_output(name='output predictions', data_reference='steps.2.produce')
  35. # Output to YAML
  36. yaml = pipeline_description.to_yaml()
  37. with open('pipeline.yml', 'w') as f:
  38. f.write(yaml)
  39. print(yaml)
  40. # Or you can output json
  41. #data = pipline_description.to_json()

全栈的自动化机器学习系统,主要针对多变量时间序列数据的异常检测。TODS提供了详尽的用于构建基于机器学习的异常检测系统的模块,它们包括:数据处理(data processing),时间序列处理( time series processing),特征分析(feature analysis),检测算法(detection algorithms),和强化模块( reinforcement module)。这些模块所提供的功能包括常见的数据预处理、时间序列数据的平滑或变换,从时域或频域中抽取特征、多种多样的检测算