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_VariationalAutoEncoder.py 3.1 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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. from d3m import index
  2. from d3m.metadata.base import ArgumentType
  3. from d3m.metadata.pipeline import Pipeline, PrimitiveStep
  4. # -> dataset_to_dataframe -> column_parser -> extract_columns_by_semantic_types(attributes) -> imputer -> random_forest
  5. # extract_columns_by_semantic_types(targets) -> ^
  6. # Creating pipeline
  7. pipeline_description = Pipeline()
  8. pipeline_description.add_input(name='inputs')
  9. # Step 0: dataset_to_dataframe
  10. step_0 = PrimitiveStep(primitive=index.get_primitive('d3m.primitives.tods.data_processing.dataset_to_dataframe'))
  11. step_0.add_argument(name='inputs', argument_type=ArgumentType.CONTAINER, data_reference='inputs.0')
  12. step_0.add_output('produce')
  13. pipeline_description.add_step(step_0)
  14. # Step 1: column_parser
  15. step_1 = PrimitiveStep(primitive=index.get_primitive('d3m.primitives.data_transformation.column_parser.Common'))
  16. step_1.add_argument(name='inputs', argument_type=ArgumentType.CONTAINER, data_reference='steps.0.produce')
  17. step_1.add_output('produce')
  18. pipeline_description.add_step(step_1)
  19. # Step 2: extract_columns_by_semantic_types(attributes)
  20. step_2 = PrimitiveStep(primitive=index.get_primitive('d3m.primitives.data_transformation.extract_columns_by_semantic_types.Common'))
  21. step_2.add_argument(name='inputs', argument_type=ArgumentType.CONTAINER, data_reference='steps.1.produce')
  22. step_2.add_output('produce')
  23. step_2.add_hyperparameter(name='semantic_types', argument_type=ArgumentType.VALUE,
  24. data=['https://metadata.datadrivendiscovery.org/types/Attribute'])
  25. pipeline_description.add_step(step_2)
  26. # Step 3: extract_columns_by_semantic_types(targets)
  27. step_3 = PrimitiveStep(primitive=index.get_primitive('d3m.primitives.data_transformation.extract_columns_by_semantic_types.Common'))
  28. step_3.add_argument(name='inputs', argument_type=ArgumentType.CONTAINER, data_reference='steps.0.produce')
  29. step_3.add_output('produce')
  30. step_3.add_hyperparameter(name='semantic_types', argument_type=ArgumentType.VALUE,
  31. data=['https://metadata.datadrivendiscovery.org/types/TrueTarget'])
  32. pipeline_description.add_step(step_3)
  33. attributes = 'steps.2.produce'
  34. targets = 'steps.3.produce'
  35. # Step 4: imputer
  36. step_4 = PrimitiveStep(primitive=index.get_primitive('d3m.primitives.data_cleaning.imputer.SKlearn'))
  37. step_4.add_argument(name='inputs', argument_type=ArgumentType.CONTAINER, data_reference=attributes)
  38. step_4.add_output('produce')
  39. pipeline_description.add_step(step_4)
  40. # Step 5: variatinal auto encoder
  41. step_5 = PrimitiveStep(primitive=index.get_primitive('d3m.primitives.tods.detection_algorithm.pyod_vae'))
  42. step_5.add_argument(name='inputs', argument_type=ArgumentType.CONTAINER, data_reference=attributes)
  43. step_5.add_output('produce')
  44. pipeline_description.add_step(step_5)
  45. # Final Output
  46. pipeline_description.add_output(name='output predictions', data_reference='steps.5.produce')
  47. # Output to YAML
  48. yaml = pipeline_description.to_yaml()
  49. with open('pipeline.yml', 'w') as f:
  50. f.write(yaml)
  51. print(yaml)
  52. # Or you can output json
  53. #data = pipline_description.to_json()

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