ersilia-os / auto-tabnet

TabNet implementation with hyperparameter search
GNU General Public License v3.0
1 stars 0 forks source link

ERROR: 'numpy.AxisError: axis 1 is out of bounds for array of dimension 1' #1

Open Femme-js opened 1 year ago

Femme-js commented 1 year ago

The main.py in this repo gives the following error when running the main.py file.

  File "/home/femme_js/auto-tabnet/main.py", line 87, in <module>
    study.optimize(optimization_function, n_trials = 5)
  File "/home/femme_js/auto-tabnet/auto/lib/python3.10/site-packages/optuna/study/study.py", line 425, in optimize
    _optimize(
  File "/home/femme_js/auto-tabnet/auto/lib/python3.10/site-packages/optuna/study/_optimize.py", line 66, in _optimize
    _optimize_sequential(
  File "/home/femme_js/auto-tabnet/auto/lib/python3.10/site-packages/optuna/study/_optimize.py", line 163, in _optimize_sequential
    frozen_trial = _run_trial(study, func, catch)
  File "/home/femme_js/auto-tabnet/auto/lib/python3.10/site-packages/optuna/study/_optimize.py", line 251, in _run_trial
    raise func_err
  File "/home/femme_js/auto-tabnet/auto/lib/python3.10/site-packages/optuna/study/_optimize.py", line 200, in _run_trial
    value_or_values = func(trial)
  File "/home/femme_js/auto-tabnet/main.py", line 61, in optimize
    fold_roc = metrics.roc_auc_score(ytest, preds, multi_class='ovr')
  File "/home/femme_js/auto-tabnet/auto/lib/python3.10/site-packages/sklearn/metrics/_ranking.py", line 566, in roc_auc_score
    return _multiclass_roc_auc_score(
  File "/home/femme_js/auto-tabnet/auto/lib/python3.10/site-packages/sklearn/metrics/_ranking.py", line 638, in _multiclass_roc_auc_score
    if not np.allclose(1, y_score.sum(axis=1)):
  File "/home/femme_js/auto-tabnet/auto/lib/python3.10/site-packages/numpy/core/_methods.py", line 49, in _sum
    return umr_sum(a, axis, dtype, out, keepdims, initial, where)
numpy.AxisError: axis 1 is out of bounds for array of dimension 1
Femme-js commented 1 year ago

This issue is resolved.

There was a problem with the objective function. According to the documentation, the n_d and n_a parameters were not given the correct syntax.

Earlier, it was n_d = trial.suggest_categorical("n_d", [8, 16, 32, 64])

I changed it to n_d = trial.suggest_int("n_d", low = 8, high = 64, step = 8)