Menu

Latest snapshot failed to build with VS 2013 Express

Help
XiaoboGu
2014-06-14
2014-06-14
  • XiaoboGu

    XiaoboGu - 2014-06-14

    The major problem is regarding to array size in the GRecommander.cpp such as

        double features[m_pUsers->cols() - m_intrinsicDims + 1];
    

    Error 14 error C2057: expected constant expression d:\amber\wrokspace\waffles\waffles-code-0f8e1ebd0992c6f12b4fc1f8438a9acc7aaee049\src\gclasses\grecommender.cpp 1396 1 GClasses

     
  • XiaoboGu

    XiaoboGu - 2014-06-14

    the following version works, just a work around

    double GHybridNonlinearPCA::predict(size_t item, size_t user)
    {
    //The user and item are reversed (the item is the user and user is the item)
    //If the user is new
    if(user >= m_pUsers->rows() || item >= m_items)
    return 0.0;

    //If the item has not yet been rated but has item features
    if(m_itemSet.find(user) == m_itemSet.end())
    {
        //find closest instances
        double* pVec = m_pUsers->row(user);
    
        //double features[m_pUsers->cols() - m_intrinsicDims + 1];
    
        double* features = new double(m_pUsers->cols() - m_intrinsicDims + 1);
    
        features[0] = 0;
        for(size_t i = m_intrinsicDims; i < m_pUsers->cols(); i++)
        {
            features[i-m_intrinsicDims+1] = pVec[i] / 0.01;
        }
        //size_t neighbors[m_numNeighbors];
        size_t* neighbors = new size_t[m_numNeighbors];
    
        //double distances[m_numNeighbors];
        double* distances = new double[m_numNeighbors];
    
        m_neighbors->neighbors(neighbors, distances, features);
    
        //sort the neighbors based on distance
        m_neighbors->sortNeighbors(m_numNeighbors, neighbors, distances);
    

    /// Commentted out portion is for returning a weighted average instead of a weighted mode
    // double sum =0;
    // double denom = 0;

        size_t counts [11];
        GIndexVec::setAll(counts, 0, 11);
        size_t i = 0;
        while(distances[i] == 0 && i < m_numNeighbors)
        {
            size_t neighbor = m_itemMap[neighbors[i]];
            if(m_pRatingCount[neighbor] > 50)
            {
                double prediction = round(((m_pMaxs[item] - m_pMins[item]) * m_pModel->forwardPropSingleOutput(m_pUsers->row(neighbor), item) + m_pMins[item])* 2.0) / 2.0;
    

    // double prediction = (m_pMaxs[item] - m_pMins[item]) * m_pModel->forwardPropSingleOutput(m_pUsers->row(neighbor), item) + m_pMins[item];
    if(prediction > m_pMaxs[item])
    prediction = m_pMaxs[item];
    if(prediction < m_pMins[item])
    prediction = m_pMins[item];
    counts[(size_t) (prediction * 2)] += m_pRatingCount[neighbor];
    }
    i++;
    /
    if(m_pRatingCount[neighbor] > 50)
    {
    sum+=prediction * m_pRatingCount[neighbor];
    denom+=m_pRatingCount[neighbor];
    }
    /
    }
    // return sum / denom;

        delete features;
        delete neighbors;
        delete distances;
    
    
        size_t predMode = 0;
        for(size_t i = 1; i < 11; i++)
        {
            if(counts[i] > counts[predMode])
                predMode = i;
        }
        return predMode / 2.0;
    }
    
    return (m_pMaxs[item] - m_pMins[item]) * m_pModel->forwardPropSingleOutput(m_pUsers->row(user), item) + m_pMins[item];
    

    }

     
  • Mike Gashler

    Mike Gashler - 2014-06-14

    Thank you! I have integrated these fixes into the tree. (I modified it slightly to use GTEMPBUF, which uses alloca, because it is faster than allocating on the heap.)

     

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.