aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--effectivenessobserver.cpp12
-rw-r--r--effectivenessobserver.h6
-rw-r--r--main.cpp25
3 files changed, 24 insertions, 19 deletions
diff --git a/effectivenessobserver.cpp b/effectivenessobserver.cpp
index 305b3f8..61bc264 100644
--- a/effectivenessobserver.cpp
+++ b/effectivenessobserver.cpp
@@ -6,7 +6,7 @@ EffectiveInteractionEnforcer::EffectiveInteractionEnforcer(const arma::uvec &sam
{
}
-void EffectiveInteractionEnforcer::setSelection(const arma::uvec &selection)
+void EffectiveInteractionEnforcer::setSelection(const QSet<int> &selection)
{
m_selection = selection;
}
@@ -15,13 +15,15 @@ void EffectiveInteractionEnforcer::setMeasureDifference(const arma::vec &measure
{
m_measure = measure;
- if (m_selection.n_elem == 0) {
+ if (m_selection.isEmpty()) {
return;
}
- arma::uvec selectionIndices(m_selection);
- for (auto it = selectionIndices.begin(); it != selectionIndices.end(); it++) {
- *it = m_sampleIndices[*it];
+ arma::uvec selectionIndices(m_selection.size());
+ int i = 0;
+ for (auto it = m_selection.cbegin(); it != m_selection.cend(); it++) {
+ selectionIndices[i] = m_sampleIndices[*it];
+ i++;
}
double diff = arma::mean(m_measure(selectionIndices));
diff --git a/effectivenessobserver.h b/effectivenessobserver.h
index 8331916..80ee368 100644
--- a/effectivenessobserver.h
+++ b/effectivenessobserver.h
@@ -2,6 +2,7 @@
#define EFFECTIVEINTERACTIONENFORCER_H
#include <QObject>
+#include <QSet>
#include <armadillo>
class EffectiveInteractionEnforcer : public QObject
@@ -14,13 +15,14 @@ signals:
void effectivenessChanged(const arma::vec &effectiveness);
public slots:
- void setSelection(const arma::uvec &selection);
+ void setSelection(const QSet<int> &selection);
void setMeasureDifference(const arma::vec &measure);
private:
+ arma::uvec m_sampleIndices;
arma::mat m_effectiveness;
- arma::uvec m_sampleIndices, m_selection;
arma::vec m_measure;
+ QSet<int> m_selection;
};
#endif // EFFECTIVEINTERACTIONENFORCER_H
diff --git a/main.cpp b/main.cpp
index 559d554..5dbbe8b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -39,10 +39,10 @@ int main(int argc, char **argv)
arma::vec labels = dataset.col(dataset.n_cols - 1);
arma::uword n = dataset.n_rows;
- arma::uword subsampleSize = (arma::uword) sqrt(n) * 3;
+ arma::uword subsampleSize = (arma::uword) n / 10.f;
arma::uvec sampleIndices = arma::randi<arma::uvec>(subsampleSize, arma::distr_param(0, n-1));
arma::mat Ys(subsampleSize, 2, arma::fill::randn);
- Ys = mp::forceScheme(mp::dist(X.rows(sampleIndices)), Ys);
+ mp::forceScheme(mp::dist(X.rows(sampleIndices)), Ys);
ColorScale colorScale{
QColor("#1f77b4"),
@@ -60,7 +60,6 @@ int main(int argc, char **argv)
//ContinuousColorScale colorScale = ContinuousColorScale::builtin(ContinuousColorScale::RED_GRAY_BLUE);
//colorScale.setExtents(-1, 1);
Scatterplot *subsamplePlot = engine.rootObjects()[0]->findChild<Scatterplot *>("subsamplePlot");
- HistoryGraph *history = engine.rootObjects()[0]->findChild<HistoryGraph *>("history");
subsamplePlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton);
// subsamplePlot->setColorData(arma::zeros<arma::vec>(subsampleSize));
subsamplePlot->setColorScale(&colorScale);
@@ -74,18 +73,21 @@ int main(int argc, char **argv)
&interactionHandler, SLOT(setSubsample(const arma::mat &)));
QObject::connect(&interactionHandler, SIGNAL(subsampleChanged(const arma::mat &)),
plot, SLOT(setXY(const arma::mat &)));
- QObject::connect(subsamplePlot, SIGNAL(xyInteractivelyChanged(const arma::mat &)),
- history, SLOT(addHistoryItem(const arma::mat &)));
- QObject::connect(history, SIGNAL(currentItemChanged(const arma::mat &)),
- subsamplePlot, SLOT(setXY(const arma::mat &)));
+ // linking between selections in subsample plot and full dataset plot
SelectionHandler selectionHandler(sampleIndices);
QObject::connect(subsamplePlot, SIGNAL(selectionChanged(const QSet<int> &)),
&selectionHandler, SLOT(setSelection(const QSet<int> &)));
QObject::connect(&selectionHandler, SIGNAL(selectionChanged(const QSet<int> &)),
plot, SLOT(setSelection(const QSet<int> &)));
- /*
+ HistoryGraph *history = engine.rootObjects()[0]->findChild<HistoryGraph *>("history");
+ // connections between history graph and subsample plot
+ QObject::connect(subsamplePlot, SIGNAL(xyInteractivelyChanged(const arma::mat &)),
+ history, SLOT(addHistoryItem(const arma::mat &)));
+ QObject::connect(history, SIGNAL(currentItemChanged(const arma::mat &)),
+ subsamplePlot, SLOT(setXY(const arma::mat &)));
+
DistortionObserver distortionObs(X, sampleIndices);
std::unique_ptr<DistortionMeasure> distortionMeasure(new NPDistortion());
distortionObs.setMeasure(distortionMeasure.get());
@@ -95,13 +97,12 @@ int main(int argc, char **argv)
plot, SLOT(setColorData(const arma::vec &)));
EffectiveInteractionEnforcer enforcer(sampleIndices);
- QObject::connect(subsamplePlot, SIGNAL(selectionChanged(const arma::uvec &)),
- &enforcer, SLOT(setSelection(const arma::uvec &)));
+ QObject::connect(subsamplePlot, SIGNAL(selectionChanged(const QSet<int> &)),
+ &enforcer, SLOT(setSelection(const QSet<int> &)));
QObject::connect(plot, SIGNAL(colorDataChanged(const arma::vec &)),
&enforcer, SLOT(setMeasureDifference(const arma::vec &)));
QObject::connect(&enforcer, SIGNAL(effectivenessChanged(const arma::vec &)),
subsamplePlot, SLOT(setColorData(const arma::vec &)));
- */
/*
ContinuousColorScale ccolorScale = ContinuousColorScale::builtin(ContinuousColorScale::RED_GRAY_BLUE);
@@ -109,11 +110,11 @@ int main(int argc, char **argv)
plot->setColorScale(&ccolorScale);
*/
plot->setColorScale(&colorScale);
- plot->setColorData(labels);
history->addHistoryItem(Ys);
subsamplePlot->setXY(Ys);
subsamplePlot->setColorData(labels(sampleIndices));
+ plot->setColorData(labels);
return app.exec();
}