fairnessforensics / wiggum

simpson's paradox inspired fairness forensics
https://fairnessforensics.github.io/wiggum/
MIT License
5 stars 3 forks source link

Issue visualizing pattern_tree #222

Open cegme opened 9 months ago

cegme commented 9 months ago

I tried to run the pattern tree example but I am getting the error below.

Setup: MacBook Pro Apple M2 Max Pre setup: brew install pyenv pipenv

git clone ... git branch pattern_tree

Note: I had to change the default port to 5001 because an apple display using 5000.

pipenv run python3 run.py

Data folder: OK_President2_TwoParty chose on df.csv Rank by Percentage

var_type: all categorical except for Votes2016 and Votes2020

role: District2010Cycle=splitby District2020Cycle=splitby Party=independent Votes2016=dependent Votes2016=dependent

Clicked [Interactive Exploration]

Error

Traceback (most recent call last):
  File "/Users/christan/.local/share/virtualenvs/wiggum-U2i8wUjT/lib/python3.8/site-packages/flask/app.py", line 1478, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/christan/.local/share/virtualenvs/wiggum-U2i8wUjT/lib/python3.8/site-packages/flask/app.py", line 1458, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/christan/.local/share/virtualenvs/wiggum-U2i8wUjT/lib/python3.8/site-packages/flask/app.py", line 1455, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/christan/.local/share/virtualenvs/wiggum-U2i8wUjT/lib/python3.8/site-packages/flask/app.py", line 869, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/christan/.local/share/virtualenvs/wiggum-U2i8wUjT/lib/python3.8/site-packages/flask/app.py", line 867, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/christan/.local/share/virtualenvs/wiggum-U2i8wUjT/lib/python3.8/site-packages/flask/app.py", line 852, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/Users/christan/projects/wiggum/wiggum_app/controller.py", line 42, in explore
    labeled_df_setup.get_subgroup_trends_1lev(trend_list)
  File "/Users/christan/projects/wiggum/wiggum/detectors.py", line 273, in get_subgroup_trends_1lev
    agg_trends = cur_trend.get_trends(self.df,'agg_trend')
  File "/Users/christan/projects/wiggum/wiggum/trend_components/categorical.py", line 555, in get_trends
    stat_df = stat_df.assign(stat=stat_df.div(stat_df.sum()).round(3))
  File "/Users/christan/.local/share/virtualenvs/wiggum-U2i8wUjT/lib/python3.8/site-packages/pandas/core/frame.py", line 4844, in assign
    data[k] = com.apply_if_callable(v, data)
  File "/Users/christan/.local/share/virtualenvs/wiggum-U2i8wUjT/lib/python3.8/site-packages/pandas/core/frame.py", line 3940, in __setitem__
    self._set_item_frame_value(key, value)
  File "/Users/christan/.local/share/virtualenvs/wiggum-U2i8wUjT/lib/python3.8/site-packages/pandas/core/frame.py", line 4069, in _set_item_frame_value
    raise ValueError("Columns must be same length as key")
ValueError: Columns must be same length as key
cegme commented 9 months ago

@Shine226 I just changed the port to 5001 and there is no different between the two branches.

git diff gerrymanderingdemo..interactive_lasso

I am still getting the same error

cegme commented 9 months ago

@Shine226 on a fresh install on an Intel Mac I had the same error.

My steps after cloning and going to the interactive_lasso directory:

pipenv run pip install .
pipenv run pip install scikit-learn
pipenv run python3 run.py

I correctly chose the folder, and below is the output.

 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 129-920-441
127.0.0.1 - - [07/Nov/2023 22:22:07] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Nov/2023 22:22:14] "POST / HTTP/1.1" 200 -
127.0.0.1 - - [07/Nov/2023 22:22:20] "POST / HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/flask/app.py", line 2552, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/flask/app.py", line 2532, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/flask/app.py", line 2529, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/Users/cgrant/scratch/wiggum/wiggum_app/controller.py", line 361, in main
    trend_list = [wg.all_trend_types[trend]() for trend in user_trends]
  File "/Users/cgrant/scratch/wiggum/wiggum_app/controller.py", line 361, in <listcomp>
    trend_list = [wg.all_trend_types[trend]() for trend in user_trends]
KeyError: ''
127.0.0.1 - - [07/Nov/2023 22:22:24] "POST / HTTP/1.1" 302 -
127.0.0.1 - - [07/Nov/2023 22:22:24] "GET /interact HTTP/1.1" 200 -
127.0.0.1 - - [07/Nov/2023 22:22:24] "POST /interact HTTP/1.1" 200 -
127.0.0.1 - - [07/Nov/2023 22:22:25] "POST /explore HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/flask/app.py", line 2552, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/flask/app.py", line 2532, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/flask/app.py", line 2529, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/Users/cgrant/scratch/wiggum/wiggum_app/controller.py", line 42, in explore
    labeled_df_setup.get_subgroup_trends_1lev(trend_list)
  File "/Users/cgrant/scratch/wiggum/wiggum/detectors.py", line 273, in get_subgroup_trends_1lev
    agg_trends = cur_trend.get_trends(self.df,'agg_trend')
  File "/Users/cgrant/scratch/wiggum/wiggum/trend_components/categorical.py", line 555, in get_trends
    stat_df = stat_df.assign(stat=stat_df.div(stat_df.sum()).round(3))
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/pandas/core/frame.py", line 4486, in assign
    data[k] = com.apply_if_callable(v, data)
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/pandas/core/frame.py", line 3602, in __setitem__
    self._set_item_frame_value(key, value)
  File "/Users/cgrant/.local/share/virtualenvs/wiggum-v53Y4_F0/lib/python3.7/site-packages/pandas/core/frame.py", line 3729, in _set_item_frame_value
    raise ValueError("Columns must be same length as key")
ValueError: Columns must be same length as key