src/CXX/train.cxx
/**
 *  \brief  Train LVQ clustering
 *
 *  \param  train_src  Training set source stream
 *  \param  test_src   Testing set source stream
 *  \param  rank       Vector rank
 *
 *  \return Exit code
 */
\brief  Train LVQ clustering
\param  train_src  Training set source stream
\param  test_src   Testing set source stream
\param  rank       Vector rank

\return Exit code
\ brief Train LVQ clustering \ param train_src Training set source stream \ param test_src Testing set source stream \ param rank Vector rank \ return Exit code
static int train_clustering(
    std::istream & train_src,
    std::istream & test_src,
    size_t         rank)
{
    size_t cluster_cnt;
    auto train_set = read_clustering_tset(train_src, rank, &cluster_cnt);
    lvq_t lvq(rank, cluster_cnt);
    lvq.set_random();
    lvq.train_unsupervised(train_set);
    auto test_set = read_clustering_tset(test_src, rank);
    lvq_t::clustering_statistics stats = lvq.test_clustering(test_set);
    std::cerr << "Avg. error : " << stats.avg_error() << std::endl;
    for (size_t i = 0; i < cluster_cnt; ++i) {
        std::cout << lvq.get(i) << std::endl;
        std::cerr
            << "Cluster " << i << " avg. error: "
            << stats.avg_error(i) << std::endl;
    }
    return 0;
}
static int train_clustering ( std :: istream & train_src , std :: istream & test_src , size_t rank ) { size_t cluster_cnt ; auto train_set = read_clustering_tset ( train_src , rank , & cluster_cnt ) ; lvq_t lvq ( rank , cluster_cnt ) ; lvq . set_random ( ) ; lvq . train_unsupervised ( train_set ) ; auto test_set = read_clustering_tset ( test_src , rank ) ; lvq_t :: clustering_statistics stats = lvq . test_clustering ( test_set ) ; std :: cerr << " " << stats . avg_error ( ) << std :: endl ; for ( size_t i = 0 ; i < cluster_cnt ; ++ i ) { std :: cout << lvq . get ( i ) << std :: endl ; std :: cerr << " " << i << " " << stats . avg_error ( i ) << std :: endl ; } return 0 ; }
\brief  Train LVQ clustering
  \param  train_src  Training set source stream
  \param  test_src   Testing set source stream
  \param  rank       Vector rank
\ brief Train LVQ clustering \ param train_src Training set source stream \ param test_src Testing set source stream \ param rank Vector rank
// Read training set // Train the model // Read test set // Test the model // Print statistics // Print cluster representants & per-cluster average error