Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix index in eval_session_df breaking online trial eval #272

Merged
merged 1 commit into from Jan 20, 2019
Merged

Conversation

kengz
Copy link
Owner

@kengz kengz commented Jan 20, 2019

Feature / Fix

Online eval trial plot was broken. Turns out the issue was when trial analysis tries to read eval session_fitness_df, it encounter series with duplicate index (all of them are 0 because of the appending by row during session eval).

Error log:

Traceback (most recent call last):
  File "run_lab.py", line 100, in <module>
    main()
  File "run_lab.py", line 84, in main
    run_by_mode(*args)
  File "run_lab.py", line 77, in run_by_mode
    run_old_mode(spec_file, spec_name, lab_mode)
  File "run_lab.py", line 64, in run_old_mode
    analysis.analyze_eval_trial(spec, info_space, predir)
  File "/home/ubuntu/SLM-Lab/slm_lab/experiment/analysis.py", line 592, in analyze_eval_trial
    analyze_trial(trial)
  File "/home/ubuntu/SLM-Lab/slm_lab/experiment/analysis.py", line 556, in analyze_trial
    trial_fig = plot_trial(trial.spec, trial.info_space)
  File "/home/ubuntu/SLM-Lab/slm_lab/experiment/analysis.py", line 426, in plot_trial
    aeb_rewards_df = gather_aeb_rewards_df(aeb, session_datas, max_tick_unit)
  File "/home/ubuntu/SLM-Lab/slm_lab/experiment/analysis.py", line 362, in gather_aeb_rewards_df
    aeb_rewards_df = pd.DataFrame(aeb_session_rewards)
  File "/home/ubuntu/anaconda3/envs/lab/lib/python3.6/site-packages/pandas/core/frame.py", line 330, in __init__
    mgr = self._init_dict(data, index, columns, dtype=dtype)
  File "/home/ubuntu/anaconda3/envs/lab/lib/python3.6/site-packages/pandas/core/frame.py", line 461, in _init_dict
    return _arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype)
  File "/home/ubuntu/anaconda3/envs/lab/lib/python3.6/site-packages/pandas/core/frame.py", line 6168, in _arrays_to_mgr
    arrays = _homogenize(arrays, index, dtype)
  File "/home/ubuntu/anaconda3/envs/lab/lib/python3.6/site-packages/pandas/core/frame.py", line 6465, in _homogenize
    v = v.reindex(index, copy=False)
  File "/home/ubuntu/anaconda3/envs/lab/lib/python3.6/site-packages/pandas/core/series.py", line 2681, in reindex
    return super(Series, self).reindex(index=index, **kwargs)
  File "/home/ubuntu/anaconda3/envs/lab/lib/python3.6/site-packages/pandas/core/generic.py", line 3023, in reindex
    fill_value, copy).__finalize__(self)
  File "/home/ubuntu/anaconda3/envs/lab/lib/python3.6/site-packages/pandas/core/generic.py", line 3041, in _reindex_axes
    copy=copy, allow_dups=False)
  File "/home/ubuntu/anaconda3/envs/lab/lib/python3.6/site-packages/pandas/core/generic.py", line 3145, in _reindex_with_indexers
    copy=copy)
  File "/home/ubuntu/anaconda3/envs/lab/lib/python3.6/site-packages/pandas/core/internals.py", line 4139, in reindex_indexer
    self.axes[axis]._can_reindex(indexer)
  File "/home/ubuntu/anaconda3/envs/lab/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2944, in _can_reindex
    raise ValueError("cannot reindex from a duplicate axis")
ValueError: cannot reindex from a duplicate axis

Fix this by adding totalt as the index to append a row to eval_session_df

@kengz kengz changed the title Fix index in eval fitness_df breaking online trial eval Fix index in eval_session_df breaking online trial eval Jan 20, 2019
@kengz kengz merged commit eb9bdb9 into master Jan 20, 2019
@kengz kengz deleted the fix-index branch January 20, 2019 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant