コード例 #1
0
FeatureVectorListPtr  FeatureEncoder::CreateEncodedFeatureVector (FeatureVectorList&  srcData)
{
  if  (srcData.AllFieldsAreNumeric ())
    return  srcData.DuplicateListAndContents ();

  FeatureVectorListPtr  encodedFeatureVectorList = new FeatureVectorList (destFileDesc, true);

  FeatureVectorList::iterator  idx;
  for  (idx = srcData.begin ();   idx != srcData.end ();  idx++)
  {
    FeatureVectorPtr  srcExample = *idx;
    XSpacePtr  encodedData = EncodeAExample (srcExample);

    kkint32  zed = 0;
    FeatureVectorPtr  encodedFeatureVector = new FeatureVector (codedNumOfFeatures);
    while  (encodedData[zed].index != -1)
    {
      encodedFeatureVector->AddFeatureData (encodedData[zed].index, (float)encodedData[zed].value);
      zed++;
    }

    encodedFeatureVector->MLClass (srcExample->MLClass ());
    encodedFeatureVectorList->PushOnBack (encodedFeatureVector);

    delete  encodedData;
    encodedData = NULL;
  }

  return  encodedFeatureVectorList;
}  /* CreateEncodedFeatureVector */
コード例 #2
0
void  FeatureFileIO::SaveFeatureFileMultipleParts (const KKStr&          _fileName, 
                                                   FeatureNumListConst&  _selFeatures,
                                                   FeatureVectorList&    _examples,
                                                   VolConstBool&         _cancelFlag,
                                                   bool&                 _successful,
                                                   RunLog&               _log
                                                  )
{
  kkuint32  numExamplesWritten = 0;
  SaveFeatureFile (_fileName, _selFeatures, _examples, numExamplesWritten, _cancelFlag, _successful, _log);

  if  (_cancelFlag  ||  (!_successful))
    return;

  if  (_examples.QueueSize () > 64000)
  {
    kkint32  numPartsNeeded = (_examples.QueueSize () / 64000);
    if  ((_examples.QueueSize () % 64000) > 0)
      numPartsNeeded++;

    kkuint32  maxPartSize = (_examples.QueueSize () / numPartsNeeded) + 1;

    kkint32  partNum = 0;
    FeatureVectorList::const_iterator idx = _examples.begin ();

    while  ((idx != _examples.end ())  &&  (_successful)  &&  (!_cancelFlag))
    {
      FeatureVectorListPtr  part = _examples.ManufactureEmptyList (false);

      while  ((idx != _examples.end ())  &&  (part->QueueSize () < maxPartSize))
      {
        part->PushOnBack (*idx);
        idx++;
      }

      KKStr  partFileName = osRemoveExtension (_fileName) + "-" + 
                            StrFormatInt (partNum, "00") + "." +
                            osGetFileExtension (_fileName);

      SaveFeatureFile (partFileName, _selFeatures, *part, numExamplesWritten, _cancelFlag, _successful, _log);

      partNum++;
      delete  part; part = NULL;
    }
  }
}  /* SaveFeatureFileMultipleParts */
コード例 #3
0
FeatureVectorListPtr  FeatureEncoder2::EncodedFeatureVectorList (const FeatureVectorList&  srcData)  const
{
  if  (srcData.AllFieldsAreNumeric ())
    return  srcData.DuplicateListAndContents ();

  FeatureVectorListPtr  encodedFeatureVectorList = new FeatureVectorList (encodedFileDesc, true);

  FeatureVectorList::const_iterator  idx;
  for  (idx = srcData.begin ();   idx != srcData.end ();  idx++)
  {
    FeatureVectorPtr  srcExample = *idx;
    FeatureVectorPtr  encodedFeatureVector = EncodeAExample (srcExample);
    encodedFeatureVector->MLClass (srcExample->MLClass ());
    encodedFeatureVectorList->PushOnBack (encodedFeatureVector);
  }

  return  encodedFeatureVectorList;
}  /* EncodedFeatureVectorList */
コード例 #4
0
void  GradeClassification::ValidateThatBothListsHaveSameEntries (FeatureVectorList&  groundTruth, 
                                                                 FeatureVectorList&  examplesToGrade,
                                                                 bool&               theyAreTheSame
                                                                )
{
  theyAreTheSame = true;  // We will assume that they are the same to start with.

  int  missingExamplesToGrade = 0;
  int  missingGroundTruthExamples = 0;

  groundTruth.SortByRootName ();
  examplesToGrade.SortByRootName ();

  *report << endl << endl << endl
          << "Missing Examples To Grade" << endl
          << "=========================" << endl;

  ImageFeaturesList::iterator  idx;
  for  (idx = groundTruth.begin ();  idx !=  groundTruth.end ();  idx++)
  {
    FeatureVectorPtr  groundTruthExample = *idx;

    KKStr  rootName = osGetRootName (groundTruthExample->ImageFileName ());

    FeatureVectorPtr  exampleToGrade = examplesToGrade.LookUpByRootName (rootName);

    if  (!exampleToGrade)
    {
      theyAreTheSame = false;
      *report << rootName << "\t" << "*** MISSING ***" << "\t" << groundTruthExample->ImageFileName () << endl;
      missingExamplesToGrade++;
    }
  }

  if  (missingExamplesToGrade == 0)
  {
    *report  << "    *** None ***" << endl;
  }


  *report << endl << endl << endl
          << "Missing Ground Truth Examples" << endl
          << "=============================" << endl;

  for  (idx = examplesToGrade.begin ();  idx !=  examplesToGrade.end ();  idx++)
  {
    FeatureVectorPtr  exampleToGrade = *idx;

    KKStr  rootName = osGetRootName (exampleToGrade->ImageFileName ());

    FeatureVectorPtr  groundTruthExample = groundTruth.LookUpByRootName (rootName);

    if  (!groundTruthExample)
    {
      theyAreTheSame = false;
      *report << rootName << "\t" << "*** MISSING ***" << "\t" << exampleToGrade->ImageFileName () << "\t" << endl;
      missingGroundTruthExamples++;
    }
  }

  if  (missingGroundTruthExamples == 0)
  {
    *report << "   *** None ***" << endl;
  }
} /* ValidateThatBothListsHaveSameEntries */