int main()
{
SampleType::Pointer sample = SampleType::New();
MeasurementVectorType mv;
mv[0] = 1.0;
mv[1] = 2.0;
mv[2] = 4.0;
sample->PushBack(mv);
mv[0] = 2.0;
mv[1] = 4.0;
mv[2] = 5.0;
sample->PushBack(mv);
mv[0] = 3.0;
mv[1] = 8.0;
mv[2] = 6.0;
sample->PushBack(mv);
using MembershipSampleType =
MembershipSampleType::Pointer membershipSample =
MembershipSampleType::New();
membershipSample->SetSample(sample);
membershipSample->SetNumberOfClasses(2);
membershipSample->AddInstance(0U, 0UL );
membershipSample->AddInstance(0U, 1UL );
membershipSample->AddInstance(1U, 2UL );
std::cout << "Size = " << membershipSample->Size() << std::endl;
std::cout << "Total frequency = "
<< membershipSample->GetTotalFrequency() << std::endl;
MembershipSampleType::Iterator iter = membershipSample->Begin();
while ( iter != membershipSample->End() )
{
std::cout << "instance identifier = " << iter.GetInstanceIdentifier()
<< "\t measurement vector = "
<< iter.GetMeasurementVector()
<< "\t frequency = "
<< iter.GetFrequency()
<< "\t class label = "
<< iter.GetClassLabel()
<< std::endl;
++iter;
}
std::cout << "class label = 0 sample size = "
<< membershipSample->GetClassSampleSize(0) << std::endl;
std::cout << "class label = 1 sample size = "
<< membershipSample->GetClassSampleSize(0) << std::endl;
MembershipSampleType::ClassSampleType::Pointer classSample =
membershipSample->GetClassSample(0);
MembershipSampleType::ClassSampleType::Iterator c_iter =
classSample->Begin();
while ( c_iter != classSample->End() )
{
std::cout << "instance identifier = " << c_iter.GetInstanceIdentifier()
<< "\t measurement vector = "
<< c_iter.GetMeasurementVector()
<< "\t frequency = "
<< c_iter.GetFrequency() << std::endl;
++c_iter;
}
return EXIT_SUCCESS;
}