{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import networkx as nx\n",
"from pathlib import Path\n",
"from collections import OrderedDict"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[WindowsPath('../data/v1/WikiCSSH_categories.csv'),\n",
" WindowsPath('../data/v1/WikiCSSH_category2page.csv'),\n",
" WindowsPath('../data/v1/WikiCSSH_category_links.csv'),\n",
" WindowsPath('../data/v1/WikiCSSH_category_links_all.csv'),\n",
" WindowsPath('../data/v1/Wikicssh_core_categories.csv'),\n",
" WindowsPath('../data/v1/WikiCSSH_page2redirect.csv')]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wikicssh_path = Path(\"../data/v1\")\n",
"wikicssh_files = list(wikicssh_path.glob(\"./*.csv\"))\n",
"wikicssh_files"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" category | \n",
" level | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Computer_science | \n",
" 1 | \n",
"
\n",
" \n",
" 1 | \n",
" Mathematics | \n",
" 1 | \n",
"
\n",
" \n",
" 2 | \n",
" Information_science | \n",
" 1 | \n",
"
\n",
" \n",
" 3 | \n",
" Computer_engineering | \n",
" 1 | \n",
"
\n",
" \n",
" 4 | \n",
" Statistics | \n",
" 1 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" category level\n",
"0 Computer_science 1\n",
"1 Mathematics 1\n",
"2 Information_science 1\n",
"3 Computer_engineering 1\n",
"4 Statistics 1"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_categories = pd.read_csv('../data/v1/WikiCSSH_categories.csv')\n",
"df_categories.head()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(7354, 2)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_categories.shape"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 Category:Computer_science\n",
"1 Category:Mathematics\n",
"2 Category:Information_science\n",
"3 Category:Computer_engineering\n",
"4 Category:Statistics\n",
"Name: category, dtype: object"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(\"Category:\"+ df_categories.category).head()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"OrderedDict([('Computer_science', {'level': 1}),\n",
" ('Mathematics', {'level': 1}),\n",
" ('Information_science', {'level': 1}),\n",
" ('Computer_engineering', {'level': 1}),\n",
" ('Statistics', {'level': 1})])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_categories.set_index(\"category\").head().to_dict(orient=\"index\", into=OrderedDict)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" parent_cat | \n",
" child_cat | \n",
" parent_level | \n",
" child_level | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Computer_engineering | \n",
" Electronic_engineering | \n",
" 1 | \n",
" 2 | \n",
"
\n",
" \n",
" 1 | \n",
" Computer_engineering | \n",
" Software_engineering | \n",
" 1 | \n",
" 2 | \n",
"
\n",
" \n",
" 2 | \n",
" Computer_engineering | \n",
" Computer_hardware | \n",
" 1 | \n",
" 2 | \n",
"
\n",
" \n",
" 3 | \n",
" Computer_engineering | \n",
" Computer_systems | \n",
" 1 | \n",
" 2 | \n",
"
\n",
" \n",
" 4 | \n",
" Computer_engineering | \n",
" Computer_engineering_stubs | \n",
" 1 | \n",
" 2 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" parent_cat child_cat parent_level child_level\n",
"0 Computer_engineering Electronic_engineering 1 2\n",
"1 Computer_engineering Software_engineering 1 2\n",
"2 Computer_engineering Computer_hardware 1 2\n",
"3 Computer_engineering Computer_systems 1 2\n",
"4 Computer_engineering Computer_engineering_stubs 1 2"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_category_links = pd.read_csv('../data/v1/WikiCSSH_category_links.csv')\n",
"df_category_links.head()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(8323, 4)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_category_links.shape"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"7354"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(set(df_categories.category.values))"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"7263"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(set(df_category_links.parent_cat.values) | set(df_category_links.child_cat.values))"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" cat_title | \n",
" cat_level | \n",
" num_aff_pages | \n",
" page_title | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Information_science | \n",
" 1 | \n",
" 247 | \n",
" Information_professional | \n",
"
\n",
" \n",
" 1 | \n",
" Computer_science | \n",
" 1 | \n",
" 50 | \n",
" Technology_transfer_in_computer_science | \n",
"
\n",
" \n",
" 2 | \n",
" Computer_science | \n",
" 1 | \n",
" 50 | \n",
" Computational_social_choice | \n",
"
\n",
" \n",
" 3 | \n",
" Computer_science | \n",
" 1 | \n",
" 50 | \n",
" Outline_of_computer_science | \n",
"
\n",
" \n",
" 4 | \n",
" Computer_science | \n",
" 1 | \n",
" 50 | \n",
" Reduction_Operator | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" cat_title cat_level num_aff_pages \\\n",
"0 Information_science 1 247 \n",
"1 Computer_science 1 50 \n",
"2 Computer_science 1 50 \n",
"3 Computer_science 1 50 \n",
"4 Computer_science 1 50 \n",
"\n",
" page_title \n",
"0 Information_professional \n",
"1 Technology_transfer_in_computer_science \n",
"2 Computational_social_choice \n",
"3 Outline_of_computer_science \n",
"4 Reduction_Operator "
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_pages = pd.read_csv('../data/v1/WikiCSSH_category2page.csv')\n",
"df_pages.head()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(272747, 4)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_pages.shape"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(181070,)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_pages.page_title.value_counts().shape"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" page_title | \n",
" min_level | \n",
" redirect_page_title | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Information_professional | \n",
" 1 | \n",
" Information_Professional | \n",
"
\n",
" \n",
" 1 | \n",
" Technology_transfer_in_computer_science | \n",
" 1 | \n",
" NaN | \n",
"
\n",
" \n",
" 2 | \n",
" Computational_social_choice | \n",
" 1 | \n",
" Computational_social_choice | \n",
"
\n",
" \n",
" 3 | \n",
" Outline_of_computer_science | \n",
" 1 | \n",
" Computer_science_basic_topics | \n",
"
\n",
" \n",
" 4 | \n",
" Outline_of_computer_science | \n",
" 1 | \n",
" List_of_computer_science_topics | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" page_title min_level \\\n",
"0 Information_professional 1 \n",
"1 Technology_transfer_in_computer_science 1 \n",
"2 Computational_social_choice 1 \n",
"3 Outline_of_computer_science 1 \n",
"4 Outline_of_computer_science 1 \n",
"\n",
" redirect_page_title \n",
"0 Information_Professional \n",
"1 NaN \n",
"2 Computational_social_choice \n",
"3 Computer_science_basic_topics \n",
"4 List_of_computer_science_topics "
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_redirects = pd.read_csv('../data/v1/WikiCSSH_page2redirect.csv')\n",
"df_redirects.head()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(580312,)"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_redirects.redirect_page_title.value_counts().shape"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(942295, 3)"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_redirects.shape"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"91"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"isolate_cats = (\n",
" set(df_categories.category.values) \n",
" - set(\n",
" set(df_category_links.parent_cat.values) \n",
" | set(df_category_links.child_cat.values)\n",
" )\n",
")\n",
"len(isolate_cats)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"76"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"root_child_cats = set(\n",
" set(df_category_links.parent_cat.values) \n",
" - set(df_category_links.child_cat.values)\n",
")\n",
"len(root_child_cats)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Automotive_chemicals',\n",
" 'Social_status',\n",
" 'French-language_magazines',\n",
" 'Mosaic',\n",
" 'Statistics',\n",
" 'Sound_recording_technology',\n",
" 'Audio_engineering',\n",
" 'Original_English-language_manga',\n",
" 'Noise_reduction',\n",
" 'Eponyms']"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(root_child_cats)[:10]"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" category | \n",
" level | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Computer_science | \n",
" 1 | \n",
"
\n",
" \n",
" 1 | \n",
" Mathematics | \n",
" 1 | \n",
"
\n",
" \n",
" 2 | \n",
" Information_science | \n",
" 1 | \n",
"
\n",
" \n",
" 3 | \n",
" Computer_engineering | \n",
" 1 | \n",
"
\n",
" \n",
" 4 | \n",
" Statistics | \n",
" 1 | \n",
"
\n",
" \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" 6610 | \n",
" Plant_disease_scales | \n",
" 17 | \n",
"
\n",
" \n",
" 6629 | \n",
" Sustainable_design | \n",
" 17 | \n",
"
\n",
" \n",
" 6876 | \n",
" Masks | \n",
" 18 | \n",
"
\n",
" \n",
" 7118 | \n",
" Economic_reforms | \n",
" 19 | \n",
"
\n",
" \n",
" 7156 | \n",
" Change | \n",
" 19 | \n",
"
\n",
" \n",
"
\n",
"
76 rows × 2 columns
\n",
"
"
],
"text/plain": [
" category level\n",
"0 Computer_science 1\n",
"1 Mathematics 1\n",
"2 Information_science 1\n",
"3 Computer_engineering 1\n",
"4 Statistics 1\n",
"... ... ...\n",
"6610 Plant_disease_scales 17\n",
"6629 Sustainable_design 17\n",
"6876 Masks 18\n",
"7118 Economic_reforms 19\n",
"7156 Change 19\n",
"\n",
"[76 rows x 2 columns]"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_categories[df_categories.category.isin(root_child_cats)]"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" category | \n",
" level | \n",
"
\n",
" \n",
" \n",
" \n",
" 2390 | \n",
" Microphones | \n",
" 5 | \n",
"
\n",
" \n",
" 3166 | \n",
" Kernel_programmers | \n",
" 5 | \n",
"
\n",
" \n",
" 4332 | \n",
" Silicon_photonics | \n",
" 7 | \n",
"
\n",
" \n",
" 4404 | \n",
" Silicones | \n",
" 7 | \n",
"
\n",
" \n",
" 4578 | \n",
" ITU-T_recommendations | \n",
" 7 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" category level\n",
"2390 Microphones 5\n",
"3166 Kernel_programmers 5\n",
"4332 Silicon_photonics 7\n",
"4404 Silicones 7\n",
"4578 ITU-T_recommendations 7"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_categories[df_categories.category.isin(isolate_cats)].head()"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" category | \n",
" level | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Computer_science | \n",
" 1 | \n",
"
\n",
" \n",
" 1 | \n",
" Mathematics | \n",
" 1 | \n",
"
\n",
" \n",
" 2 | \n",
" Information_science | \n",
" 1 | \n",
"
\n",
" \n",
" 3 | \n",
" Computer_engineering | \n",
" 1 | \n",
"
\n",
" \n",
" 4 | \n",
" Statistics | \n",
" 1 | \n",
"
\n",
" \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" 7349 | \n",
" Techniques | \n",
" 20 | \n",
"
\n",
" \n",
" 7350 | \n",
" Streptococcal_proteins | \n",
" 20 | \n",
"
\n",
" \n",
" 7351 | \n",
" Catalysts | \n",
" 20 | \n",
"
\n",
" \n",
" 7352 | \n",
" Flax | \n",
" 20 | \n",
"
\n",
" \n",
" 7353 | \n",
" Gender | \n",
" 20 | \n",
"
\n",
" \n",
"
\n",
"
7354 rows × 2 columns
\n",
"
"
],
"text/plain": [
" category level\n",
"0 Computer_science 1\n",
"1 Mathematics 1\n",
"2 Information_science 1\n",
"3 Computer_engineering 1\n",
"4 Statistics 1\n",
"... ... ...\n",
"7349 Techniques 20\n",
"7350 Streptococcal_proteins 20\n",
"7351 Catalysts 20\n",
"7352 Flax 20\n",
"7353 Gender 20\n",
"\n",
"[7354 rows x 2 columns]"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_categories"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(8400, 4)"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_category_links_all = pd.concat([\n",
" df_category_links,\n",
" df_categories[df_categories.category.isin(root_child_cats)].rename(columns={\n",
" \"category\": \"child_cat\", \n",
" \"level\": \"child_level\", #\tparent_level\tchild_level\n",
" }).assign(parent_cat=\"\", parent_level=0),\n",
" pd.DataFrame({\n",
" \"parent_cat\": [\"\"],\n",
" \"child_cat\": [\"\"],\n",
" \"parent_level\": [-1],\n",
" \"child_level\": [0],\n",
" })\n",
"# df_categories[df_categories.category.isin(isolate_cats)].rename(columns={\n",
"# \"category\": \"child_cat\", \n",
"# \"level\": \"child_level\", #\tparent_level\tchild_level\n",
"# }).assign(parent_cat=\"\", parent_level=0)\n",
" \n",
"], axis=0, sort=True).sort_values([\"parent_level\", \"child_level\"])\n",
"df_category_links_all.shape"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" child_cat | \n",
" child_level | \n",
" parent_cat | \n",
" parent_level | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" <ROOT> | \n",
" 0 | \n",
" | \n",
" -1 | \n",
"
\n",
" \n",
" 0 | \n",
" Computer_science | \n",
" 1 | \n",
" <ROOT> | \n",
" 0 | \n",
"
\n",
" \n",
" 1 | \n",
" Mathematics | \n",
" 1 | \n",
" <ROOT> | \n",
" 0 | \n",
"
\n",
" \n",
" 2 | \n",
" Information_science | \n",
" 1 | \n",
" <ROOT> | \n",
" 0 | \n",
"
\n",
" \n",
" 3 | \n",
" Computer_engineering | \n",
" 1 | \n",
" <ROOT> | \n",
" 0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" child_cat child_level parent_cat parent_level\n",
"0 0 -1\n",
"0 Computer_science 1 0\n",
"1 Mathematics 1 0\n",
"2 Information_science 1 0\n",
"3 Computer_engineering 1 0"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_category_links_all.head()"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" child_cat | \n",
" child_level | \n",
" parent_cat | \n",
" parent_level | \n",
"
\n",
" \n",
" \n",
" \n",
" 85 | \n",
" Artificial_intelligence | \n",
" 3 | \n",
" Areas_of_computer_science | \n",
" 2 | \n",
"
\n",
" \n",
" 492 | \n",
" Artificial_intelligence | \n",
" 3 | \n",
" Unsolved_problems_in_computer_science | \n",
" 2 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" child_cat child_level \\\n",
"85 Artificial_intelligence 3 \n",
"492 Artificial_intelligence 3 \n",
"\n",
" parent_cat parent_level \n",
"85 Areas_of_computer_science 2 \n",
"492 Unsolved_problems_in_computer_science 2 "
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_category_links_all[\n",
" #(df_category_links_all.parent_cat==\"Artificial_intelligence\")\n",
" (df_category_links_all.child_cat==\"Artificial_intelligence\")\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(3389, 2)"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_categories[df_categories.level<=5].shape"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"G = nx.DiGraph()"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"8400"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"G.add_edges_from(df_category_links_all.set_index([\"parent_cat\", \"child_cat\"]).to_dict(orient=\"index\", into=OrderedDict))\n",
"G.size()"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nx.algorithms.is_directed_acyclic_graph(G)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Fuzzy_logic',\n",
" 'Machine_learning',\n",
" 'Turing_tests',\n",
" 'Rule_engines',\n",
" 'Robots',\n",
" 'Computer_vision',\n",
" 'Logic_programming',\n",
" 'Open_source_artificial_intelligence',\n",
" 'Virtual_assistants',\n",
" 'Cloud_robotics',\n",
" 'Game_artificial_intelligence',\n",
" 'AI_accelerators',\n",
" 'Affective_computing',\n",
" 'Cognitive_architecture',\n",
" 'Artificial_intelligence_applications',\n",
" 'Artificial_immune_systems',\n",
" 'Robotics',\n",
" 'Artificial_Intelligence_existential_risk',\n",
" 'Evolutionary_computation']"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"node = \"Artificial_intelligence\"\n",
"list(G.neighbors(node))"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Areas_of_computer_science', 'Unsolved_problems_in_computer_science']"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(G.predecessors(node))"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Wall time: 1.17 s\n"
]
}
],
"source": [
"%%time\n",
"cat2pages = pd.read_csv('../data/v1/WikiCSSH_category2page.csv').groupby(\"cat_title\").page_title.agg(list)"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display, HTML"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"def show_context_of_category(node):\n",
" parents = list(G.predecessors(node))\n",
" children = list(G.neighbors(node))\n",
" table_header = \"Parents | Node | Children |
\"\n",
" parents_list = \"\\n\".join([f\"{i}\" for i in parents])\n",
" children_list = \"\\n\".join([f\"{i}\" for i in children])\n",
" node_list = f\"{node}\"\n",
" page_list = \" | \".join([\n",
" f\"{i}\"\n",
" for i in cat2pages[node]\n",
" ])\n",
" table_body = f\"\"\"\n",
" \n",
" | \n",
" {node_list} | \n",
" | \n",
"
\n",
" Pages {page_list} |
\n",
" \"\"\"\n",
" div = f\"\"\"\n",
" \n",
" \n",
"
{table_header}{table_body}
\n",
"
\"\"\"\n",
" return HTML(div)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" \n",
"
Parents | Node | Children |
\n",
" \n",
" | \n",
" Artificial_intelligence | \n",
" - Fuzzy_logic
\n",
"- Machine_learning
\n",
"- Turing_tests
\n",
"- Rule_engines
\n",
"- Robots
\n",
"- Computer_vision
\n",
"- Logic_programming
\n",
"- Open_source_artificial_intelligence
\n",
"- Virtual_assistants
\n",
"- Cloud_robotics
\n",
"- Game_artificial_intelligence
\n",
"- AI_accelerators
\n",
"- Affective_computing
\n",
"- Cognitive_architecture
\n",
"- Artificial_intelligence_applications
\n",
"- Artificial_immune_systems
\n",
"- Robotics
\n",
"- Artificial_Intelligence_existential_risk
\n",
"- Evolutionary_computation
| \n",
"
\n",
" Pages User_behavior_analytics | FEDOR_(Armed_AI_bot) | Intelligent_word_recognition | Autonomous_agent | List_of_programming_languages_for_artificial_intelligence | Virtual_intelligence | Radiant_AI | Knowledge-based_recommender_system | Situated | Colloquis | Embodied_agent | Moral_Machine | Winner-take-all_in_action_selection | Onnx | Dartmouth_workshop | Fuzzy_logic | Knowledge_compilation | Music_and_artificial_intelligence | Trenchard_More | Artificial_empathy | Artificial_intelligence,_situated_approach | 3D_reconstruction_from_multiple_images | Roborace | Multi-Agent_Programming_Contest | VaultML | Fred_(chatterbot) | Automated_personal_assistant | Computer_audition | Stochastic_semantic_analysis | Structure_mapping_engine | Artificial_imagination | Game_theory | Algorithmic_probability | API.AI | Percept_(artificial_intelligence) | Maluuba | ADS-AC | SUPS | Automated_Mathematician | Web_intelligence | DeepDream | LIDA_(cognitive_architecture) | Shyster_(expert_system) | Recurrent_neural_network | Artificial_brain | Color_moments | Legal_expert_system | Admissible_heuristic | Reasoning_system | NewsRx | Language_Acquisition_Device_(computer) | Collective_intelligence | Psychology_of_reasoning | Commonsense_reasoning | Symbol_level | Agent_systems_reference_model | Gxc3xb6del_machine | Probabilistic_logic_network | Behavior_informatics | Chess_as_mental_training | Belief-desire-intention_model | KL-ONE | Meca_Sapiens | List_of_artificial_intelligence_projects | Artificial_general_intelligence | Susan_Schneider_(philosopher) | Fast-And-Frugal_trees | Language/action_perspective | Recursive_neural_network | Artificial_intuition | Machine_perception | Nouvelle_AI | Voice_Mate | Babelfy | Loebner_Prize | Type-1_OWA_operators | Gomocup | Epistemic_modal_logic | Instrumental_convergence | Cerebellar_model_articulation_controller | List_of_datasets_for_machine-learning_research | Thompson_sampling | Backward_chaining | IRCF360 | Computer_vision | Computer-assisted_proof | Blackboard_system | Qloo | Hierarchical_control_system | Kinect | Enterprise_cognitive_system | Uncanny_valley | Embodied_cognitive_science | Neuro-fuzzy | A.I._Artificial_Intelligence | Ontology_engineering | Knowledge_acquisition | Syman | Behavior_tree_(artificial_intelligence,_robotics_and_control) | Google.ai | ACROSS_Project | International_Conference_on_Autonomous_Agents_and_Multiagent_Systems | AIVA | Neural_computation | Cloud_robotics | Chatterbox_Challenge | Singleton_(global_governance) | Project_Joshua_Blue | 0music | Emily_Howell | Rule-based_system | Knowledge_level | Personoid | Lawbot | Cobweb_(clustering) | Noogenesis | Incremental_heuristic_search | Ontology_learning | Moravec's_paradox | Argumentation_framework | Right_to_explanation | ICarbonX | Knowledge_Based_Software_Assistant | Cognitive_philology | Inductive_programming | The_Leaf_(AI)_Project | Hybrid_intelligent_system | Extremal_optimization | Differentiable_neural_computer | Artificial_intelligence_for_video_surveillance | MNIST_database | Medical_intelligence_and_language_engineering_lab | Contextual_image_classification | Hybrid_neural_network | Applications_of_artificial_intelligence | Oriented_Energy_Filters | Model-based_reasoning | Neural_network_software | Intelligent_agent | Synthetic_Environment_for_Analysis_and_Simulations | Concurrent_MetateM | Open_Information_Extraction | Data_pack | DAYDREAMER | Knowledge-based_configuration | Deductive_classifier | OpenCog | Manifold_integration | Perceptual_computing | Anytime_algorithm | Mivar-based_approach | Neurorobotics | Plug_&_Pray | Zeuthen_strategy | Computational_humor | Puckstering | Schema-agnostic_databases | Fuzzy_agent | Brain_technology | Intel_RealSense | User_illusion | Cognitive_computer | Open_Letter_on_Artificial_Intelligence | Turing_Robot | March_of_the_Machines | NTU_RGB-D_dataset | IJCAI_Computers_and_Thought_Award | Mind-body_problem | Computational_Heuristic_Intelligence | Ordered_weighted_averaging_aggregation_operator | Distributed_artificial_intelligence | Darwin_machine | SNePS | Glossary_of_artificial_intelligence | Soft_computing | Intelligent_control | Anticipation_(artificial_intelligence) | Expert_system | Catastrophic_interference | Knowledge-based_systems | Means-ends_analysis | Spreading_activation | POP-11 | Rough_fuzzy_hybridization | Natural_language_understanding | Artificial_psychology | Vaumpus_world | Scilab_Image_Processing | Emospark | Hindsight_optimization | Self-management_(computer_science) | Connectionist_expert_system | Cognitive_infocommunications | Wetware_(brain) | Luminoso | Mycroft_(software) | Principle_of_rationality | Sensorium_Project | MANIC_(Cognitive_Architecture) | Competitions_and_prizes_in_artificial_intelligence | Any-angle_path_planning | Manifold_alignment | Conference_on_Semantics_in_Healthcare_and_Life_Sciences | Cognitive_computing | Natural_language_processing | Informatics | Diagnosis_(artificial_intelligence) | Constructionist_design_methodology | Australian_Artificial_Intelligence_Institute | S_Voice | AI-complete | Generalized_distributive_law | Computational_intelligence | Angel_F | AgentSheets | WordDive | Frame_problem | Intelligent_decision_support_system | Problem_solving | Kuwahara_filter | Artificial_intelligence | Leverhulme_Centre_for_the_Future_of_Intelligence | BabyX | Weak_AI | Autognostics | Bayesian_programming | Outline_of_machine_learning | Rational_agent | And-or_tree | DragonLord_Enterprises,_Inc. | CALO | Alesis_Artificial_Intelligence | Neural_modeling_fields | Discovery_system | Histogram_of_oriented_displacements | ASR-complete | Pattern_theory | Explainable_AI | The_Fable_of_Oscar | Automated_reasoning | OpenAIR | Intelligent_database | GENESIS_(software) | Mindpixel | Google | Action_selection | Gabbay's_separation_theorem | Allen_(robot) | Extreme:_Personal_Assistant | Outline_of_artificial_intelligence | Wojciech_Zaremba | Clone_Algo_Inc | Cognitive_tutor | Industrial_artificial_intelligence | Description_logic | Evolving_intelligent_system | Autonomic_computing | Software_agent | Artificial_intelligence_and_law | Human_Problem_Solving | Combs_method | Committee_machine | ICAD_(software) | INDECT | Artificial_consciousness | Frame_language | Computational_human_modeling | Evolutionary_developmental_robotics | BabelNet | Computational_creativity | Conflict_resolution_strategy | OpenIRIS | Cognitive_robotics | Information_space_analysis | Artificial_intelligence_systems_integration | Darkforest | Distributional-Relational_Databases | Smart_objects | Subrata_Dasgupta | Document_mosaicing | Nervous_system_network_models | Robot_lawyer | Information_extraction | Aurora_(novel) | Pedagogical_agent | Simulated_consciousness_in_fiction | K-line_(artificial_intelligence) | 20Q | Artificial_Intelligence_System | KAoS | Ensemble_averaging_(machine_learning) | Computer_Arimaa | Bio-inspired_computing | Type-2_fuzzy_sets_and_systems | Grammar_systems_theory | Attributional_calculus | Symbolic_artificial_intelligence | Decision_list | Progress_in_artificial_intelligence | Autonomic_networking | Winograd_Schema_Challenge | Dynamic_epistemic_logic |
\n",
"
\n",
"
"
],
"text/plain": [
""
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"show_context_of_category(node)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Interactive usage"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [],
"source": [
"from ipywidgets import interact_manual"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2d4a9781420c45319f11b3a246567e9e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(Text(value='Computer_vision', description='node'), Button(description='Run Interact', st…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"interact_manual(show_context_of_category, node=\"Computer_vision\");"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}