Files
founding-potential/evaluation/feature_engineering.ipynb
2023-03-15 14:31:15 +01:00

103 KiB

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

import matplotlib.pyplot as plt

import plotly.express as px
from plotly.offline import plot

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

from tqdm.notebook import tqdm as progressbar

import warnings
warnings.filterwarnings("ignore")

pd.set_option('display.max_columns', None)
In [3]:
df_founders = pd.read_csv("harvard_features_dataset.csv")
df_nonfounders = pd.read_csv("harvard_nonfounders_features_dataset.csv")
In [4]:
pub_cols = [col for col in df_founders if col.startswith('hist_pub_FN-')]
df_founders['publications_before_founding']= df_founders[pub_cols].sum(axis=1)
df_nonfounders["publications_before_founding"] = 0
pat_cols = [col for col in df_founders if col.startswith('hist_pat_FN-')]
df_founders['patents_before_founding']= df_founders[pat_cols].sum(axis=1)
df_nonfounders["patents_before_founding"] = 0
grant_cols = [col for col in df_founders if col.startswith('hist_grant_FN-')]
df_founders['grants_before_founding']= df_founders[grant_cols].sum(axis=1)
df_nonfounders["grants_before_founding"] = 0


pub_cols = [col for col in df_founders if col.startswith('hist_pub_FN+')]
df_founders['publications_after_founding']= df_founders[pub_cols].sum(axis=1)
df_nonfounders["publications_after_founding"] = 0
pat_cols = [col for col in df_founders if col.startswith('hist_pat_FN+')]
df_founders['patents_after_founding']= df_founders[pat_cols].sum(axis=1)
df_nonfounders["patents_after_founding"] = 0
grant_cols = [col for col in df_founders if col.startswith('hist_grant_FN+')]
df_founders['grants_after_founding']= df_founders[grant_cols].sum(axis=1)
df_nonfounders["grants_after_founding"] = 0
In [5]:
df_founders["activities_total"] = df_founders[["publications","patents","grants"]].sum(axis=1)
df_nonfounders["activities_total"] = df_nonfounders[["publications","patents","grants"]].sum(axis=1)
In [6]:
df_founders["activities_before_founding"] = df_founders[["publications_before_founding", 
                                                        "patents_before_founding",
                                                        "grants_before_founding"]].sum(axis=1)
df_founders["activities_after_founding"] = df_founders[["publications_after_founding", 
                                                        "patents_after_founding",
                                                        "grants_after_founding"]].sum(axis=1)
df_nonfounders["activities_before_founding"] = 0
df_nonfounders["activities_after_founding"] = 0
In [45]:
fig = px.scatter(df_founders, x="activities_after_founding", y="activities_before_founding", title=f"Corr Patents", trendline="ols")
fig.show()
# results = px.get_trendline_results(fig)
#print(results)
# results.px_fit_results.iloc[0].summary()
[Data output - unsupported data type map[string]interface {} for mime type application/vnd.plotly.v1+json]
In [56]:
df_nonfounders.head(2)
Out [56]:
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 publications_before_founding patents_before_founding grants_before_founding publications_after_founding activities_total activities_before_founding activities_after_founding
0 Meital Slakman NaN NaN 0 1.0 0.0 2 3.00 6.0 2018 2018 5202 Biological Psychology 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 0.00 0.0 0 0 NaN 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 NaN 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 0 0 0 0 0 2 0 0
1 Esther Segal NaN NaN 0 22.0 43.0 76 18.62 1415.0 1962 2022 3107 Microbiology 21 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 6 0.83 5.0 1995 2015 30 Agricultural, Veterinary and Food Sciences 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 NaN 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 0 0 0 0 0 82 0 0
In [8]:
df_founders.to_csv("harvard_features_dataset.csv", index= False)
df_nonfounders.to_csv("harvard_nonfounders_features_dataset.csv", index=False)
In [10]:
df_founders = pd.read_csv("berkeley_features_dataset.csv")
df_nonfounders = pd.read_csv("berkeley_nonfounders_features_dataset.csv")
In [13]:
pub_cols = [col for col in df_founders if col.startswith('hist_pub_FN-')]
df_founders['publications_before_founding']= df_founders[pub_cols].sum(axis=1)
df_nonfounders["publications_before_founding"] = 0
pat_cols = [col for col in df_founders if col.startswith('hist_pat_FN-')]
df_founders['patents_before_founding']= df_founders[pat_cols].sum(axis=1)
df_nonfounders["patents_before_founding"] = 0
grant_cols = [col for col in df_founders if col.startswith('hist_grant_FN-')]
df_founders['grants_before_founding']= df_founders[grant_cols].sum(axis=1)
df_nonfounders["grants_before_founding"] = 0


pub_cols = [col for col in df_founders if col.startswith('hist_pub_FN+')]
df_founders['publications_after_founding']= df_founders[pub_cols].sum(axis=1)
df_nonfounders["publications_after_founding"] = 0
pat_cols = [col for col in df_founders if col.startswith('hist_pat_FN+')]
df_founders['patents_after_founding']= df_founders[pat_cols].sum(axis=1)
df_nonfounders["patents_after_founding"] = 0
grant_cols = [col for col in df_founders if col.startswith('hist_grant_FN+')]
df_founders['grants_after_founding']= df_founders[grant_cols].sum(axis=1)
df_nonfounders["grants_after_founding"] = 0


df_founders["activities_total"] = df_founders[["publications","patents","grants"]].sum(axis=1)
df_nonfounders["activities_total"] = df_nonfounders[["publications","patents","grants"]].sum(axis=1)


df_founders["activities_before_founding"] = df_founders[["publications_before_founding", 
                                                        "patents_before_founding",
                                                        "grants_before_founding"]].sum(axis=1)
df_founders["activities_after_founding"] = df_founders[["publications_after_founding", 
                                                        "patents_after_founding",
                                                        "grants_after_founding"]].sum(axis=1)
df_nonfounders["activities_before_founding"] = 0
df_nonfounders["activities_after_founding"] = 0
#take all the records
In [14]:
df_founders.to_csv("berkeley_features_dataset.csv", index= False)
df_nonfounders.to_csv("berkeley_nonfounders_features_dataset.csv", index=False)
In [2]:
df_founders = pd.read_csv("oxford_features_dataset.csv")
df_nonfounders = pd.read_csv("oxford_nonfounders_features_dataset.csv")

pub_cols = [col for col in df_founders if col.startswith('hist_pub_FN-')]
df_founders['publications_before_founding']= df_founders[pub_cols].sum(axis=1)
df_nonfounders["publications_before_founding"] = 0
pat_cols = [col for col in df_founders if col.startswith('hist_pat_FN-')]
df_founders['patents_before_founding']= df_founders[pat_cols].sum(axis=1)
df_nonfounders["patents_before_founding"] = 0
grant_cols = [col for col in df_founders if col.startswith('hist_grant_FN-')]
df_founders['grants_before_founding']= df_founders[grant_cols].sum(axis=1)
df_nonfounders["grants_before_founding"] = 0


pub_cols = [col for col in df_founders if col.startswith('hist_pub_FN+')]
df_founders['publications_after_founding']= df_founders[pub_cols].sum(axis=1)
df_nonfounders["publications_after_founding"] = 0
pat_cols = [col for col in df_founders if col.startswith('hist_pat_FN+')]
df_founders['patents_after_founding']= df_founders[pat_cols].sum(axis=1)
df_nonfounders["patents_after_founding"] = 0
grant_cols = [col for col in df_founders if col.startswith('hist_grant_FN+')]
df_founders['grants_after_founding']= df_founders[grant_cols].sum(axis=1)
df_nonfounders["grants_after_founding"] = 0


df_founders["activities_total"] = df_founders[["publications","patents","grants"]].sum(axis=1)
df_nonfounders["activities_total"] = df_nonfounders[["publications","patents","grants"]].sum(axis=1)


df_founders["activities_before_founding"] = df_founders[["publications_before_founding", 
                                                        "patents_before_founding",
                                                        "grants_before_founding"]].sum(axis=1)
df_founders["activities_after_founding"] = df_founders[["publications_after_founding", 
                                                        "patents_after_founding",
                                                        "grants_after_founding"]].sum(axis=1)
df_nonfounders["activities_before_founding"] = 0
df_nonfounders["activities_after_founding"] = 0
#take all the records
In [4]:
df_founders.to_csv("oxford_features_dataset.csv", index= False)
df_nonfounders.to_csv("oxford_nonfounders_features_dataset.csv", index=False)
In [5]:
df_founders = pd.read_csv("ude_features_dataset.csv")
df_nonfounders = pd.read_csv("ude_nonfounders_features_dataset.csv")

pub_cols = [col for col in df_founders if col.startswith('hist_pub_FN-')]
df_founders['publications_before_founding']= df_founders[pub_cols].sum(axis=1)
df_nonfounders["publications_before_founding"] = 0
pat_cols = [col for col in df_founders if col.startswith('hist_pat_FN-')]
df_founders['patents_before_founding']= df_founders[pat_cols].sum(axis=1)
df_nonfounders["patents_before_founding"] = 0
grant_cols = [col for col in df_founders if col.startswith('hist_grant_FN-')]
df_founders['grants_before_founding']= df_founders[grant_cols].sum(axis=1)
df_nonfounders["grants_before_founding"] = 0


pub_cols = [col for col in df_founders if col.startswith('hist_pub_FN+')]
df_founders['publications_after_founding']= df_founders[pub_cols].sum(axis=1)
df_nonfounders["publications_after_founding"] = 0
pat_cols = [col for col in df_founders if col.startswith('hist_pat_FN+')]
df_founders['patents_after_founding']= df_founders[pat_cols].sum(axis=1)
df_nonfounders["patents_after_founding"] = 0
grant_cols = [col for col in df_founders if col.startswith('hist_grant_FN+')]
df_founders['grants_after_founding']= df_founders[grant_cols].sum(axis=1)
df_nonfounders["grants_after_founding"] = 0


df_founders["activities_total"] = df_founders[["publications","patents","grants"]].sum(axis=1)
df_nonfounders["activities_total"] = df_nonfounders[["publications","patents","grants"]].sum(axis=1)


df_founders["activities_before_founding"] = df_founders[["publications_before_founding", 
                                                        "patents_before_founding",
                                                        "grants_before_founding"]].sum(axis=1)
df_founders["activities_after_founding"] = df_founders[["publications_after_founding", 
                                                        "patents_after_founding",
                                                        "grants_after_founding"]].sum(axis=1)
df_nonfounders["activities_before_founding"] = 0
df_nonfounders["activities_after_founding"] = 0
#take all the records
In [10]:
df_founders.to_csv("ude_features_dataset.csv", index= False)
df_nonfounders.to_csv("ude_nonfounders_features_dataset.csv", index=False)