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