1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- //
- // Created by Austin on 2023/10/10.
- //
- #ifndef ALGORITHM__ENTROPYWEIGHTS_H_
- #define ALGORITHM__ENTROPYWEIGHTS_H_
- #include <QVector>
- typedef QVector<QVector<double>> EntropyMat;
- /**
- * @brief 熵权法
- */
- class EntropyWeights
- {
- public:
- /**
- * @param mat: 输入矩阵,一行代表一个指标, 每列对应一个样本
- * @param direction,定正向指标true,负向指标false
- */
- EntropyWeights(const EntropyMat &mat, const QVector<bool> &direction = QVector<bool>());
- void setYMin(double ymin);
- void setYMax(double ymax);
- void compute(QVector<double> &weights, QVector<double> &score);
- // 若归一化到[0,1], 0会出问题
- double ymin_;
- double ymax_;
- int sample_num_; // 样本数
- int index_num_; // 指标数
- private:
- void normalization();
- void getMinMax(const QVector<double> &in, double &min, double &max);
- void getWeights(QVector<double> &weights, QVector<double> &score);
- EntropyMat mat_;
- QVector<bool> direction_;
- };
- #endif // ALGORITHM__ENTROPYWEIGHTS_H_
|