Closed huroh closed 10 years ago
I get a similar KeyError
INFER * FROM training WITH CONFIDENCE 0.9 LIMIT 20
Traceback (most recent call last):
File "run_script.py", line 27, in
when running: DROP BTABLE training; CREATE BTABLE training FROM data_selectedCols_trainingAndTest_outcome_subset.csv; CREATE 10 MODELS FOR training; INFER * FROM training WITH CONFIDENCE 0.9 LIMIT 20;
on this file https://dl.dropboxusercontent.com/u/68514/bayesdb/data_selectedCols_trainingAndTest_outcome_subset.csv
Thanks for the bug report Hubert. We are aware of both of these issues, and will have fixes in the next release. Sorry about that! In the meantime, a hacky way you can fix the first one is removing 'str(...)' in line 281 in data_utils.py, so it looks like return M_c['column_metadata'][cidx]['value_to_code'][int(code)]. For the second, you may have to wait until the next release (which should be relatively soon).
Thanks - looking forward to the next release! What's the difference between the two errors? In the first example I am trying to INFER on a numerical variable after having imported samples. In the second, I am trying to INFER on a categorical variable, without any import.
So, without running ANALYZE or importing samples, the results for INFER won't make sense. But bugs like this shouldn't depend on whether you've run ANALYZE or imported samples. If you find a case where ANALYZE or import samples causes a bug like this to appear or disappear, please report it.
The difference that's causing the bug is just INFERing on categorical data, I believe.
Ah ha - thanks - I managed to miss that key point :-)
Fix is in the postgresdev branch -- will be merged to master when the release occurs.
After importing samples to a table, and running the INFER function to predict a column of omitted values, I always get this inscrutable 'KeyError':
Traceback (most recent call last): File "run_script.py", line 27, in
run_example()
File "run_script.py", line 12, in run_example
client(open(file_path, 'r'), wait=True)
File "/home/bayesdb/bayesdb/bayesdb/client.py", line 59, in call
return self.execute(call_input, pretty, timing, wait, plots)
File "/home/bayesdb/bayesdb/bayesdb/client.py", line 82, in execute
result = self.execute_line(line, pretty, timing)
File "/home/bayesdb/bayesdb/bayesdb/client.py", line 104, in execute_line
result = self.call_bayesdb_engine(method_name, args_dict)
File "/home/bayesdb/bayesdb/bayesdb/client.py", line 55, in call_bayesdb_engine
out = method(*args)
File "/home/bayesdb/bayesdb/bayesdb/engine.py", line 259, in infer
imputations_list = [(r, c, du.convert_code_to_value(M_c, c, code)) for r,c,code in ret]
File "/home/bayesdb/crosscat/crosscat/utils/data_utils.py", line 281, in convert_code_to_value
return M_c['column_metadata'][cidx]['value_to_code'][str(int(code))]
KeyError: '26'
Relevant files: https://www.dropbox.com/sh/ulxptvzwy3n0wtg/Z2nWz5TiEm/bayesdb