1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #include <iostream>
- #include <fstream>
- #include "vislearning/math/cluster/ClusterOnline.h"
- using namespace OBJREC;
- using namespace std;
- using namespace NICE;
- ClusterOnline::ClusterOnline()
- {
- }
- ClusterOnline::~ClusterOnline()
- {
- }
- void ClusterOnline::init ()
- {
- clusters.clear();
- weights.clear();
- }
- void ClusterOnline::cluster ( const VVector & features,
- VVector & prototypes,
- std::vector<double> & _weights,
- std::vector<int> & assignment )
- {
- init();
- assignment.clear();
- prototypes.clear();
- _weights.clear();
- for ( VVector::const_iterator i = features.begin();
- i != features.end(); i++ )
- {
-
-
- const NICE::Vector & x = *i;
-
- int nearest_cluster = updateClusters ( x );
- assignment.push_back ( nearest_cluster );
- }
- prototypes.insert ( prototypes.begin(), clusters.begin(), clusters.end() );
- _weights.insert ( _weights.begin(), weights.begin(), weights.end() );
- }
|