Commit 5d10d792 authored by Joe Grimes's avatar Joe Grimes
Browse files

Checkpoint before switching to masking

parent 5180b6c4
Loading
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -76,6 +76,17 @@ LossFunctionClustering::LossFunctionClustering(std::vector<double> prop_train,
    set_nfeat(_n_feat);
}

//void LossFunctionClustering::populate_mask() {
////Mask should be flattened or n class per task * n sample size of each prop train cluster
//for (auto x : _prop_train){
//
//    int len =
//
//}


}

LossFunctionClustering::LossFunctionClustering(const std::shared_ptr<LossFunction>& o)
    : LossFunctionClustering(
          o->prop_train(),
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ protected:
    std::vector<double> _a; //!< matrix to copy values from the D_Matrix
    std::map<int, std::vector<size_t>> _cluster_indices; //!< HashMap of the cluster label to its indices inside all feature values
    std::map<int, std::vector<double>> _centroids; //!< centroids of clusters to use for Davies Bouldin and Calinski
    std::vector<int> label_mask; //!< Label mask for prop train

public:
    /**
@@ -54,6 +55,7 @@ public:
    virtual double operator()(const std::vector<int>& inds) override;
    virtual double operator()(const std::vector<model_node_ptr>& feats) override;
    virtual double test_loss(const std::vector<model_node_ptr>& feats) override;
//    virtual void populate_mask();
};


+1 −2
Original line number Diff line number Diff line
@@ -44,9 +44,8 @@ double LossFunctionDaviesBouldin::get_dbi() {
        std::vector<double> mean(_n_feat, 0.0);
        for (size_t i = 0; i < indices.size(); i += _n_feat) {
            size_t samp = indices[i] / _n_feat;
            const double* p = &_a[samp * _n_feat];
            for (size_t f = 0; f < _n_feat; ++f) {
                mean[f] += p[f];
                mean[f] += _a[samp * _n_feat + f];
            }
        }
        for (double& x : mean){