allow nan as mssing
This commit is contained in:
parent
076159cf7a
commit
ed87eb61bd
@ -132,6 +132,7 @@ extern "C"{
|
||||
bst_ulong nrow,
|
||||
bst_ulong ncol,
|
||||
float missing) {
|
||||
bool nan_missing = std::isnan(missing);
|
||||
DMatrixSimple *p_mat = new DMatrixSimple();
|
||||
DMatrixSimple &mat = *p_mat;
|
||||
mat.info.info.num_row = nrow;
|
||||
@ -139,11 +140,15 @@ extern "C"{
|
||||
for (bst_ulong i = 0; i < nrow; ++i, data += ncol) {
|
||||
bst_ulong nelem = 0;
|
||||
for (bst_ulong j = 0; j < ncol; ++j) {
|
||||
if (data[j] != missing) {
|
||||
if (std::isnan(data[j])) {
|
||||
utils::Check(nan_missing, "There are NAN in the matrix, however, you did not set missing=NAN");
|
||||
} else {
|
||||
if (nan_missing || data[j] != missing) {
|
||||
mat.row_data_.push_back(RowBatch::Entry(j, data[j]));
|
||||
++nelem;
|
||||
}
|
||||
}
|
||||
}
|
||||
mat.row_ptr_.push_back(mat.row_ptr_.back() + nelem);
|
||||
}
|
||||
return p_mat;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user