当前位置: 首页>>代码示例>>C++>>正文


C++ Neighbors::size方法代码示例

本文整理汇总了C++中Neighbors::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Neighbors::size方法的具体用法?C++ Neighbors::size怎么用?C++ Neighbors::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Neighbors的用法示例。


在下文中一共展示了Neighbors::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fmin

TEMPLATE_HEADER
typename LR::Data LR::solveNormalEqn( Coordinate & c, Neighbors & nset ){
    
    if( y.size().rows != Basis::size ){
        A.resize( Basis::size, Basis::size );
        y.resize( Basis::size, 1);
    }
    
    // find bounds for points
    Coordinate lb = nset[0].point, rb = nset[0].point, tmp;
    
    for( int j = 0; j < Coordinate::Dims ; j++ ){
        for( int i = 1; i < nset.size(); i++ ){
            lb[j] = fmin(nset[i].point[j],lb[j]);
            rb[j] = fmax(nset[i].point[j],rb[j]);
        }
    }
    
    
    
    // compute weights
    std::vector<double> weights(nset.size());
    wfunc(weights,nset);
    
    
    // store values for A
    A = 0;
    for(int j = 0; j < Basis::size; j++ ){
        for( int k = j; k < Basis::size; k++ ){
            for( int i = 0; i < nset.size(); i++ ){
                scale(lb,rb,nset[i].point,tmp);
                A(j,k) += basis(k, tmp)*basis(j, tmp)*weights[i];
            }
        }
    }
    
    
    // store values for y
    y = 0;
    for(int j = 0; j < Basis::size; j++ ){
        for( int i = 0; i < nset.size(); i++ ){
            scale(lb,rb,nset[i].point,tmp);
            y[j] += basis(j, tmp)*weights[i]*nset[i].data;
        }
    }
    
    // solve system of equations
    la::solve(A,y,coef);
    
    // compute point
    Data output = 0;
    
    for( int i = 0; i < Basis::size; i++ ){
        scale(lb,rb,c,tmp);
        output += coef[i]*basis(i,tmp);
    }
    
    return output;
}
开发者ID:choward1491,项目名称:FuseML,代码行数:59,代码来源:LocalRegression_Impl.hpp

示例2: indexOf

// Zhu et al. "A Rank-Order Distance based Clustering Algorithm for Face Tagging", CVPR 2011
// Ob(x) in eq. 1, modified to consider 0/1 as ground truth imposter/genuine.
static int indexOf(const Neighbors &neighbors, int i)
{
    for (int j=0; j<neighbors.size(); j++) {
        const Neighbor &neighbor = neighbors[j];
        if (neighbor.first == i) {
            if      (neighbor.second == 0) return neighbors.size()-1;
            else if (neighbor.second == 1) return 0;
            else                           return j;
        }
    }
    return -1;
}
开发者ID:Alegzandra,项目名称:openbr,代码行数:14,代码来源:cluster.cpp

示例3: neighbors_distances_matrix

SparseMatrix neighbors_distances_matrix(RandomAccessIterator begin, RandomAccessIterator end,
                                        const Neighbors& neighbors, DistanceCallback callback,
                                        ScalarType& average_distance)
{
	const IndexType k = neighbors[0].size();
	const IndexType n = neighbors.size();
	if ((end-begin)!=n)
		throw std::runtime_error("Wrong size");
	SparseTriplets sparse_triplets;
	sparse_triplets.reserve(k*n);
	average_distance = 0;
	ScalarType current_distance;

	for (IndexType i = 0; i < n; ++i)
	{
		const LocalNeighbors& current_neighbors = neighbors[i];
		for (IndexType j = 0; j < k; ++j)
		{
			current_distance = callback.distance(begin[i], begin[current_neighbors[j]]);
			average_distance += current_distance;
			SparseTriplet triplet(i, current_neighbors[j], current_distance);
			sparse_triplets.push_back(triplet);
		}
	}
	average_distance /= (k*n);
	return sparse_matrix_from_triplets(sparse_triplets, n, n);
}
开发者ID:42MachineLearning,项目名称:shogun,代码行数:27,代码来源:manifold_sculpting.hpp

示例4: run_cluster

void ClustererDBSCAN::run_cluster(Points samples)
{

        ClusterId cid = 1;
        // foreach pid
        for (PointId pid = 0; pid < samples.size(); pid++)
        {
                // not already visited
                if (!_visited[pid]){

                        _visited[pid] = true;

                        // get the neighbors
                        Neighbors ne = findNeighbors(pid, _eps);

                        // not enough support -> mark as noise
                        if (ne.size() < _minPts)
                        {
                                _noise[pid] = true;
                        }
                        else
                        {
                            //else it's a core point
                                _core[pid] = true;

                                // Add p to current cluster

                                CCluster c;              // a new cluster
                                c.push_back(pid);   	// assign pid to cluster
                                _pointId_to_clusterId[pid]=cid;

                                // go to neighbors
                                for (unsigned int i = 0; i < ne.size(); i++)
                                {
                                        PointId nPid = ne[i];

                                        // not already visited
                                        if (!_visited[nPid])
                                        {
                                                _visited[nPid] = true;

                                                // go to neighbors
                                                Neighbors ne1 = findNeighbors(nPid, _eps);

                                                // enough support
                                                if (ne1.size() >= _minPts)
                                                {
                                                        _core[nPid] = true;

                                                        // join
                                                        BOOST_FOREACH(Neighbors::value_type n1, ne1)
                                                        {
                                                                // join neighbord
                                                                ne.push_back(n1);    
                                                        }
                                                }
                                        }

                                        // not already assigned to a cluster
                                        if (!_pointId_to_clusterId[nPid])
                                        {
                                            // add it to the current cluster
                                                c.push_back(nPid);
                                                _pointId_to_clusterId[nPid]=cid;
                                        }
                                }
开发者ID:barak,项目名称:mldemos,代码行数:66,代码来源:clustererDBSCAN.cpp


注:本文中的Neighbors::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。