rename findex->index

This commit is contained in:
tqchen@graphlab.com 2014-08-27 10:52:27 -07:00
parent f3a3470916
commit d5a5e0a42a
5 changed files with 10 additions and 12 deletions

View File

@ -70,12 +70,12 @@ struct SparseBatch {
/*! \brief an entry of sparse vector */
struct Entry {
/*! \brief feature index */
bst_uint findex;
bst_uint index;
/*! \brief feature value */
bst_float fvalue;
// default constructor
Entry(void) {}
Entry(bst_uint findex, bst_float fvalue) : findex(findex), fvalue(fvalue) {}
Entry(bst_uint index, bst_float fvalue) : index(index), fvalue(fvalue) {}
/*! \brief reversely compare feature values */
inline static bool CmpValue(const Entry &a, const Entry &b) {
return a.fvalue < b.fvalue;
@ -190,7 +190,7 @@ class FMatrixS : public FMatrixInterface<FMatrixS>{
}
}
inline bst_uint rindex(void) const {
return dptr_->findex;
return dptr_->index;
}
inline bst_float fvalue(void) const {
return dptr_->fvalue;
@ -345,7 +345,7 @@ class FMatrixS : public FMatrixInterface<FMatrixS>{
buffered_rowset_.push_back(static_cast<bst_uint>(batch.base_rowid+i));
SparseBatch::Inst inst = batch[i];
for (bst_uint j = 0; j < inst.length; ++j) {
builder.AddBudget(inst[j].findex);
builder.AddBudget(inst[j].index);
}
}
}
@ -362,7 +362,7 @@ class FMatrixS : public FMatrixInterface<FMatrixS>{
++ktop;
SparseBatch::Inst inst = batch[i];
for (bst_uint j = 0; j < inst.length; ++j) {
builder.PushElem(inst[j].findex,
builder.PushElem(inst[j].index,
Entry((bst_uint)(batch.base_rowid+i),
inst[j].fvalue));
}

View File

@ -150,7 +150,7 @@ class GBLinear : public IGradBooster<FMatrix> {
for (int gid = 0; gid < model.param.num_output_group; ++gid) {
float psum = model.bias()[gid];
for (bst_uint i = 0; i < inst.length; ++i) {
psum += inst[i].fvalue * model[inst[i].findex][gid];
psum += inst[i].fvalue * model[inst[i].index][gid];
}
preds[gid] = psum;
}

View File

@ -62,7 +62,7 @@ class DMatrixSimple : public DataMatrix {
inline size_t AddRow(const std::vector<SparseBatch::Entry> &feats) {
for (size_t i = 0; i < feats.size(); ++i) {
row_data_.push_back(feats[i]);
info.info.num_col = std::max(info.info.num_col, static_cast<size_t>(feats[i].findex+1));
info.info.num_col = std::max(info.info.num_col, static_cast<size_t>(feats[i].index+1));
}
row_ptr_.push_back(row_ptr_.back() + feats.size());
info.info.num_row += 1;
@ -81,7 +81,7 @@ class DMatrixSimple : public DataMatrix {
std::vector<SparseBatch::Entry> feats;
while (fscanf(file, "%s", tmp) == 1) {
SparseBatch::Entry e;
if (sscanf(tmp, "%u:%f", &e.findex, &e.fvalue) == 2) {
if (sscanf(tmp, "%u:%f", &e.index, &e.fvalue) == 2) {
feats.push_back(e);
} else {
if (!init) {

View File

@ -493,13 +493,13 @@ class RegTree: public TreeModel<bst_float, RTreeNodeStat>{
/*! \brief fill the vector with sparse vector */
inline void Fill(const SparseBatch::Inst &inst) {
for (bst_uint i = 0; i < inst.length; ++i) {
data[inst[i].findex].fvalue = inst[i].fvalue;
data[inst[i].index].fvalue = inst[i].fvalue;
}
}
/*! \brief drop the trace after fill, must be called after fill */
inline void Drop(const SparseBatch::Inst &inst) {
for (bst_uint i = 0; i < inst.length; ++i) {
data[inst[i].findex].flag = -1;
data[inst[i].index].flag = -1;
}
}
/*! \brief get ith value */

View File

@ -62,8 +62,6 @@ inline IUpdater<FMatrix>* CreateUpdater(const char *name) {
if (!strcmp(name, "prune")) return new TreePruner<FMatrix>();
if (!strcmp(name, "refresh")) return new TreeRefresher<FMatrix, GradStats>();
if (!strcmp(name, "grow_colmaker")) return new ColMaker<FMatrix, GradStats>();
if (!strcmp(name, "grow_colmaker2")) return new ColMaker<FMatrix, CVGradStats<2> >();
if (!strcmp(name, "grow_colmaker5")) return new ColMaker<FMatrix, CVGradStats<5> >();
utils::Error("unknown updater:%s", name);
return NULL;
}