<jupyter_start><jupyter_text>The aim of this is to be able to classify names as either being African in origin or not<jupyter_code>import pandas as pd
import ast
from ethnicolr import pred_wiki_ln, pred_wiki_name<jupyter_output>Using TensorFlow backend.<jupyter_text>Load puplications, get authors and how many publications of theirs we have<jupyter_code>from collections import Counter
data = pd.read_csv("bb_pulications.csv")
data['author'] = data['bib'].apply(lambda x: ast.literal_eval(x)['author'])
data['year'] = data['bib'].apply(lambda x: ast.literal_eval(x)['pub_year'])
data['title'] = data['bib'].apply(lambda x: ast.literal_eval(x)['title'])<jupyter_output><empty_output><jupyter_text>Clean author names a little bit<jupyter_code>def clean_author(x):
    """
    x list of authors for a publication
    """
    clean_list = []
    for item in x:
        clean_list.append(item.lower())
    return clean_list
data['author_cleaned'] = data['author'].apply(lambda x: clean_author(x))
authors = data['author_cleaned'].sum()
Counter(authors)<jupyter_output><empty_output><jupyter_text>Get surnames<jupyter_code># first have to searate from initials and then put back togetehr again
surnames = []
for name in authors:
    surname = name.split(' ')[1:]
    surname_str = ' '.join(surname) 
    surnames.append(surname_str)
Counter(surnames)<jupyter_output><empty_output><jupyter_text>Hokay, lets try this Classifier<jupyter_code>#drop duplicates
surnames = list(set(surnames))
df = pd.DataFrame(surnames, columns=["surnames"])
preds = pred_wiki_ln(df, "surnames")
preds
preds['race'].value_counts()
preds[preds['race'] == 'GreaterAfrican,Africans']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13071895424836602, 'fraction_numerical': 0.0005941770647653001, 'mean_word_length': 6.981042654028436, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '666985', 'license': 'Apache-2.0', 'n_tokens_mistral': 594, 'n_tokens_neox': 576, 'n_words': 129, 'path': 'working_ipynbs/name_classification.ipynb', 'repo_name': 'TamatiB/restitution_africa2021', 'size': '1683'}