dmatrix2np
dmatrix2np copied to clipboard
OSError: [Errno 22] Invalid argument
If I do
from dmatrix2np import dmatrix_to_numpy
x_test = xgboost.DMatrix(test_data_df)
x_test_np = dmatrix_to_numpy(x_test)
I get
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/tmp/ipykernel_23836/416855278.py in <module>
1 from dmatrix2np import dmatrix_to_numpy
2
----> 3 x_test_nft_np = dmatrix_to_numpy(x_test_nft)
~/.pyenv/versions/anaconda3-2020.11/lib/python3.8/site-packages/dmatrix2np/dmatrix_to_numpy.py in dmatrix_to_numpy(dmatrix)
39 with tempfile.NamedTemporaryFile(delete=False) as fp:
40 dmatrix.save_binary(fp.name)
---> 41 result = stream_parser(fp, dmatrix.num_row(), dmatrix.num_col()).parse()
42 finally:
43 # We can safely remove the temp file now, parsing process finished
~/.pyenv/versions/anaconda3-2020.11/lib/python3.8/site-packages/dmatrix2np/dmatrix_v_1_0_0_stream_parser.py in parse(self)
20 self._parse_magic()
21 self._parse_version()
---> 22 self._skip_fields()
23 self._parse_offset_vector()
24 self._parse_data_vector()
~/.pyenv/versions/anaconda3-2020.11/lib/python3.8/site-packages/dmatrix2np/dmatrix_v_1_0_0_stream_parser.py in _skip_fields(self)
39 fields_count, = self._read_struct(VECTOR_SIZE_STRUCT)
40 for _ in range(fields_count):
---> 41 self._skip_field()
42
43 def _skip_field(self):
~/.pyenv/versions/anaconda3-2020.11/lib/python3.8/site-packages/dmatrix2np/dmatrix_v_1_0_0_stream_parser.py in _skip_field(self)
44 # Skip field name (pascal string)
45 name_size, = self._read_struct(VECTOR_SIZE_STRUCT)
---> 46 self._handle.seek(name_size, SEEK_CUR)
47
48 # Find field type
~/.pyenv/versions/anaconda3-2020.11/lib/python3.8/tempfile.py in func_wrapper(*args, **kwargs)
472 @_functools.wraps(func)
473 def func_wrapper(*args, **kwargs):
--> 474 return func(*args, **kwargs)
475 # Avoid closing the file as long as the wrapper is alive,
476 # see issue #18879.
OSError: [Errno 22] Invalid argument
I'm using xgboost version '1.6.2'. dmatric2np is the latest.