felixbur / nkululeko

Machine learning speaker characteristics
MIT License
32 stars 5 forks source link

Error: TypeError: ufunc 'isfinite' not supported for the input types #115

Closed bagustris closed 2 months ago

bagustris commented 7 months ago

I am getting error when running test files,

python -m nkululeko.explore --config tests/exp_agedb_explore_data.ini

Output:


DEBUG explore: running exp_agedb_explore from config tests/exp_agedb_explore_data.ini, nkululeko version 0.83.0
DEBUG experiment: value for type not found, using default: audformat
DEBUG dataset: emodb: loading from ./data/emodb/emodb
DEBUG dataset: emodb: loading tables: []
DEBUG dataset: value for files_tables not found, using default: ['files']
DEBUG dataset: value for label not found, using default: age
DEBUG dataset: emodb: loaded with 535 samples: got targets: True, got speakers: True (10), got sexes: True
DEBUG datafilter: emodb: limited samples to 20, reduced samples from 535 to 20
DEBUG experiment: target: age
DEBUG experiment: Target labels (from config): ['u29', 'ü29']
DEBUG experiment: loaded databases emodb
DEBUG dataset: splitting database emodb with strategy random
DEBUG dataset: value for test_size not found, using default: 20
DEBUG dataset: emodb: [16/4] samples in train/test
DEBUG dataset: emodb: 4 samples in test and 16 samples in train
DEBUG experiment: 3 speakers in test and 8 speakers in train
DEBUG explore: train shape : (16, 6), test shape:(4, 6)
DEBUG plots: value for dist_type not found, using default: hist
DEBUG plots: plotting ['gender', 'duration']
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/bagus/github/nkululeko/nkululeko/explore.py", line 75, in <module>
    main(cwd)  # use this if you want to state the config file path on command line
  File "/home/bagus/github/nkululeko/nkululeko/explore.py", line 68, in main
    expr.analyse_features(needs_feats)
  File "/home/bagus/github/nkululeko/nkululeko/experiment.py", line 516, in analyse_features
    self.plot_distribution(df_labels)
  File "/home/bagus/github/nkululeko/nkululeko/experiment.py", line 315, in plot_distribution
    plot.plot_distributions(df_labels)
  File "/home/bagus/github/nkululeko/nkululeko/plots.py", line 197, in plot_distributions
    ax, caption = self._plot2cont_cat(
  File "/home/bagus/github/nkululeko/nkululeko/plots.py", line 258, in _plot2cont_cat
    ax = sns.lmplot(data=df, x=cont1, y=cont2, hue=cat)
  File "/home/bagus/github/nkululeko/.env/lib/python3.8/site-packages/seaborn/regression.py", line 651, in lmplot
    facets.map_dataframe(regplot, x=x, y=y, **regplot_kws)
  File "/home/bagus/github/nkululeko/.env/lib/python3.8/site-packages/seaborn/axisgrid.py", line 825, in map_dataframe
    self._facet_plot(func, ax, args, kwargs)
  File "/home/bagus/github/nkululeko/.env/lib/python3.8/site-packages/seaborn/axisgrid.py", line 854, in _facet_plot
    func(*plot_args, **plot_kwargs)
  File "/home/bagus/github/nkululeko/.env/lib/python3.8/site-packages/seaborn/regression.py", line 775, in regplot
    plotter.plot(ax, scatter_kws, line_kws)
  File "/home/bagus/github/nkululeko/.env/lib/python3.8/site-packages/seaborn/regression.py", line 384, in plot
    self.lineplot(ax, line_kws)
  File "/home/bagus/github/nkululeko/.env/lib/python3.8/site-packages/seaborn/regression.py", line 442, in lineplot
    ax.fill_between(grid, *err_bands, facecolor=fill_color, alpha=.15)
  File "/home/bagus/github/nkululeko/.env/lib/python3.8/site-packages/matplotlib/__init__.py", line 1446, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/home/bagus/github/nkululeko/.env/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 5425, in fill_between
    return self._fill_between_x_or_y(
  File "/home/bagus/github/nkululeko/.env/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 5330, in _fill_between_x_or_y
    ind, dep1, dep2 = map(
  File "/home/bagus/github/nkululeko/.env/lib/python3.8/site-packages/numpy/ma/core.py", line 2360, in masked_invalid
    res = masked_where(~(np.isfinite(a)), a, copy=copy)
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''  
bagustris commented 7 months ago

I run it again but the error was gone, I don't no why. Maybe updating numpy.

bagustris commented 6 months ago

@felixbur I reopened this issue since I can reproduce this issue. This issue gone when I run for second time.

Steps to reproduce:

  1. Remove all results inside test.

    rm -fr tests/results
  2. Run it once, it will fail.

    python -m nkululeko.explore --config tests/exp_agedb_explore_data.ini
  3. Run for the second time, it will success and done.

    python -m nkululeko.explore --config tests/exp_agedb_explore_data.ini
felixbur commented 6 months ago

thanks, I'll check it out

felixbur commented 2 months ago

that works now, right? can we close the issue, @bagustris ?