better warning at multiclass, fix cran check

This commit is contained in:
tqchen 2015-01-25 10:05:47 -08:00
parent da9f0989c6
commit f848844310
4 changed files with 13 additions and 6 deletions

View File

@ -339,7 +339,7 @@ class FMatrixPage : public IFMatrix {
}
if (ktop % 100000 == 0) {
utils::Printf("\r \r");
utils::Printf("InitCol: %lu rows ", static_cast<unsigned long>(ktop));
utils::Printf("InitCol: %lu rows ", static_cast<unsigned long>(ktop));
}
}
}

View File

@ -227,14 +227,19 @@ class BoostLearner : public rabit::ISerializable {
*/
inline void SaveModel(const char *fname) const {
FILE *fp;
bool use_stdout = false;;
#ifndef XGBOOST_STRICT_CXX98_
if (!strcmp(fname, "stdout")) {
fp = stdout;
} else {
use_stdout = true;
} else
#endif
{
fp = utils::FopenCheck(fname, "wb");
}
utils::FileStream fo(fp);
std::string header;
if (save_base64 != 0|| fp == stdout) {
if (save_base64 != 0|| use_stdout) {
fo.Write("bs64\t", 5);
utils::Base64OutStream bout(fp);
this->SaveModel(bout);
@ -243,7 +248,9 @@ class BoostLearner : public rabit::ISerializable {
fo.Write("binf", 4);
this->SaveModel(fo);
}
if (fp != stdout) fclose(fp);
if (!use_stdout) {
fclose(fp);
}
}
/*!
* \brief check if data matrix is ready to be used by training,

View File

@ -206,7 +206,8 @@ class SoftmaxMultiClassObj : public IObjFunction {
Softmax(&rec);
const unsigned j = i % nstep;
int label = static_cast<int>(info.labels[j]);
utils::Check(label < nclass, "SoftmaxMultiClassObj: label exceed num_class");
utils::Check(label >= 0 && label < nclass,
"SoftmaxMultiClassObj: label must be in [0, num_class)");
const float wt = info.GetWeight(j);
for (int k = 0; k < nclass; ++k) {
float p = rec[k];

View File

@ -208,7 +208,6 @@ struct SparseCSRFileBuilder {
fo->Write(BeginPtr(buffer_data), (rptr[end] - rptr[begin]) * sizeof(IndexType));
}
}
printf("CSV::begin_dat=%lu\n", begin_data);
}
protected:
inline void WriteBuffer(void) {