abhishekkrthakur / autoxgb

XGBoost + Optuna
Apache License 2.0
653 stars 90 forks source link

TypeError: argument of type 'method' is not iterable #23

Open ludomare opened 2 years ago

ludomare commented 2 years ago

Hi, I try autoxgb but very quickly it returns that error:

2022-03-08 09:22:21.269 | INFO | autoxgb.autoxgb:post_init:42 - Output directory: output2 2022-03-08 09:22:21.276 | WARNING | autoxgb.autoxgb:post_init:49 - No id column specified. Will default to id. 2022-03-08 09:22:21.283 | INFO | autoxgb.autoxgb:_process_data:149 - Reading training data

TypeError Traceback (most recent call last) in () 37 fast=fast, 38 ) ---> 39 axgb.train() 10 frames /usr/local/lib/python3.7/dist-packages/autoxgb/autoxgb.py in train(self) 244 245 def train(self): --> 246 self._process_data() 247 best_params = train_model(self.model_config) 248 logger.info("Training complete")

/usr/local/lib/python3.7/dist-packages/autoxgb/autoxgb.py in _process_data(self) 148 def _process_data(self): 149 logger.info("Reading training data") --> 150 train_df = pd.read_csv(self.train_filename) 151 train_df = reduce_memory_usage(train_df) 152 problem_type = self._determine_problem_type(train_df)

/usr/local/lib/python3.7/dist-packages/pandas/util/_decorators.py in wrapper(*args, *kwargs) 309 stacklevel=stacklevel, 310 ) --> 311 return func(args, **kwargs) 312 313 return wrapper

/usr/local/lib/python3.7/dist-packages/pandas/io/parsers/readers.py in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, error_bad_lines, warn_bad_lines, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options) 584 kwds.update(kwds_defaults) 585 --> 586 return _read(filepath_or_buffer, kwds) 587 588

/usr/local/lib/python3.7/dist-packages/pandas/io/parsers/readers.py in _read(filepath_or_buffer, kwds) 480 481 # Create the parser. --> 482 parser = TextFileReader(filepath_or_buffer, **kwds) 483 484 if chunksize or iterator:

/usr/local/lib/python3.7/dist-packages/pandas/io/parsers/readers.py in init(self, f, engine, **kwds) 809 self.options["has_index_names"] = kwds["has_index_names"] 810 --> 811 self._engine = self._make_engine(self.engine) 812 813 def close(self):

/usr/local/lib/python3.7/dist-packages/pandas/io/parsers/readers.py in _make_engine(self, engine) 1038 ) 1039 # error: Too many arguments for "ParserBase" -> 1040 return mapping[engine](self.f, **self.options) # type: ignore[call-arg] 1041 1042 def _failover_to_python(self):

/usr/local/lib/python3.7/dist-packages/pandas/io/parsers/c_parser_wrapper.py in init(self, src, **kwds) 49 50 # open handles ---> 51 self._open_handles(src, kwds) 52 assert self.handles is not None 53

/usr/local/lib/python3.7/dist-packages/pandas/io/parsers/base_parser.py in _open_handles(self, src, kwds) 227 memory_map=kwds.get("memory_map", False), 228 storage_options=kwds.get("storage_options", None), --> 229 errors=kwds.get("encoding_errors", "strict"), 230 ) 231

/usr/local/lib/python3.7/dist-packages/pandas/io/common.py in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options) 583 584 # read_csv does not know whether the buffer is opened in binary/text mode --> 585 if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 586 mode += "b" 587

/usr/local/lib/python3.7/dist-packages/pandas/io/common.py in _is_binary_mode(handle, mode) 960 # classes that expect bytes 961 binary_classes = (BufferedIOBase, RawIOBase) --> 962 return isinstance(handle, binary_classes) or "b" in getattr(handle, "mode", mode)

TypeError: argument of type 'method' is not iterable

Don't know why..??? Thank you all for your help

My code: from autoxgb import AutoXGB

required parameters:

train_filename = df.iloc[:round(df.shape[0]*.8)] output = "output2"

optional parameters

test_filename = None task = None idx = df.index targets = ["Goal"] features = None categorical_features = None use_gpu = False num_folds = 5 seed = 42 num_trials = 100 time_limit = 360 fast = False

Now its time to train the model!

axgb = AutoXGB( train_filename=train_filename, output=output, test_filename=test_filename, task=task, idx=idx, targets=targets, features=features, categorical_features=categorical_features, use_gpu=use_gpu, num_folds=num_folds, seed=seed, num_trials=num_trials, time_limit=time_limit, fast=fast, ) axgb.train()

xhulianoThe1 commented 1 year ago

Should be because the train_filename is of type str and represents the input path of the csv file. You passed in a dataframe instead so it threw this error.