sgoldenlab / simba

SimBA (Simple Behavioral Analysis), a pipeline and GUI for developing supervised behavioral classifiers
https://simba-uw-tf-dev.readthedocs.io/
GNU General Public License v3.0
298 stars 143 forks source link

Error in generateFeatureImportanceBarGraph #22

Closed JensBlack closed 4 years ago

JensBlack commented 4 years ago

Describe the bug After starting the training with the following settings, the error occured.

grafik

[Parallel(n_jobs=-1)]: Using backend ThreadingBackend with 12 concurrent workers.
[Parallel(n_jobs=-1)]: Done  26 tasks      | elapsed:    8.9s
[Parallel(n_jobs=-1)]: Done 176 tasks      | elapsed:   51.3s
[Parallel(n_jobs=-1)]: Done 426 tasks      | elapsed:  2.1min
[Parallel(n_jobs=-1)]: Done 776 tasks      | elapsed:  3.7min
[Parallel(n_jobs=-1)]: Done 1226 tasks      | elapsed:  5.8min
[Parallel(n_jobs=-1)]: Done 1776 tasks      | elapsed:  8.4min
[Parallel(n_jobs=-1)]: Done 2000 out of 2000 | elapsed:  9.4min finished
[Parallel(n_jobs=12)]: Using backend ThreadingBackend with 12 concurrent workers.
[Parallel(n_jobs=12)]: Done  26 tasks      | elapsed:    0.0s
[Parallel(n_jobs=12)]: Done 176 tasks      | elapsed:    0.2s
[Parallel(n_jobs=12)]: Done 426 tasks      | elapsed:    0.5s
[Parallel(n_jobs=12)]: Done 776 tasks      | elapsed:    1.0s
[Parallel(n_jobs=12)]: Done 1226 tasks      | elapsed:    1.6s
[Parallel(n_jobs=12)]: Done 1776 tasks      | elapsed:    2.4s
[Parallel(n_jobs=12)]: Done 2000 out of 2000 | elapsed:    2.7s finished
[Parallel(n_jobs=12)]: Using backend ThreadingBackend with 12 concurrent workers.
[Parallel(n_jobs=12)]: Done  26 tasks      | elapsed:    0.0s
[Parallel(n_jobs=12)]: Done 176 tasks      | elapsed:    0.2s
[Parallel(n_jobs=12)]: Done 426 tasks      | elapsed:    0.5s
[Parallel(n_jobs=12)]: Done 776 tasks      | elapsed:    1.0s
[Parallel(n_jobs=12)]: Done 1226 tasks      | elapsed:    1.6s
[Parallel(n_jobs=12)]: Done 1776 tasks      | elapsed:    2.4s
[Parallel(n_jobs=12)]: Done 2000 out of 2000 | elapsed:    2.7s finished
[Parallel(n_jobs=12)]: Using backend ThreadingBackend with 12 concurrent workers.
[Parallel(n_jobs=12)]: Done  26 tasks      | elapsed:    0.0s
[Parallel(n_jobs=12)]: Done 176 tasks      | elapsed:    0.2s
[Parallel(n_jobs=12)]: Done 426 tasks      | elapsed:    0.5s
[Parallel(n_jobs=12)]: Done 776 tasks      | elapsed:    1.0s
[Parallel(n_jobs=12)]: Done 1226 tasks      | elapsed:    1.6s
[Parallel(n_jobs=12)]: Done 1776 tasks      | elapsed:    2.3s
[Parallel(n_jobs=12)]: Done 2000 out of 2000 | elapsed:    2.6s finished
Exception in thread Thread-7:
Traceback (most recent call last):
  File "D:\Anaconda\envs\simba-gpu\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "D:\Anaconda\envs\simba-gpu\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "simba.py", line 3737, in trainsinglemodel
    trainmodel2(self.projectconfigini)
  File "C:\Users\schwa\PycharmProjects\simba\simba\train_model_2.py", line 302, in trainmodel2
    generateFeatureImportanceBarGraph(log_df, N_feature_importance_bars)
UnboundLocalError: local variable 'log_df' referenced before assignment

Additional context I guess this is an error based on the missing selection/toggle of "Generate Features Importance Log". Do you need to select both?

JensBlack commented 4 years ago

I add the part from the tutorial for future reference and readability. Quote from the Readme (Generic SimBA Tutorial, 07.04.2020):

Generate Features Importance Log: Creates a .csv file that lists the importance's (gini importances) of all features for the classifier.

Generate Features Importance Bar Graph: Creates a bar chart of the top N features based on gini importances. Specify N in the N feature importance bars entry box below.

N feature importance bars: Integer defining the number of top features to be included in the bar graph (e.g., 15).

sgoldenlab commented 4 years ago

Thanks @JensBlack - as i think you got, the graph can't be created without the generate feature importance log. I will look to add a feature in the GUI to grey the Generate Feature importance bar graph out unless the generate feature importance log is ticked.

JensBlack commented 4 years ago

Okay, with both options enabled and a valid value entered the bars plotted just fine. I will close this issue then.