Files
2023-03-15 14:31:15 +01:00

150 KiB

In [1]:
import dimcli
from dimcli.utils import *

import sys, json, time
import pandas as pd
import numpy as np
from tqdm import tqdm

from tqdm.notebook import tqdm as progressbar

pd.set_option('display.max_columns', None)
In [2]:
import warnings
warnings.filterwarnings("ignore")
In [3]:
dsl = dimcli.login(verbose=False)
Searching config file credentials for default 'live' instance..
In [4]:
dsl = dimcli.Dsl()
In [5]:
GRIDID = "grid.17063.33"
In [6]:
df_startups = pd.read_csv(r"H:\\temp Uni\\baseline\\toronto_startups_full.csv")
df_pubs = pd.read_csv("toronto_papers.csv")
df_pubs_authors = pd.read_csv("toronto_authors.csv")
df_pubs_authors_aff = pd.read_csv("toronto_authors_affiliations.csv")
df_pats = pd.read_csv("toronto_patents.csv")
df_grants = pd.read_csv("toronto_grants.csv")
In [7]:
df_pubs['times_cited'] = df_pubs['times_cited'].fillna(0)
df_pats['times_cited'] = df_pats['times_cited'].fillna(0)

df_startups["founded_year"] = pd.DatetimeIndex(df_startups["founded_on"]).year.astype('Int64')

df_startups['founded_year'] = df_startups['founded_year'].fillna(0)

df_pubs_authors["full_name"] = df_pubs_authors["first_name"] + " "+  df_pubs_authors["last_name"]
df_pubs_authors_aff["full_name"] = df_pubs_authors_aff["first_name"] + " "+  df_pubs_authors_aff["last_name"]

all_authors = list(set(df_pubs["author_people"].tolist() +  df_pats["author_people"].tolist()))

df_pubs["category_for"]= df_pubs["category_for"].replace({'\'': '"'}, regex=True)
df_pats["category_for"]= df_pats["category_for"].replace({'\'': '"'}, regex=True)
df_grants["category_for"]= df_grants["category_for"].replace({'\'': '"'}, regex=True)

df_pubs["research_area"] = df_pubs["category_for"].apply(lambda x: 'n.a.' if pd.isnull(x) else json.loads(x)[0]["name"])
df_pats["research_area"] = df_pats["category_for"].apply(lambda x: 'n.a.' if pd.isnull(x) else json.loads(x)[0]["name"])
df_grants["research_area"] = df_grants["category_for"].apply(lambda x: 'n.a.' if pd.isnull(x) else json.loads(x)[0]["name"])
In [ ]:
#df_pubs[df_pubs["author_people"] == "Eran Segal"].groupby("year")["year"].count().reset_index(name="count").sort_values(["count"],ascending=False)
In [ ]:
df_pubs_authors_aff[df_pubs_authors_aff["full_name"] == "Tomer Aharon"].groupby(["aff_id","aff_name","aff_country"])["aff_id"].count().reset_index(name="count").sort_values(["count"],ascending=False)
In [ ]:
pubs_ids = df_pubs_authors_aff[df_pubs_authors_aff["full_name"] == "Eran Segal"]["pub_id"].unique().tolist()
countries = df_pubs_authors_aff[df_pubs_authors_aff["full_name"] == "Eran Segal"]["aff_country"].unique().tolist()
collab_institutes = df_pubs_authors_aff[df_pubs_authors_aff["pub_id"].isin(pubs_ids) & ~(df_pubs_authors_aff["full_name"] == "Eran Segal")].groupby(["aff_id","aff_name","aff_country"])["aff_id"].count().reset_index(name="count").sort_values(["count"],ascending=False) #collab institutes
collab_institutes["count"].sum() #number of collab partners
In [8]:
def generate_history(grouped_df, field, founded_year, history_type):
    year_history = dict()
    ground_value = 0
    ground_year_string = "FN"
    # if founded_year == 0:
    #     return   
    for i in range(20):
        data = dict()
        positiv = founded_year + (i+1)
        literal = ground_year_string + "+"+ str(i+1)
        df_positiv = grouped_df[grouped_df[field] == positiv]
        key = "hist_{0}_{1}".format(history_type,literal)
        if df_positiv.shape[0] > 0:
            val = df_positiv["count"].values[0]
            data[key] = int(val)
            year_history.update(data) 
        else:
            data[key] = int(ground_value)
            year_history.update(data) 
        
    
    for i in range(20):
        data = dict()    
        negative = founded_year - (i+1)
        literal = ground_year_string + "-" + str(i+1)
        df_negative = grouped_df[grouped_df[field] == negative]
        key = "hist_{0}_{1}".format(history_type,literal)
        if df_negative.shape[0] > 0:
            val = df_negative["count"].values[0]
            data[key] = int(val)
            year_history.update(data) 
        else:
            data[key] = int(ground_value)
            year_history.update(data) 
            
    df_ground = grouped_df[grouped_df[field] == founded_year]
    key = "hist_{0}_{1}".format(history_type,ground_year_string)
    data = dict() 
    if df_ground.shape[0] > 0:
        val = df_ground["count"].values[0]
        data[key] = int(val)
        year_history.update(data)
    else:           
        data[key] = int(ground_value)
        year_history.update(data) 
    #year_history = dict(sorted(year_history.items())) 
    return year_history    
In [9]:
def the_H_function(sorted_citations_list, n=1):
    if sorted_citations_list and sorted_citations_list[0] >= n:
        return the_H_function(sorted_citations_list[1:], n+1)
    else:
        return n-1 
    
    
def the_i_10_function(sorted_citations_list):
    count = sum(map(lambda x : x>=10, sorted_citations_list))
    return count


def get_researcher_info(researcher_ids):
    #check if ids exist, if not use the info with names
    # if ids exist get the info plus affiliations using ids
    ids = json.dumps(researcher_ids)
    researchers = dsl.query_iterative(f"""search researchers
                                    where id in {ids}
                                    return researchers[first_name+last_name+first_publication_year+last_publication_year+research_orgs+total_grants+total_publications+id+last_grant_year+first_grant_year]""", show_results=False, pause=3)
    return researchers.as_dataframe()


def get_startup_info(startup_df, author):
    name = list(startup_df[startup_df["name"] == author]["name"])[0]
    company = list(startup_df[startup_df["name"] == author]["featured_job_organization_name"])[0]
    founded_date = list(startup_df[startup_df["name"] == author]["founded_year"])[0]
    company_details = list(startup_df[startup_df["name"] == author]["category_list"])[0]
    if pd.isna(company_details):
        company_details = list(startup_df[startup_df["name"] == author]["short_description"])[0]
    startup_info = {
        "name": name,
        "company": company,
        "company_details": company_details,
        "founded_on":  founded_date,
    }
    return startup_info    

def get_affiliation_info(affiliation_df, author):
    total_affiliations = 0
    affiliations = affiliation_df[affiliation_df["full_name"] == author].groupby(["aff_id","aff_name","aff_country"])["aff_id"].count().reset_index(name="count").sort_values(["count"],ascending=False)
    if affiliations.shape[0] > 0:
        total_affiliations = affiliations.shape[0]
    affiliation_info = {
        "affiliations": total_affiliations
    }
    return affiliation_info   
        

def get_grants_info(grants_df, author, founded_year):
    first_grant_year = 0
    last_grant_year = 0
    number_grants = 0
    grant_research_area = None

    number_grants = grants_df[grants_df["author_people"] == author].shape[0]
    
    grant_by_year = grants_df[grants_df["author_people"] == author].groupby("start_year")["start_year"].count().reset_index(name="count").sort_values(["start_year"],ascending=True)        
    if grant_by_year.shape[0] > 0:
        first_grant_year = int(grant_by_year.iloc[0:]["start_year"].values[0])
        last_grant_year = int(grant_by_year.iloc[-1:]["start_year"].values[0])
    history_obj = generate_history(grant_by_year,"start_year",founded_year,"grant")    
    
    
    research_areas = list(grants_df[grants_df["author_people"] == author]["research_area"])
    if len(research_areas) > 0:
        grant_research_area = research_areas[0]   
    
    grant_info = {
        "first_grant_year": first_grant_year,
        "last_grant_year": last_grant_year,
        "grant_research_area": grant_research_area,
        "grants": number_grants
    }
    grant_info.update(history_obj)
    return grant_info

def get_publications_info(publications_df, author, founded_year):
    pub_citation_mean = 0
    pub_citation_sum = 0
    first_publication_year = 0
    last_publication_year = 0
    number_pubs = 0
    research_area = None
    
    citations_list = list(publications_df[publications_df["author_people"] == author]["times_cited"])
    citations_list.sort(reverse=True)
    h_index = the_H_function(citations_list)
    i10_index = the_i_10_function(citations_list)
    number_pubs = publications_df[publications_df["author_people"] == author].shape[0]
    
    if number_pubs > 0:
        pub_citation_mean = np.round(publications_df[publications_df["author_people"] == author]["times_cited"].mean(),2)
        pub_citation_sum = sum(citations_list)        
        
    pubs_by_year = publications_df[publications_df["author_people"] == author].groupby("year")["year"].count().reset_index(name="count").sort_values(["year"],ascending=True)        
    if pubs_by_year.shape[0] > 0:
        first_publication_year = int(pubs_by_year.iloc[0:]["year"].values[0])
        last_publication_year = int(pubs_by_year.iloc[-1:]["year"].values[0])
    history_obj = generate_history(pubs_by_year,"year",founded_year,"pub")    
    
    research_areas = list(publications_df[publications_df["author_people"] == author]["research_area"])
    if len(research_areas) > 0:
        research_area = research_areas[0]
        
    BATCHSIZE = 500
    VERBOSE = False
    patents_json = []

    q = """search patents
        where publication_ids in {}
        return patents[basics+publication_ids+category_for]"""

    pub_ids_list = list(df_pubs[df_pubs["author_people"] == author]["id"])

    try: 
        for chunk in list(chunks_of(pub_ids_list, BATCHSIZE)):
            data = dsl.query_iterative(q.format(json.dumps(chunk)), verbose=VERBOSE)
            patents_json += data.patents
            time.sleep(2)

        patents = pd.DataFrame().from_dict(patents_json)
        patents.drop_duplicates(subset='id', inplace=True)
        linked_patents_to_publications = len(patents)
        # print("Patents found: ", len(patents)) 
    except Exception as e:
        print("failed on", author)
        linked_patents_to_publications = -1      
    
    publication_info = {
        "h-index": h_index,
        "i10-index": i10_index,
        "publications": number_pubs,
        "pub_citation_mean": pub_citation_mean,
        "pub_citation_sum": pub_citation_sum,
        "first_publication_year": first_publication_year,
        "last_publication_year": last_publication_year,
        "publication_research_area": research_area,
        "linked_patents_to_publications": linked_patents_to_publications
    }
    publication_info.update(history_obj)
    return publication_info

def get_patent_info(patents_df, author, founded_year):
    pat_citation_mean = 0
    pat_citation_sum = 0
    first_patent_year = 0
    last_patent_year = 0
    number_pats = 0
    patent_research_area = None
    
    citations_list_pats = list(patents_df[patents_df["author_people"] == author]["times_cited"])
    number_pats = patents_df[patents_df["author_people"] == author].shape[0]
    
    if number_pats > 0:
        pat_citation_mean = np.round(patents_df[patents_df["author_people"] == author]["times_cited"].mean(),2) 
        pat_citation_sum = sum(citations_list_pats)    
        
    pats_by_year = patents_df[patents_df["author_people"] == author].groupby("year")["year"].count().reset_index(name="count").sort_values(["year"],ascending=True)        
    if pats_by_year.shape[0] > 0:
        first_patent_year = int(pats_by_year.iloc[0:]["year"].values[0])
        last_patent_year = int(pats_by_year.iloc[-1:]["year"].values[0])
    history_obj = generate_history(pats_by_year,"year",founded_year,"pat")    
        
    patent_research_areas = list(patents_df[patents_df["author_people"] == author]["research_area"])
    if len(patent_research_areas) > 0:
        patent_research_area = patent_research_areas[0]      
    
    patent_info = {
        "patents": number_pats,
        "pat_citation_mean": pat_citation_mean,
        "pat_citation_sum": pat_citation_sum,
        "first_patent_year": first_patent_year,
        "last_patent_year": last_patent_year,
        "patent_research_area": patent_research_area
    }
    patent_info.update(history_obj)
    return patent_info
In [ ]:
# BATCHSIZE = 400
# VERBOSE = False
# patents_json = []

# q = """search patents
# where publication_ids in {}
# return patents[basics+publication_ids+category_for]"""

# pub_ids_list = list(df_pubs[df_pubs["author_people"] == "Aviv Madar"]["id"])

# for chunk in progressbar(list(chunks_of(pub_ids_list, 400))):
#     data = dsl.query_iterative(q.format(json.dumps(chunk)), verbose=VERBOSE)
#     patents_json += data.patents
#     time.sleep(3)

# patents = pd.DataFrame().from_dict(patents_json)
# patents.drop_duplicates(subset='id', inplace=True)
# referenced_pubs_in_patents = len(patents)
In [ ]:
# def count_patents_per_pub(pubid):
#   global patents
#   return len(patents[patents['publication_ids'].str.contains(pubid)])

# # turn lists into strings to ensure compatibility with CSV loaded data
# # see also: https://stackoverflow.com/questions/23111990/pandas-dataframe-stored-list-as-string-how-to-convert-back-to-list
# patents['publication_ids'] = patents['publication_ids'].apply(lambda x: ','.join(map(str, x)))

# #progressbar.pandas()
# #pubs['patents'] = pubs['id'].progress_apply(lambda x: count_patents_per_pub(x))
In [10]:
# columns= ["name","company","founded_on", "company_details","h-index","i10-index","publications", "patents", "pub_citation_mean", "pat_citation_mean", "pub_citation_sum", "pat_citation_sum",
#           "first_publication_year", "first_grant_year", "first_patent_year", "last_publication_year", "last_grant_year", "last_patent_year", "affiliations", "research_area"]
features_df = pd.DataFrame()
for author in tqdm(all_authors):
    row = dict()
    startup_info = get_startup_info(df_startups, author)
    founded_year = startup_info["founded_on"]
    publication_info = get_publications_info(df_pubs, author, founded_year)
    patent_info = get_patent_info(df_pats, author, founded_year)
    grant_info = get_grants_info(df_grants, author, founded_year)
    affiliation_info = get_affiliation_info(df_pubs_authors_aff, author)
    
    row.update(startup_info)
    row.update(publication_info)
    row.update(patent_info)
    row.update(grant_info)
    row.update(affiliation_info)
    features_df = features_df.append(row, ignore_index=True)
    
    
    # df_temp = df_pubs_authors[df_pubs_authors["full_name"]== author].copy()
    # if df_temp.shape[0] > 0:
    #     df_temp = df_temp.dropna(subset=["researcher_id"]) 
    #     df_temp.drop_duplicates('researcher_id', inplace=True)
    #     researcher_ids = df_temp["researcher_id"].unique().tolist()
100%|██████████| 440/440 [40:34<00:00,  5.53s/it]  
In [13]:
features_df["founded_on"] = features_df["founded_on"].astype(int)
features_df["first_publication_year"] = features_df["first_publication_year"].astype(int)
features_df["last_publication_year"] = features_df["last_publication_year"].astype(int)
features_df["first_patent_year"] = features_df["first_patent_year"].astype(int)
features_df["last_patent_year"] = features_df["last_patent_year"].astype(int)
features_df["publications"] = features_df["publications"].astype(int)
features_df["patents"] = features_df["patents"].astype(int)
features_df["affiliations"] = features_df["affiliations"].astype(int)
features_df["grants"] = features_df["grants"].astype(int)
features_df["first_grant_year"] = features_df["first_grant_year"].astype(int)
features_df["last_grant_year"] = features_df["last_grant_year"].astype(int)
features_df["linked_patents_to_publications"] = features_df["linked_patents_to_publications"].astype(int)

cols = [col for col in features_df if col.startswith('hist_')]
features_df[cols] = features_df[cols].astype(int)
In [12]:
features_df["Company_founded"] = 1
In [14]:
features_df
Out [14]:
name company company_details founded_on h-index i10-index publications pub_citation_mean pub_citation_sum first_publication_year last_publication_year publication_research_area linked_patents_to_publications hist_pub_FN+1 hist_pub_FN+2 hist_pub_FN+3 hist_pub_FN+4 hist_pub_FN+5 hist_pub_FN+6 hist_pub_FN+7 hist_pub_FN+8 hist_pub_FN+9 hist_pub_FN+10 hist_pub_FN+11 hist_pub_FN+12 hist_pub_FN+13 hist_pub_FN+14 hist_pub_FN+15 hist_pub_FN+16 hist_pub_FN+17 hist_pub_FN+18 hist_pub_FN+19 hist_pub_FN+20 hist_pub_FN-1 hist_pub_FN-2 hist_pub_FN-3 hist_pub_FN-4 hist_pub_FN-5 hist_pub_FN-6 hist_pub_FN-7 hist_pub_FN-8 hist_pub_FN-9 hist_pub_FN-10 hist_pub_FN-11 hist_pub_FN-12 hist_pub_FN-13 hist_pub_FN-14 hist_pub_FN-15 hist_pub_FN-16 hist_pub_FN-17 hist_pub_FN-18 hist_pub_FN-19 hist_pub_FN-20 hist_pub_FN patents pat_citation_mean pat_citation_sum first_patent_year last_patent_year patent_research_area hist_pat_FN+1 hist_pat_FN+2 hist_pat_FN+3 hist_pat_FN+4 hist_pat_FN+5 hist_pat_FN+6 hist_pat_FN+7 hist_pat_FN+8 hist_pat_FN+9 hist_pat_FN+10 hist_pat_FN+11 hist_pat_FN+12 hist_pat_FN+13 hist_pat_FN+14 hist_pat_FN+15 hist_pat_FN+16 hist_pat_FN+17 hist_pat_FN+18 hist_pat_FN+19 hist_pat_FN+20 hist_pat_FN-1 hist_pat_FN-2 hist_pat_FN-3 hist_pat_FN-4 hist_pat_FN-5 hist_pat_FN-6 hist_pat_FN-7 hist_pat_FN-8 hist_pat_FN-9 hist_pat_FN-10 hist_pat_FN-11 hist_pat_FN-12 hist_pat_FN-13 hist_pat_FN-14 hist_pat_FN-15 hist_pat_FN-16 hist_pat_FN-17 hist_pat_FN-18 hist_pat_FN-19 hist_pat_FN-20 hist_pat_FN first_grant_year last_grant_year grant_research_area grants hist_grant_FN+1 hist_grant_FN+2 hist_grant_FN+3 hist_grant_FN+4 hist_grant_FN+5 hist_grant_FN+6 hist_grant_FN+7 hist_grant_FN+8 hist_grant_FN+9 hist_grant_FN+10 hist_grant_FN+11 hist_grant_FN+12 hist_grant_FN+13 hist_grant_FN+14 hist_grant_FN+15 hist_grant_FN+16 hist_grant_FN+17 hist_grant_FN+18 hist_grant_FN+19 hist_grant_FN+20 hist_grant_FN-1 hist_grant_FN-2 hist_grant_FN-3 hist_grant_FN-4 hist_grant_FN-5 hist_grant_FN-6 hist_grant_FN-7 hist_grant_FN-8 hist_grant_FN-9 hist_grant_FN-10 hist_grant_FN-11 hist_grant_FN-12 hist_grant_FN-13 hist_grant_FN-14 hist_grant_FN-15 hist_grant_FN-16 hist_grant_FN-17 hist_grant_FN-18 hist_grant_FN-19 hist_grant_FN-20 hist_grant_FN affiliations Company_founded
0 Alex Zivkovic Breaking Data Corp Apps,Information Services,Information Technolo... 2004 0 0 1 0.00 0 2022 2022 3604 Performing Arts 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0.50 1 2018 2018 40 Engineering 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 None 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 Alex Sebastian Orchard Consumer,E-Commerce,Mobile Apps 2013 1 0 1 5.00 5 2012 2012 38 Economics 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00 0 0 0 None 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 None 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
2 Elize Shirdel HELM App B2B,Computer,Software 2017 5 4 6 56.67 340 2011 2017 31 Biological Sciences 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0.00 0 0 0 None 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2007 2007 31 Biological Sciences 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1
3 Spyro Mousses Systems Oncology Biotechnology,Health Care,Information Technology 2015 27 44 95 42.38 4026 1999 2022 32 Biomedical and Clinical Sciences 111 1 0 1 2 1 1 3 0 0 0 0 0 0 0 0 0 0 0 0 0 4 2 2 8 10 14 5 9 3 4 3 9 4 7 0 2 0 0 0 0 0 61 5.08 310 2001 2022 n.a. 0 10 3 12 0 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2 0 0 1 1 3 0 10 0 0 3 3 0 0 0 0 0 0 5 2003 2013 31 Biological Sciences 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 1 0 0 0 1 0 3 0 0 0 0 0 0 0 0 0 19 1
4 Ian Robertson Algonquin Power & Utilities Corp. Energy 1997 91 516 1097 31.17 34193 1904 2022 5202 Biological Psychology 271 14 14 15 16 19 14 21 33 43 22 42 37 36 51 45 43 35 52 49 41 22 22 19 10 14 10 6 7 2 6 11 5 13 5 2 3 5 6 2 6 10 299 4.03 1206 1969 2022 n.a. 0 0 2 30 4 4 8 35 23 64 3 15 5 28 6 14 10 4 2 3 0 2 0 0 7 0 0 1 4 4 0 0 0 0 0 1 0 0 0 0 0 1993 2021 33 Built Environment and Design 32 1 0 0 0 0 3 4 4 1 0 1 3 0 2 0 1 2 0 2 1 2 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 60 1
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
435 David Wenner Local Hits Media Mobile,Public Relations,Reputation,Small and M... 2008 13 14 25 37.28 932 1971 2021 32 Biomedical and Clinical Sciences 0 0 1 0 0 0 0 0 0 0 1 2 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0.00 0 0 0 None 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1974 1992 37 Earth Sciences 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 2 1
436 Umar Ahmed Treasured Software 2021 9 8 69 4.88 337 2005 2022 32 Biomedical and Clinical Sciences 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 6 9 7 1 4 2 0 3 1 0 0 0 0 0 1 0 0 0 0 16 9 0.11 1 2017 2022 33 Built Environment and Design 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2018 2021 47 Language, Communication and Culture 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 7 1
437 Kenneth Mo Silk & Snow E-Commerce,Furniture,Retail,Shopping 2017 1 0 4 0.50 2 2021 2022 46 Information and Computing Sciences 0 0 0 0 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 0.73 8 1953 2011 n.a. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 None 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
438 Cameron Stewart Mesosil Advanced Materials,Health Care,Medical Device 2016 40 111 336 26.92 9045 1954 2022 4206 Public Health 67 21 14 11 34 40 37 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 19 13 11 10 7 6 8 6 10 4 8 6 4 5 2 0 1 1 15 31 0.65 20 2001 2022 32 Biomedical and Clinical Sciences 9 1 0 0 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 8 1991 2021 49 Mathematical Sciences 45 1 3 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 2 3 2 1 1 2 3 3 1 1 2 3 1 0 0 1 0 0 0 3 17 1
439 Chris Doan Game Hive Android,Apps,Gaming,iOS,Mobile Apps,Video Games 2009 0 0 1 0.00 0 2022 2022 4605 Data Management and Data Science 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00 0 0 0 None 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 None 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1

440 rows × 148 columns

In [15]:
features_df[features_df["linked_patents_to_publications"]==-1]
Out [15]:
name company company_details founded_on h-index i10-index publications pub_citation_mean pub_citation_sum first_publication_year last_publication_year publication_research_area linked_patents_to_publications hist_pub_FN+1 hist_pub_FN+2 hist_pub_FN+3 hist_pub_FN+4 hist_pub_FN+5 hist_pub_FN+6 hist_pub_FN+7 hist_pub_FN+8 hist_pub_FN+9 hist_pub_FN+10 hist_pub_FN+11 hist_pub_FN+12 hist_pub_FN+13 hist_pub_FN+14 hist_pub_FN+15 hist_pub_FN+16 hist_pub_FN+17 hist_pub_FN+18 hist_pub_FN+19 hist_pub_FN+20 hist_pub_FN-1 hist_pub_FN-2 hist_pub_FN-3 hist_pub_FN-4 hist_pub_FN-5 hist_pub_FN-6 hist_pub_FN-7 hist_pub_FN-8 hist_pub_FN-9 hist_pub_FN-10 hist_pub_FN-11 hist_pub_FN-12 hist_pub_FN-13 hist_pub_FN-14 hist_pub_FN-15 hist_pub_FN-16 hist_pub_FN-17 hist_pub_FN-18 hist_pub_FN-19 hist_pub_FN-20 hist_pub_FN patents pat_citation_mean pat_citation_sum first_patent_year last_patent_year patent_research_area hist_pat_FN+1 hist_pat_FN+2 hist_pat_FN+3 hist_pat_FN+4 hist_pat_FN+5 hist_pat_FN+6 hist_pat_FN+7 hist_pat_FN+8 hist_pat_FN+9 hist_pat_FN+10 hist_pat_FN+11 hist_pat_FN+12 hist_pat_FN+13 hist_pat_FN+14 hist_pat_FN+15 hist_pat_FN+16 hist_pat_FN+17 hist_pat_FN+18 hist_pat_FN+19 hist_pat_FN+20 hist_pat_FN-1 hist_pat_FN-2 hist_pat_FN-3 hist_pat_FN-4 hist_pat_FN-5 hist_pat_FN-6 hist_pat_FN-7 hist_pat_FN-8 hist_pat_FN-9 hist_pat_FN-10 hist_pat_FN-11 hist_pat_FN-12 hist_pat_FN-13 hist_pat_FN-14 hist_pat_FN-15 hist_pat_FN-16 hist_pat_FN-17 hist_pat_FN-18 hist_pat_FN-19 hist_pat_FN-20 hist_pat_FN first_grant_year last_grant_year grant_research_area grants hist_grant_FN+1 hist_grant_FN+2 hist_grant_FN+3 hist_grant_FN+4 hist_grant_FN+5 hist_grant_FN+6 hist_grant_FN+7 hist_grant_FN+8 hist_grant_FN+9 hist_grant_FN+10 hist_grant_FN+11 hist_grant_FN+12 hist_grant_FN+13 hist_grant_FN+14 hist_grant_FN+15 hist_grant_FN+16 hist_grant_FN+17 hist_grant_FN+18 hist_grant_FN+19 hist_grant_FN+20 hist_grant_FN-1 hist_grant_FN-2 hist_grant_FN-3 hist_grant_FN-4 hist_grant_FN-5 hist_grant_FN-6 hist_grant_FN-7 hist_grant_FN-8 hist_grant_FN-9 hist_grant_FN-10 hist_grant_FN-11 hist_grant_FN-12 hist_grant_FN-13 hist_grant_FN-14 hist_grant_FN-15 hist_grant_FN-16 hist_grant_FN-17 hist_grant_FN-18 hist_grant_FN-19 hist_grant_FN-20 hist_grant_FN affiliations Company_founded
In [16]:
BATCHSIZE = 500
VERBOSE = True
patents_json = []

q = """search patents
    where publication_ids in {}
    return patents[basics+publication_ids+category_for]"""

pub_ids_list = list(df_pubs[df_pubs["author_people"] == "Eirini Psallida"]["id"])

for chunk in list(chunks_of(pub_ids_list, BATCHSIZE)):
    data = dsl.query_iterative(q.format(json.dumps(chunk)), verbose=VERBOSE)
    patents_json += data.patents
    time.sleep(5)

patents = pd.DataFrame().from_dict(patents_json)
patents.drop_duplicates(subset='id', inplace=True)
linked_patents_to_publications = len(patents)
Starting iteration with limit=1000 skip=0 ...
===
Records extracted: 0
In [21]:
linked_patents_to_publications
Out [21]:
0
In [23]:
features_df.loc[features_df["name"]=="Eirini Psallida", ["linked_patents_to_publications"]] = linked_patents_to_publications
In [24]:
features_df[features_df["name"]=="Eirini Psallida"]
Out [24]:
name company company_details founded_on h-index i10-index publications pub_citation_mean pub_citation_sum first_publication_year last_publication_year publication_research_area linked_patents_to_publications hist_pub_FN+1 hist_pub_FN+2 hist_pub_FN+3 hist_pub_FN+4 hist_pub_FN+5 hist_pub_FN+6 hist_pub_FN+7 hist_pub_FN+8 hist_pub_FN+9 hist_pub_FN+10 hist_pub_FN+11 hist_pub_FN+12 hist_pub_FN+13 hist_pub_FN+14 hist_pub_FN+15 hist_pub_FN+16 hist_pub_FN+17 hist_pub_FN+18 hist_pub_FN+19 hist_pub_FN+20 hist_pub_FN-1 hist_pub_FN-2 hist_pub_FN-3 hist_pub_FN-4 hist_pub_FN-5 hist_pub_FN-6 hist_pub_FN-7 hist_pub_FN-8 hist_pub_FN-9 hist_pub_FN-10 hist_pub_FN-11 hist_pub_FN-12 hist_pub_FN-13 hist_pub_FN-14 hist_pub_FN-15 hist_pub_FN-16 hist_pub_FN-17 hist_pub_FN-18 hist_pub_FN-19 hist_pub_FN-20 hist_pub_FN patents pat_citation_mean pat_citation_sum first_patent_year last_patent_year patent_research_area hist_pat_FN+1 hist_pat_FN+2 hist_pat_FN+3 hist_pat_FN+4 hist_pat_FN+5 hist_pat_FN+6 hist_pat_FN+7 hist_pat_FN+8 hist_pat_FN+9 hist_pat_FN+10 hist_pat_FN+11 hist_pat_FN+12 hist_pat_FN+13 hist_pat_FN+14 hist_pat_FN+15 hist_pat_FN+16 hist_pat_FN+17 hist_pat_FN+18 hist_pat_FN+19 hist_pat_FN+20 hist_pat_FN-1 hist_pat_FN-2 hist_pat_FN-3 hist_pat_FN-4 hist_pat_FN-5 hist_pat_FN-6 hist_pat_FN-7 hist_pat_FN-8 hist_pat_FN-9 hist_pat_FN-10 hist_pat_FN-11 hist_pat_FN-12 hist_pat_FN-13 hist_pat_FN-14 hist_pat_FN-15 hist_pat_FN-16 hist_pat_FN-17 hist_pat_FN-18 hist_pat_FN-19 hist_pat_FN-20 hist_pat_FN first_grant_year last_grant_year grant_research_area grants hist_grant_FN+1 hist_grant_FN+2 hist_grant_FN+3 hist_grant_FN+4 hist_grant_FN+5 hist_grant_FN+6 hist_grant_FN+7 hist_grant_FN+8 hist_grant_FN+9 hist_grant_FN+10 hist_grant_FN+11 hist_grant_FN+12 hist_grant_FN+13 hist_grant_FN+14 hist_grant_FN+15 hist_grant_FN+16 hist_grant_FN+17 hist_grant_FN+18 hist_grant_FN+19 hist_grant_FN+20 hist_grant_FN-1 hist_grant_FN-2 hist_grant_FN-3 hist_grant_FN-4 hist_grant_FN-5 hist_grant_FN-6 hist_grant_FN-7 hist_grant_FN-8 hist_grant_FN-9 hist_grant_FN-10 hist_grant_FN-11 hist_grant_FN-12 hist_grant_FN-13 hist_grant_FN-14 hist_grant_FN-15 hist_grant_FN-16 hist_grant_FN-17 hist_grant_FN-18 hist_grant_FN-19 hist_grant_FN-20 hist_grant_FN affiliations Company_founded
8 Eirini Psallida KEWAZO Analytics,Construction,Robotics 2018 2 2 4 15.5 62 2007 2018 46 Information and Computing Sciences 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 2 4 1.0 4 2017 2018 33 Built Environment and Design 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 None 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1
In [16]:
features_df.to_csv("toronto_features_dataset.csv", index=False)
In [ ]:
#CATEGORY = "None"  #@param ['None', '0101 Pure Mathematics', '0102 Applied Mathematics', '0103 Numerical and Computational Mathematics', '0104 Statistics', '0105 Mathematical Physics', 
# '0201 Astronomical and Space Sciences', '0202 Atomic, Molecular, Nuclear, Particle and Plasma Physics', '0203 Classical Physics', '0204 Condensed Matter Physics', '0205 Optical Physics', 
# '0206 Quantum Physics', '0299 Other Physical Sciences', '0301 Analytical Chemistry', '0302 Inorganic Chemistry', '0303 Macromolecular and Materials Chemistry', '0304 Medicinal and Biomolecular Chemistry', 
# '0305 Organic Chemistry', '0306 Physical Chemistry (incl. Structural)', '0307 Theoretical and Computational Chemistry', '0399 Other Chemical Sciences', '0401 Atmospheric Sciences', '0402 Geochemistry', '0403 Geology', 
# '0404 Geophysics', '0405 Oceanography', '0406 Physical Geography and Environmental Geoscience', '0499 Other Earth Sciences', '0501 Ecological Applications', '0502 Environmental Science and Management', '0503 Soil Sciences', 
# '0599 Other Environmental Sciences', '0601 Biochemistry and Cell Biology', '0602 Ecology', '0603 Evolutionary Biology', '0604 Genetics', '0605 Microbiology', '0606 Physiology', '0607 Plant Biology', '0608 Zoology', 
# '0699 Other Biological Sciences', '0701 Agriculture, Land and Farm Management', '0702 Animal Production', '0703 Crop and Pasture Production', '0704 Fisheries Sciences', '0705 Forestry Sciences', '0706 Horticultural Production', 
# '0707 Veterinary Sciences', '0799 Other Agricultural and Veterinary Sciences', '0801 Artificial Intelligence and Image Processing', '0802 Computation Theory and Mathematics', '0803 Computer Software', '0804 Data Format', 
# '0805 Distributed Computing', '0806 Information Systems', '0807 Library and Information Studies', '0899 Other Information and Computing Sciences', '0901 Aerospace Engineering', '0902 Automotive Engineering', 
# '0903 Biomedical Engineering', '0904 Chemical Engineering', '0905 Civil Engineering', '0906 Electrical and Electronic Engineering', '0907 Environmental Engineering', '0908 Food Sciences', '0909 Geomatic Engineering', 
# '0910 Manufacturing Engineering', '0911 Maritime Engineering', '0912 Materials Engineering', '0913 Mechanical Engineering', '0914 Resources Engineering and Extractive Metallurgy', '0915 Interdisciplinary Engineering', 
# '0999 Other Engineering', '1001 Agricultural Biotechnology', '1002 Environmental Biotechnology', '1003 Industrial Biotechnology', '1004 Medical Biotechnology', '1005 Communications Technologies', '1006 Computer Hardware', 
# '1007 Nanotechnology', '1099 Other Technology', '1101 Medical Biochemistry and Metabolomics', '1102 Cardiorespiratory Medicine and Haematology', '1103 Clinical Sciences', '1104 Complementary and Alternative Medicine', 
# '1105 Dentistry', '1106 Human Movement and Sports Science', '1107 Immunology', '1108 Medical Microbiology', '1109 Neurosciences', '1110 Nursing', '1111 Nutrition and Dietetics', '1112 Oncology and Carcinogenesis', 
# '1113 Ophthalmology and Optometry', '1114 Paediatrics and Reproductive Medicine', '1115 Pharmacology and Pharmaceutical Sciences', '1116 Medical Physiology', '1117 Public Health and Health Services', 
# '1199 Other Medical and Health Sciences', '1201 Architecture', '1202 Building', '1203 Design Practice and Management', '1205 Urban and Regional Planning', '1299 Other Built Environment and Design', '1301 Education Systems', 
# '1302 Curriculum and Pedagogy', '1303 Specialist Studies In Education', '1399 Other Education', '1401 Economic Theory', '1402 Applied Economics', '1403 Econometrics', '1499 Other Economics', 
# '1501 Accounting, Auditing and Accountability', '1502 Banking, Finance and Investment', '1503 Business and Management', '1504 Commercial Services', '1505 Marketing', '1506 Tourism', 
# '1507 Transportation and Freight Services', '1601 Anthropology', '1602 Criminology', '1603 Demography', '1604 Human Geography', '1605 Policy and Administration', '1606 Political Science', '1607 Social Work', 
# '1608 Sociology', '1699 Other Studies In Human Society', '1701 Psychology', '1702 Cognitive Sciences', '1799 Other Psychology and Cognitive Sciences', '1801 Law', '1899 Other Law and Legal Studies', 
# '1901 Art Theory and Criticism', '1902 Film, Television and Digital Media', '1903 Journalism and Professional Writing', '1904 Performing Arts and Creative Writing', '1905 Visual Arts and Crafts', 
# '1999 Other Studies In Creative Arts and Writing', '2001 Communication and Media Studies', '2002 Cultural Studies', '2003 Language Studies', '2004 Linguistics', '2005 Literary Studies', 
# '2099 Other Language, Communication and Culture', '2101 Archaeology', '2102 Curatorial and Related Studies', '2103 Historical Studies', '2199 Other History and Archaeology', '2201 Applied Ethics', 
# '2202 History and Philosophy of Specific Fields', '2203 Philosophy', '2204 Religion and Religious Studies', '2299 Other Philosophy and Religious Studies']