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.

concept_drift_time_series.py 1.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2021 Huawei Technologies Co., Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. """
  16. Concept drift example.
  17. Download dataset from: https://www.kaggle.com/camnugent/sandp500.
  18. File structure:
  19. --archive
  20. --individual_stocks_5yr
  21. --__MACOSX
  22. --individual_stocks_5yr
  23. --all_stocks_5yr.csv
  24. --getSandP.py
  25. --merge.sh
  26. Please use the data in archive/individual_stocks_5yr/individual_stocks_5yr/XX.csv.
  27. In each csv file, there are 'date','open','high','low','close','volume','Name' columns.
  28. Please choose one column or multiple columns.
  29. 'date' and 'Name' are non-data column, please do not use.
  30. """
  31. import numpy as np
  32. from mindarmour import ConceptDriftCheckTimeSeries
  33. # input data
  34. DATA_FILE = r'archive/individual_stocks_5yr/individual_stocks_5yr/AEE_data.csv'
  35. data = np.loadtxt(DATA_FILE, str, delimiter=",")
  36. data = data[1:, 2].astype('float64') # choose one column or multiple columns data[1:, 2:5]
  37. # Initialization
  38. concept = ConceptDriftCheckTimeSeries(window_size=100, rolling_window=10,
  39. step=10, threshold_index=1.5, need_label=False)
  40. # drift check
  41. drift_score, threshold, concept_drift_location = concept.concept_check(data)

MindArmour关注AI的安全和隐私问题。致力于增强模型的安全可信、保护用户的数据隐私。主要包含3个模块:对抗样本鲁棒性模块、Fuzz Testing模块、隐私保护与评估模块。 对抗样本鲁棒性模块 对抗样本鲁棒性模块用于评估模型对于对抗样本的鲁棒性,并提供模型增强方法用于增强模型抗对抗样本攻击的能力,提升模型鲁棒性。对抗样本鲁棒性模块包含了4个子模块:对抗样本的生成、对抗样本的检测、模型防御、攻防评估。