aboutsummaryrefslogtreecommitdiff
path: root/interactionhandler.cpp
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2015-05-20 18:53:07 -0300
committerSamuel Fadel <samuelfadel@gmail.com>2015-05-21 18:09:16 -0300
commitb3c7ac156e1c4ac5d7455ce61e89549291ac85b1 (patch)
tree024ee0050cf68534b2e977d48c266303a2c9bdc8 /interactionhandler.cpp
parent02e2ebf10c30ca278dc8a85649c6a7db87858cde (diff)
Nearly complete implementation of interaction.
Interaction still does not work due to signals not being correctly emitted.
Diffstat (limited to 'interactionhandler.cpp')
-rw-r--r--interactionhandler.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/interactionhandler.cpp b/interactionhandler.cpp
new file mode 100644
index 0000000..fab3c75
--- /dev/null
+++ b/interactionhandler.cpp
@@ -0,0 +1,31 @@
+#include "interactionhandler.h"
+
+#include "mp.h"
+
+InteractionHandler::InteractionHandler(const arma::mat &X,
+ const arma::vec &labels,
+ const arma::uvec &sampleIndices)
+ : m_X(X)
+ , m_labels(labels)
+ , m_sampleIndices(sampleIndices)
+ , m_technique(TECHNIQUE_LAMP)
+{
+}
+
+void InteractionHandler::setSubsample(const arma::mat &Ys)
+{
+ arma::mat embedding(m_X.n_rows, Ys.n_cols);
+ switch (m_technique) {
+ case TECHNIQUE_PLMP:
+ case TECHNIQUE_LSP:
+ case TECHNIQUE_LAMP:
+ embedding = mp::lamp(m_X, m_sampleIndices, Ys);
+ break;
+ }
+
+ arma::mat Y(embedding.n_rows, embedding.n_cols);
+ Y.cols(0, embedding.n_cols - 1) = embedding;
+ Y.col(Y.n_cols - 1) = m_labels;
+
+ emit subsampleChanged(Y);
+}