EntropyWeights.h 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // Created by Austin on 2023/10/10.
  3. //
  4. #ifndef ALGORITHM__ENTROPYWEIGHTS_H_
  5. #define ALGORITHM__ENTROPYWEIGHTS_H_
  6. #include <QVector>
  7. typedef QVector<QVector<double> > EntropyMat;
  8. class EntropyWeights
  9. {
  10. public:
  11. /**
  12. * @param mat: 输入矩阵,一行代表一个指标, 每列对应一个样本
  13. * @param direction,定正向指标true,负向指标false
  14. */
  15. EntropyWeights(const EntropyMat& mat, const QVector<bool>& direction);
  16. void setYMin(double ymin);
  17. void setYMax(double ymax);
  18. void compute(QVector<double>& weights, QVector<double>& score);
  19. //若归一化到[0,1], 0会出问题
  20. double ymin_;
  21. double ymax_;
  22. int sample_num_; //样本数
  23. int index_num_; //指标数
  24. private:
  25. void normalization();
  26. void getMinMax(const QVector<double>& in, double& min, double& max);
  27. void getWeights(QVector<double>& weights, QVector<double>& score);
  28. EntropyMat mat_;
  29. QVector<bool> direction_;
  30. };
  31. #endif //ALGORITHM__ENTROPYWEIGHTS_H_