appeler/ethnicolr

prediction functions producing ValueError: no results

Closed this issue · 8 comments

Hello,

I am working with ethnicolr 0.8 in Python 3.8. While census_ln is working, it seems all of the prediction functions are producing the same error. I have tried with TensorFlow 2.5.0, 2.5.1, and 2.5.2.

For example, running the following:

import pandas as pd
from ethnicolr import census_ln, pred_census_ln
names = [{'name': 'smith'}, {'name': 'zhang'}, {'name': 'jackson'}]
df = pd.DataFrame(names)
pred_census_ln(df,'name')

produces this output:

['api', 'black', 'hispanic', 'white']


ValueError Traceback (most recent call last)
in
6 {'name': 'jackson'}]
7 df = pd.DataFrame(names)
----> 8 pred_census_ln(df,'name')

~/.local/lib/python3.8/site-packages/ethnicolr/pred_census_ln.py in pred_census_ln(cls, df, namecol, year, num_iter, conf_int)
65 RACE = resource_filename(name, RACEFN.format(year))
66
---> 67 rdf = transform_and_pred(
68 df=df,
69 newnamecol=namecol,

~/.local/lib/python3.8/site-packages/ethnicolr/utils.py in transform_and_pred(df, newnamecol, cls, VOCAB, RACE, MODEL, NGRAMS, maxlen, num_iter, conf_int)
121
122 res = (
--> 123 pdf.groupby("rowindex")
124 .agg(
125 [

~/.local/lib/python3.8/site-packages/pandas/core/groupby/generic.py in aggregate(self, func, engine, engine_kwargs, *args, **kwargs)
943 func = maybe_mangle_lambdas(func)
944
--> 945 result, how = aggregate(self, func, *args, **kwargs)
946 if how is None:
947 return result

~/.local/lib/python3.8/site-packages/pandas/core/aggregation.py in aggregate(obj, arg, *args, **kwargs)
584 # we require a list, but not an 'str'
585 arg = cast(List[AggFuncTypeBase], arg)
--> 586 return agg_list_like(obj, arg, _axis=_axis), None
587 else:
588 result = None

~/.local/lib/python3.8/site-packages/pandas/core/aggregation.py in agg_list_like(obj, arg, _axis)
670 # if we are empty
671 if not len(results):
--> 672 raise ValueError("no results")
673
674 try:

ValueError: no results

thanks for flagging this. looks like a bug. will send out a PR soon on this.

Hi,

I am getting this same error when I try to use any function except census_ln. I'm using a virtual environment with python 3.6 and ethnicolr 0.8.1.
Also, when using census_ln on my dataset, there are many names that come up with NaN for the predictions - any suggestions on why this might be?

Thanks

@eleanor-lee please review the requirements at: https://pypi.org/project/ethnicolr/
ethnicolr 0.8.1 is compatible with python 3.7 or 3.8 and not 3.6. Let us know if you are still encountering issues after making the fix.

@eleanor-lee please review the requirements at: https://pypi.org/project/ethnicolr/ ethnicolr 0.8.1 is compatible with python 3.7 or 3.8 and not 3.6. Let us know if you are still encountering issues after making the fix.

Hi, the documentation states it works on Python 3.7, 3.8 and lower - I have also tried with 3.7 and 3.8 and the wiki_ln and pred_census_ln functions do now work but only on a set of three names. When I test it on my dataset (>100,000 names) the code will not run. I'm using a Jupyter notebook for this, and I have tried running it for >10 minutes but it will not execute. Thanks

@eleanor-lee please review the requirements at: https://pypi.org/project/ethnicolr/ ethnicolr 0.8.1 is compatible with python 3.7 or 3.8 and not 3.6. Let us know if you are still encountering issues after making the fix.

Hi, the documentation states it works on Python 3.7, 3.8 and lower - I have also tried with 3.7 and 3.8 and the wiki_ln and pred_census_ln functions do now work but only on a set of three names. When I test it on my dataset (>100,000 names) the code will not run. I'm using a Jupyter notebook for this, and I have tried running it for >10 minutes but it will not execute. Thanks

I will fix the "lower" part and remove it, it should be 3.7 & 3.8.... can you provide your dataset on a public drive that I can access to replicate your issue?

@eleanor-lee please review the requirements at: https://pypi.org/project/ethnicolr/ ethnicolr 0.8.1 is compatible with python 3.7 or 3.8 and not 3.6. Let us know if you are still encountering issues after making the fix.

Hi, the documentation states it works on Python 3.7, 3.8 and lower - I have also tried with 3.7 and 3.8 and the wiki_ln and pred_census_ln functions do now work but only on a set of three names. When I test it on my dataset (>100,000 names) the code will not run. I'm using a Jupyter notebook for this, and I have tried running it for >10 minutes but it will not execute. Thanks

I will fix the "lower" part and remove it, it should be 3.7 & 3.8.... can you provide your dataset on a public drive that I can access to replicate your issue?

Hi, here is the link: https://docs.google.com/spreadsheets/d/1nRap2RnEmSRUDZbAbYiDWctEK0Njrcg_/edit?usp=sharing&ouid=102925104722352792124&rtpof=true&sd=true. Thank you!

Everything works for me so the issue is with your virtual environment.

I did this:
conda create -n deleteme python=3.7
conda activate deleteme
conda install notebook
pip install ethnicolr
after installation was complete and launched a notebook:

import pandas as pd
from ethnicolr import census_ln, pred_census_ln

df = pd.read_csv('countries.csv')
df = pred_census_ln(df, 'Surname')

I attached a sample output
Screen Shot 2022-04-22 at 6 28 02 PM

Everything works for me so the issue is with your virtual environment.

I did this: conda create -n deleteme python=3.7 conda activate deleteme conda install notebook pip install ethnicolr after installation was complete and launched a notebook:

import pandas as pd from ethnicolr import census_ln, pred_census_ln

df = pd.read_csv('countries.csv') df = pred_census_ln(df, 'Surname')

I attached a sample output Screen Shot 2022-04-22 at 6 28 02 PM

Thank you very much for checking. I have tried it on both my laptops following those same steps and it's still not running for me. I think it might be an issue with tensorflow as when trying to run the anaconda prompt shows this message '2022-04-25 09:26:35.847416: W tensorflow/core/framework/cpu_allocator_impl.cc:80] Allocation of 1029939200 exceeds 10% of free system memory.'