|
@@ -4,10 +4,12 @@
|
|
|
#include "CMind.h"
|
|
|
#include "dbService/GradeInfoService.h"
|
|
|
#include "dbService/EffectIndexInfoService.h"
|
|
|
+#include "algorithm/GreyClusterEvaluation.h"
|
|
|
|
|
|
#include <QHeaderView>
|
|
|
#include <QDebug>
|
|
|
#include <QMessageBox>
|
|
|
+#include <QtMath>
|
|
|
|
|
|
/**
|
|
|
* example
|
|
@@ -255,6 +257,64 @@ void GreyClusteringSampleTable::refreshTableView()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void GreyClusteringSampleTable::compute()
|
|
|
+{
|
|
|
+ GCEMat mat;
|
|
|
+ GCERangeMat ranges;
|
|
|
+
|
|
|
+ QVector<GCEmat> samples;
|
|
|
+ int colCount = m_nodeDepth + 4 + m_grayNumber;
|
|
|
+ for (int r = 0; r < m_rowCount; ++r) {
|
|
|
+ samples << GCEmat { m_model->item(r, colCount)->text().toDouble(),
|
|
|
+ m_model->item(r, colCount + 1)->text().toDouble() };
|
|
|
+ }
|
|
|
+ mat = samples;
|
|
|
+
|
|
|
+ // 指标
|
|
|
+ for (const auto &item : m_greyClusterings) {
|
|
|
+ if (!item.value.isNull()) {
|
|
|
+ QVector<GCERange> rg;
|
|
|
+
|
|
|
+ QSet<double> fullSet;
|
|
|
+ fullSet << item.value->leftExtension;
|
|
|
+ for (const auto &grange : item.value->greyRanges) {
|
|
|
+ fullSet << grange.leftValue << grange.rightValue;
|
|
|
+ }
|
|
|
+ fullSet << item.value->rightExtension;
|
|
|
+ QList<double> full = fullSet.toList();
|
|
|
+ std::sort(full.begin(), full.end());
|
|
|
+
|
|
|
+ for (int i = 0; i < item.value->greyRanges.size(); ++i) {
|
|
|
+ double left;
|
|
|
+ double right;
|
|
|
+ int lloc = full.indexOf(item.value->greyRanges.at(i).leftValue);
|
|
|
+ int rloc = full.indexOf(item.value->greyRanges.at(i).rightValue);
|
|
|
+
|
|
|
+ if (lloc == 0) {
|
|
|
+ left = full[0];
|
|
|
+ } else {
|
|
|
+ left = full[lloc - 1];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (rloc == full.size() - 1) {
|
|
|
+ right = full.last();
|
|
|
+ } else {
|
|
|
+ right = full[rloc + 1];
|
|
|
+ }
|
|
|
+ rg << GCERange { i, left, item.value->greyRanges.at(i).leftValue,
|
|
|
+ item.value->greyRanges.at(i).rightValue, right };
|
|
|
+ }
|
|
|
+
|
|
|
+ ranges << rg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QScopedPointer<GreyClusterEvaluation> gc(new GreyClusterEvaluation(mat, ranges));
|
|
|
+ gc->evaluate({ 0.2, 0.15, 0.05, 0.4, 0.2 });
|
|
|
+ BestIndex index = gc->getBestIndex();
|
|
|
+ qDebug() << index.front_index << index.back_index;
|
|
|
+}
|
|
|
+
|
|
|
void GreyClusteringSampleTable::init()
|
|
|
{
|
|
|
setAlternatingRowColors(false);
|