{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "a9a16090",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import pickle\n",
"import sys\n",
"sys.path.append('../src')\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
" \n",
"sns.set(font_scale = 3) \n",
"sns.set_theme()\n",
"sns.set_style(\"whitegrid\") "
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "07b65c40",
"metadata": {},
"outputs": [],
"source": [
"datasets = [\n",
" 'conference-1',\n",
" 'conference-2',\n",
" 'conference-3',\n",
" 'conference-4',\n",
" 'conference-5',\n",
" 'conference-6',\n",
" 'conference-7',\n",
" 'conference-8',\n",
" 'conference-9',\n",
" 'conference-10',\n",
" 'conference-11',\n",
" 'conference-12',\n",
" 'conference-13',\n",
" 'conference-14',\n",
" 'conference-15',\n",
" 'conference-16',\n",
" 'conference-17',\n",
" 'conference-18',\n",
" 'conference-19',\n",
" 'conference-20',\n",
" 'conference-21',\n",
" 'ai4eu-1',\n",
" 'ai4eu-2',\n",
" 'ai4eu-3',\n",
" 'nasa'\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "99cef871",
"metadata": {},
"outputs": [],
"source": [
"# number of pairs before and after blocking\n",
"dataset_summary = []\n",
"\n",
"for ds in datasets:\n",
" df_matrix = pd.read_csv('../results/' + ds + '/' + ds + '_matrix.csv')\n",
" source_ontology = pickle.load( open('../results/' + ds + '/' + ds + \"_source_ontology.pk\", \"rb\" ) )\n",
" target_ontology = pickle.load( open('../results/' + ds + '/' + ds + \"_target_ontology.pk\", \"rb\" ) ) \n",
" \n",
" category_name = ds.split('-', 1)[0]\n",
" \n",
" num_true_matches = len(df_matrix[df_matrix['label']==1])\n",
" num_candidates = len(df_matrix.index)\n",
" percentage = num_true_matches * 100.0 / num_candidates\n",
" \n",
" summary = {}\n",
" summary['dataset'] = category_name\n",
" summary['sub-name'] = ds\n",
" summary['#src'] = len(source_ontology)\n",
" summary['#target'] = len(target_ontology)\n",
" summary['#candidates'] = num_candidates\n",
" summary['#matches'] = num_true_matches\n",
" summary['percentage(after blocking)'] = percentage\n",
" \n",
" \n",
" dataset_summary.append(summary)\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "0f59560d",
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame(dataset_summary)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "2a30fcee",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead tr th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe thead tr:last-of-type th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr>\n",
" <th></th>\n",
" <th colspan=\"3\" halign=\"left\">#src</th>\n",
" <th colspan=\"3\" halign=\"left\">#target</th>\n",
" <th colspan=\"3\" halign=\"left\">#candidates</th>\n",
" <th colspan=\"3\" halign=\"left\">#matches</th>\n",
" <th colspan=\"3\" halign=\"left\">percentage(after blocking)</th>\n",
" </tr>\n",
" <tr>\n",
" <th></th>\n",
" <th>mean</th>\n",
" <th>min</th>\n",
" <th>max</th>\n",
" <th>mean</th>\n",
" <th>min</th>\n",
" <th>max</th>\n",
" <th>mean</th>\n",
" <th>min</th>\n",
" <th>max</th>\n",
" <th>mean</th>\n",
" <th>min</th>\n",
" <th>max</th>\n",
" <th>mean</th>\n",
" <th>min</th>\n",
" <th>max</th>\n",
" </tr>\n",
" <tr>\n",
" <th>dataset</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>ai4eu</th>\n",
" <td>92.000000</td>\n",
" <td>92</td>\n",
" <td>92</td>\n",
" <td>656.333333</td>\n",
" <td>451</td>\n",
" <td>1035</td>\n",
" <td>8214.333333</td>\n",
" <td>7719</td>\n",
" <td>9200</td>\n",
" <td>23.333333</td>\n",
" <td>17</td>\n",
" <td>33</td>\n",
" <td>0.279297</td>\n",
" <td>0.220093</td>\n",
" <td>0.358696</td>\n",
" </tr>\n",
" <tr>\n",
" <th>conference</th>\n",
" <td>57.904762</td>\n",
" <td>29</td>\n",
" <td>140</td>\n",
" <td>82.380952</td>\n",
" <td>38</td>\n",
" <td>140</td>\n",
" <td>2376.428571</td>\n",
" <td>956</td>\n",
" <td>5243</td>\n",
" <td>12.190476</td>\n",
" <td>4</td>\n",
" <td>23</td>\n",
" <td>0.605900</td>\n",
" <td>0.281258</td>\n",
" <td>1.301236</td>\n",
" </tr>\n",
" <tr>\n",
" <th>nasa</th>\n",
" <td>154.000000</td>\n",
" <td>154</td>\n",
" <td>154</td>\n",
" <td>915.000000</td>\n",
" <td>915</td>\n",
" <td>915</td>\n",
" <td>12213.000000</td>\n",
" <td>12213</td>\n",
" <td>12213</td>\n",
" <td>32.000000</td>\n",
" <td>32</td>\n",
" <td>32</td>\n",
" <td>0.262016</td>\n",
" <td>0.262016</td>\n",
" <td>0.262016</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" #src #target #candidates \\\n",
" mean min max mean min max mean min \n",
"dataset \n",
"ai4eu 92.000000 92 92 656.333333 451 1035 8214.333333 7719 \n",
"conference 57.904762 29 140 82.380952 38 140 2376.428571 956 \n",
"nasa 154.000000 154 154 915.000000 915 915 12213.000000 12213 \n",
"\n",
" #matches percentage(after blocking) \\\n",
" max mean min max mean min \n",
"dataset \n",
"ai4eu 9200 23.333333 17 33 0.279297 0.220093 \n",
"conference 5243 12.190476 4 23 0.605900 0.281258 \n",
"nasa 12213 32.000000 32 32 0.262016 0.262016 \n",
"\n",
" \n",
" max \n",
"dataset \n",
"ai4eu 0.358696 \n",
"conference 1.301236 \n",
"nasa 0.262016 "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby('dataset').agg({'#src': ['mean', 'min', 'max'], \n",
" '#target': ['mean', 'min', 'max'], \n",
" '#candidates': ['mean', 'min', 'max'], \n",
" '#matches': ['mean', 'min', 'max'], \n",
" 'percentage(after blocking)': ['mean', 'min', 'max']})"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "37b12178",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}