Home | History | Annotate | Download | only in test

Lines Matching refs:labels

77 void generateData( Mat& data, Mat& labels, const vector<int>& sizes, const Mat& _means, const vector<Mat>& covs, int dataType, int labelType )
87 labels.create( data.rows, 1, labelType );
107 labels.at<float>(p, 0) = (float)l;
109 labels.at<int>(p, 0) = l;
137 bool getLabelsMap( const Mat& labels, const vector<int>& sizes, vector<int>& labelsMap, bool checkClusterUniq=true )
143 assert( !labels.empty() );
144 assert( labels.total() == total && (labels.cols == 1 || labels.rows == 1));
145 assert( labels.type() == CV_32SC1 || labels.type() == CV_32FC1 );
147 bool isFlt = labels.type() == CV_32FC1;
158 int lbl = isFlt ? (int)labels.at<float>(i) : labels.at<int>(i);
184 bool calcErr( const Mat& labels, const Mat& origLabels, const vector<int>& sizes, float& err, bool labelsEquivalent = true, bool checkClusterUniq=true )
187 CV_Assert( !labels.empty() && !origLabels.empty() );
188 CV_Assert( labels.rows == 1 || labels.cols == 1 );
190 CV_Assert( labels.total() == origLabels.total() );
191 CV_Assert( labels.type() == CV_32SC1 || labels.type() == CV_32FC1 );
192 CV_Assert( origLabels.type() == labels.type() );
195 bool isFlt = labels.type() == CV_32FC1;
198 if( !getLabelsMap( labels, sizes, labelsMap, checkClusterUniq ) )
201 for( int i = 0; i < labels.rows; i++ )
203 err += labels.at<float>(i) != labelsMap[(int)origLabels.at<float>(i)] ? 1.f : 0.f;
205 err += labels.at<int>(i) != labelsMap[origLabels.at<int>(i)] ? 1.f : 0.f;
209 for( int i = 0; i < labels.rows; i++ )
211 err += labels.at<float>(i) != origLabels.at<float>(i) ? 1.f : 0.f;
213 err += labels.at<int>(i) != origLabels.at<int>(i) ? 1.f : 0.f;
215 err /= (float)labels.rows;
233 Mat data( pointsCount, 2, CV_32FC1 ), labels;
238 generateData( data, labels, sizes, means, covs, CV_32FC1, CV_32SC1 );
245 if( !calcErr( bestLabels, labels, sizes, err , false ) )
247 ts->printf( cvtest::TS::LOG, "Bad output labels if flag==KMEANS_PP_CENTERS.\n" );
258 if( !calcErr( bestLabels, labels, sizes, err, false ) )
260 ts->printf( cvtest::TS::LOG, "Bad output labels if flag==KMEANS_RANDOM_CENTERS.\n" );
270 labels.copyTo( bestLabels );
275 if( !calcErr( bestLabels, labels, sizes, err, false ) )
277 ts->printf( cvtest::TS::LOG, "Bad output labels if flag==KMEANS_USE_INITIAL_LABELS.\n" );
323 ts->printf( cvtest::TS::LOG, "Bad output labels.\n" );
339 ts->printf( cvtest::TS::LOG, "Bad output labels.\n" );
395 cv::Mat labels;
403 em->trainEM( trainData, noArray(), labels, noArray() );
406 *params.weights, noArray(), labels, noArray() );
409 noArray(), labels, noArray() );
412 if( !calcErr( labels, trainLabels, sizes, err , false, false ) )
414 ts->printf( cvtest::TS::LOG, "Case index %i : Bad output labels.\n", caseIndex );
424 labels.create( testData.rows, 1, CV_32SC1 );
429 labels.at<int>(i) = static_cast<int>(em->predict2( sample, probs )[1]);
431 if( !calcErr( labels, testLabels, sizes, err, false, false ) )
433 ts->printf( cvtest::TS::LOG, "Case index %i : Bad output labels.\n", caseIndex );
547 Mat labels;
551 em->trainEM(samples, noArray(), labels, noArray());