Vespucci  1.0.0
agglomerativeclustering.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (C) 2014-2016 Wright State University - All Rights Reserved
3  Daniel P. Foose - Maintainer/Lead Developer
4 
5  This file is part of Vespucci.
6 
7  Vespucci is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Vespucci is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Vespucci. If not, see <http://www.gnu.org/licenses/>.
19 *******************************************************************************/
20 #ifndef AGGLOMERATIVECLUSTERING_H
21 #define AGGLOMERATIVECLUSTERING_H
22 #include "Global/libvespucci.h"
23 #include <mlpack/core.hpp>
27 typedef std::vector<node_t *> nodevec;
28 
29 
30 namespace Vespucci{
31  namespace Math{
32  namespace Clustering{
39  {
40  public:
41  AHCA(std::string linkage_method,
42  std::string metric_type);
43  AHCA();
44 
45  void Link(const arma::mat &data);
46 
47  void SetLinkage(std::string linkage_method);
48  void SetMetric(std::string metric_type);
49 
50  arma::mat Cluster(arma::uword k);
51  std::string metric_type();
52  std::string linkage_method();
53  arma::mat merge_data();
54  arma::mat dist();
55  std::map<size_t, nodevec> clusters();
56  private:
57  node_t *root_node_;
58  std::string metric_type_;
59  std::string linkage_method_;
60  arma::uword observations_;
61  arma::uvec FindClosest(const arma::mat &data, const arma::mat &dist,
62  const nodevec &clusters, double &distance);
63  double ClusterDistance(int i, int j, const arma::mat &data, const arma::mat &dist,
64  const nodevec &clusters);
65  arma::mat dist_;
66  arma::mat merge_data_;
67  arma::mat mean_distance_;
68  std::map<size_t, nodevec> clusters_;
69 
70  };
71 
72  VESPUCCI_EXPORT arma::mat pdist(const arma::mat &x,
73  std::string metric_type,
74  arma::uword dim = 1,
75  std::string shape = "row");
76 
77  }
78  }
79 }
80 
81 #endif // AGGLOMERATIVECLUSTERING_H
VESPUCCI_EXPORT arma::mat pdist(const arma::mat &x, std::string metric_type, arma::uword dim=1, std::string shape="row")
The AHCANode class This class stores a node in the data structure representing the AHCA dendrogram Th...
Definition: ahcanode.h:34
std::vector< node_t * > nodevec
#define VESPUCCI_EXPORT
Definition: libvespucci.h:7
Vespucci::Math::Clustering::AHCANode node_t
A namespace for "global" functions, including math functions.
The AHCA class Handles agglomerative hierarchical clustering of data This class holds a tree which re...