Menu

classify a instance(supervised learning)

Help
2012-07-07
2012-09-14
  • Nobody/Anonymous

    hi

    i want to classify a instance of a dataset,the class of my instances is
    categorical,how can with predict return a categorical?

    but my program do not work true

    please help me

        GMatrix* pData= GMatrix::loadArff("/home/t3/yousefian/dataset/darpa99/Extract-features/W4-2.arff"); // load some data
        //Holder hm(pM); // make sure it will be cleaned up later
        Holder<GMatrix> hData(pData);
        cout<<"pdata"<<"RowSize: "<<pData->rows()<<"ColSize: "<<pData->cols()<<endl;//return: pdataRowSize: 19158 ColSize: 20
        GMatrix* pFeatures = pData->cloneSub(0, 0, pData->rows(), pData->cols() - 1);
        cout<<"pFeatures"<<"RowSize: "<<pFeatures->rows()<<"ColSize: "<<pFeatures->cols()<<endl;//return: pFeaturesRowSize: 19158 ColSize: 19
            Holder<GMatrix> hFeatures(pFeatures);
            GMatrix* pLabels = pData->cloneSub(0, pData->cols() - 1, pData->rows(), 1);
            cout<<"pLables"<<"RowSize: "<<pLabels->rows()<<"ColSize: "<<pLabels->cols()<<endl;//return: pLablesRowSize: 19158 ColSize: 1
            Holder<GMatrix> hLabels(pLabels);
    
    
            GRand rand(0);
            GKNN modell(rand);
            modell.setNeighborCount(3);
            modell.train(*pFeatures, *pLabels);
    
            double pOut[1];
    
                modell.predict(pFeatures->row(37), pOut);
    

    thanks

     
  • Mike Gashler

    Mike Gashler - 2012-07-20

    Your code looks right to me. Can you describe how your actual results differ
    from your expected results?

     
  • Nobody/Anonymous

    thanks for you attention

    how can return lable of row(37)??

    cout<< pOut dont worked!!

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.