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