IIabm/AmendFirm_20230216.ipynb

308 lines
1.3 MiB
Plaintext
Raw Normal View History

2023-02-16 16:11:54 +08:00
{
"cells": [
{
"cell_type": "code",
2023-02-20 17:40:26 +08:00
"execution_count": 207,
2023-02-16 16:11:54 +08:00
"metadata": {},
2023-02-18 18:44:26 +08:00
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
2023-02-20 17:40:26 +08:00
"C:\\Users\\25759\\AppData\\Local\\Temp\\ipykernel_3908\\296948596.py:42: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
2023-02-18 18:44:26 +08:00
" Firm_copy.insert(Firm_copy.columns.get_loc('Revenue'),'Revenue_Log', series_Revenue_Log)\n",
2023-02-20 17:40:26 +08:00
"C:\\Users\\25759\\AppData\\Local\\Temp\\ipykernel_3908\\296948596.py:44: PerformanceWarning: DataFrame is highly fragmented. This is usually the result of calling `frame.insert` many times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()`\n",
2023-02-18 18:44:26 +08:00
" Firm_copy.insert(Firm_copy.columns.get_loc('Num_Employ'),'Num_Employ_Log', series_Num_Employ_Log)\n"
]
2023-02-20 17:40:26 +08:00
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"1\n"
]
2023-02-18 18:44:26 +08:00
}
],
2023-02-16 16:11:54 +08:00
"source": [
"import pandas as pd\n",
2023-02-18 16:46:38 +08:00
"import numpy as np\n",
2023-02-18 18:44:26 +08:00
"import math\n",
"import statsmodels.formula.api as smf\n",
2023-02-18 16:46:38 +08:00
"from sklearn.preprocessing import MinMaxScaler\n",
2023-02-16 16:11:54 +08:00
"import networkx as nx\n",
"import matplotlib.pyplot as plt\n",
2023-02-18 18:44:26 +08:00
"import seaborn as sns\n",
2023-02-16 16:11:54 +08:00
"\n",
"plt.rcParams['font.sans-serif'] = 'SimHei'\n",
"\n",
2023-02-18 18:44:26 +08:00
"# init graph bom\n",
2023-02-16 16:11:54 +08:00
"BomNodes = pd.read_csv('BomNodes.csv', index_col=0)\n",
"BomNodes.set_index('Code', inplace=True)\n",
"BomCateNet = pd.read_csv('BomCateNet.csv', index_col=0)\n",
"BomCateNet.fillna(0, inplace=True)\n",
"\n",
"G = nx.from_pandas_adjacency(BomCateNet, create_using=nx.MultiDiGraph())\n",
"\n",
"labels_dict = {}\n",
"for code in G.nodes:\n",
" labels_dict[code] = BomNodes.loc[code].to_dict()\n",
2023-02-18 18:44:26 +08:00
"nx.set_node_attributes(G, labels_dict)\n",
"\n",
"# load firm\n",
"Firm = pd.read_csv(\"Firm.csv\")\n",
"Firm_copy = Firm.copy()\n",
"\n",
"# get log revenue\n",
"Firm_copy['Revenue_Log'] = Firm_copy['Revenue'].map(math.log)\n",
"Firm_copy['Num_Employ_Log'] = Firm_copy['Num_Employ'].map(math.log)\n",
"data_ols = Firm_copy[Firm_copy[['Revenue_Log', 'Num_Employ_Log']].notnull().all(axis=1)][['Revenue_Log', 'Num_Employ_Log']]\n",
"\n",
"ols_model = smf.ols('Revenue_Log ~ Num_Employ_Log', data=data_ols)\n",
"ols_results = ols_model.fit()\n",
"b = ols_results.params.Intercept\n",
"a = ols_results.params.Num_Employ_Log\n",
"# sns.regplot(x='Num_Employ_Log',y='Revenue_Log',data=data_ols[data_ols.notnull().all(axis=1)])\n",
"\n",
"Firm_copy.loc[Firm_copy['Revenue_Log'].isnull(), 'Revenue_Log'] = Firm_copy[Firm_copy['Revenue_Log'].isnull()]['Num_Employ_Log'].map(lambda x: a*x + b)\n",
"series_Revenue_Log = Firm_copy.pop('Revenue_Log')\n",
"Firm_copy.insert(Firm_copy.columns.get_loc('Revenue'),'Revenue_Log', series_Revenue_Log)\n",
"series_Num_Employ_Log = Firm_copy.pop('Num_Employ_Log')\n",
"Firm_copy.insert(Firm_copy.columns.get_loc('Num_Employ'),'Num_Employ_Log', series_Num_Employ_Log)\n",
"\n",
"# lift firm from neighboring tier\n",
2023-02-20 17:40:26 +08:00
"node_list = list(nx.bfs_tree(G, '1'))\n",
"node_list.reverse()\n",
"for node in node_list[:-1]:\n",
" if G.out_degree(node) > 0 and sum(Firm_copy[node]==1) == 0:\n",
2023-02-16 16:11:54 +08:00
" list_neighbors = list(G.neighbors(node))\n",
" firm_list = Firm_copy.index[(Firm_copy[list_neighbors]==1).all(axis=1)].to_list()\n",
2023-02-20 16:02:39 +08:00
" if firm_list: # there exist firm that produces all components\n",
" # lift firm with size above average in firm_list\n",
" average_size = Firm_copy.loc[firm_list, 'Revenue_Log'].mean()\n",
2023-02-20 17:03:36 +08:00
" firm_selected_list = Firm_copy.loc[firm_list].loc[Firm_copy.loc[firm_list, 'Revenue_Log'] > average_size].index.to_list()\n",
" Firm_copy.loc[firm_selected_list, node] = 1\n",
" Firm_copy.loc[firm_selected_list, list_neighbors] = np.nan\n",
2023-02-20 17:40:26 +08:00
" else: # select top 15% firm in terms of size\n",
2023-02-20 17:03:36 +08:00
" firm_list = Firm_copy.index[(Firm_copy[list_neighbors]==1).any(axis=1)].to_list()\n",
" firm_df = Firm_copy.loc[firm_list].sort_values('Revenue_Log', ascending=False)\n",
2023-02-20 17:40:26 +08:00
" num_firm_selected = round(firm_df.shape[0] * 0.15)\n",
2023-02-20 17:03:36 +08:00
" firm_selected_list = firm_df.index[0: num_firm_selected].to_list()\n",
2023-02-20 17:40:26 +08:00
" Firm_copy.loc[firm_selected_list, node] = 1\n",
" Firm_copy.loc[firm_selected_list, list_neighbors] = np.nan\n",
2023-02-18 18:44:26 +08:00
"\n",
"# output\n",
2023-02-16 16:11:54 +08:00
"Firm_copy.to_csv('Firm_amended.csv', index=False, encoding='utf-8-sig')"
]
},
{
"cell_type": "code",
2023-02-20 17:40:26 +08:00
"execution_count": 211,
2023-02-20 17:03:36 +08:00
"metadata": {},
"outputs": [
{
"data": {
2023-02-20 17:40:26 +08:00
"image/png": "iVBORw0K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AAAAAAAAaiaIDAAAAAAAAAAAAADUTBAZAAAAAAAAAAAAAKiZIDIAAAAAAAAAAAAAUDNBZAAAAAAAAAAAAACgZoLIAAAAAAAAAAAAAEDNBJEBAAAAAAAAAAAAgJoJIgMAAAAAAAAAAAAANRNEBgAAAAAAAAAAAABqJogMAAAAAAAAAAAAANRMEBkAAAAAAAAAAAAAqJkgMgAAAAAAAAAAAABQM0FkAAAAAAAAAAAAAKBmgsgAAAAAAAAAAAAAQM0EkQEAAAAAAAAAAACAmgkiAwAAAAAAAAAAAAA1E0QGAAAAAAAAAAAAAGomiAwAAAAAAAAAAAAA1EwQGQAAAAAAAAAAAAComSAyAAAAAAAAAAAAAFAzQWQAAAAAAAAAAAAAoGaCyAAAAAAAAAAAAABAzQSRAQAAAAAAAAAAAICaCSIDAAAAAAAAAAAAADUTRAYAAAAAAAAAAAAAaiaIDAAAAAAAAAAAAADUTBAZAAAAAAAAAAAAAKiZIDIAAAAAAAAAAAAAUDNBZAAAAAAAAAAAAACgZoLIAAAAAAAAAAAAAEDNBJEBAAAAAAAAAAAAgJoJIgMAAAAAAAAAAAAANRNEBgAAAAAAAAAAAABqJogMAAAAAAAAAAAAANRMEBkAAAAAAAAAAAAAqJkgMgAAAAAAAAAAAABQM0FkAAAAAAAAAAAAAKBmgsgAAAAAAAAAAAAAQM0EkQEAAAAAAAAAAACAmgkiAwAAAAAAAAAAAAA1E0QGAAAAAAAAAAAAAGomiAwAAAAAAAAAAAAA1EwQGQAAAAAAAAAAAAComSAyAAAAAAAAAAAAAFAzQWQAAAAAAAAAAAAAoGaCyAAAAAAAAAAAAABAzQSRAQAAAAA
2023-02-16 16:11:54 +08:00
"text/plain": [
2023-02-16 16:58:02 +08:00
"<Figure size 3600x3600 with 1 Axes>"
2023-02-16 16:11:54 +08:00
]
},
"metadata": {},
2023-02-16 16:58:02 +08:00
"output_type": "display_data"
2023-02-16 16:11:54 +08:00
}
],
"source": [
2023-02-18 16:46:38 +08:00
"# visualization\n",
2023-02-16 16:58:02 +08:00
"firm_num_dict = {}\n",
"for node in nx.nodes(G):\n",
" firm_num_dict[node]= sum(Firm_copy[node]==1)\n",
"nx.set_node_attributes(G, firm_num_dict, name=\"Num_Firm\")\n",
"\n",
"pos = nx.nx_agraph.graphviz_layout(G, prog=\"twopi\", args=\"\")\n",
2023-02-18 16:46:38 +08:00
"dict_num_firm = nx.get_node_attributes(G, 'Num_Firm')\n",
"dict_node_name = nx.get_node_attributes(G, 'Name')\n",
"node_labels = {}\n",
"for node in nx.nodes(G):\n",
2023-02-20 17:03:36 +08:00
" node_labels[node] = f\"{node} {str(dict_node_name[node])} {str(dict_num_firm[node])}\"\n",
" # node_labels[node] = f\"{str(dict_num_firm[node])}\"\n",
2023-02-16 16:58:02 +08:00
"plt.figure(figsize=(12, 12), dpi=300)\n",
"nx.draw_networkx_nodes(G, pos)\n",
"nx.draw_networkx_edges(G, pos)\n",
2023-02-18 16:46:38 +08:00
"nx.draw_networkx_labels(G, pos, labels = node_labels, font_size=4)\n",
2023-02-16 16:58:02 +08:00
"plt.show()"
2023-02-16 16:11:54 +08:00
]
},
{
"cell_type": "code",
2023-02-20 17:40:26 +08:00
"execution_count": 215,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[99]\n"
]
}
],
"source": [
"node = '2.1'\n",
"if G.out_degree(node) > 0 and sum(Firm_copy[node]==1) == 0:\n",
" list_neighbors = list(G.neighbors(node))\n",
" firm_list = Firm_copy.index[(Firm_copy[list_neighbors]==1).all(axis=1)].to_list()\n",
" print(firm_list)\n",
" if firm_list: # there exist firm that produces all components\n",
" # lift firm with size above average in firm_list\n",
" average_size = Firm_copy.loc[firm_list, 'Revenue_Log'].mean()\n",
" firm_selected_list = Firm_copy.loc[firm_list].loc[Firm_copy.loc[firm_list, 'Revenue_Log'] > average_size].index.to_list()\n",
" Firm_copy.loc[firm_selected_list, node] = 1\n",
" Firm_copy.loc[firm_selected_list, list_neighbors] = np.nan\n",
" else: # select top 15% firm in terms of size\n",
" firm_list = Firm_copy.index[(Firm_copy[list_neighbors]==1).any(axis=1)].to_list()\n",
" firm_df = Firm_copy.loc[firm_list].sort_values('Revenue_Log', ascending=False)\n",
" num_firm_selected = round(firm_df.shape[0] * 0.2)\n",
" print(num_firm_selected)\n",
" firm_selected_list = firm_df.index[0: num_firm_selected].to_list()\n",
" Firm_copy.loc[firm_selected_list, node] = 1\n",
" Firm_copy.loc[firm_selected_list, list_neighbors] = np.nan"
]
},
{
"cell_type": "code",
"execution_count": 209,
2023-02-16 16:11:54 +08:00
"metadata": {},
"outputs": [
2023-02-18 18:44:26 +08:00
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 7393.0\n",
"1 171.0\n",
"2 113.0\n",
"3 24.0\n",
"4 242.0\n",
" ... \n",
"165 60.0\n",
"166 292.0\n",
"167 13371.0\n",
"168 5057.0\n",
"169 5173.0\n",
"Name: Num_Employ, Length: 129, dtype: float64\n"
]
},
2023-02-16 16:11:54 +08:00
{
"data": {
"text/plain": [
2023-02-20 17:40:26 +08:00
"<seaborn.axisgrid.FacetGrid at 0x1dd9f878790>"
2023-02-16 16:11:54 +08:00
]
},
2023-02-20 17:40:26 +08:00
"execution_count": 209,
2023-02-16 16:11:54 +08:00
"metadata": {},
"output_type": "execute_result"
2023-02-18 18:44:26 +08:00
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAeoAAAHpCAYAAABN+X+UAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAnqklEQVR4nO3de3TU9Z3/8dcwk0yIkMuUCOsYzG0rBUytMWsaTyldsyxbyRHt1rLh1GK9RFGhws7RHGmrZ2mS7WFTumtB40k3xC1a6xHQpVEs2KzVxnUs5jgdVhBICVl/K8owEwgMIXx/f7jMMjCBBJP5fkiej3O+p5nLd/KeD9/Tpz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fL7/QoGg2pubrZjPAAAjJH0UJ84cUKBQECzZs1SVlaWsrKyNHHiRLW2tiocDquhoUGFhYWqra1VU1NTsscDAMAoSQ/1e++9J8uydPXVV2v8+PGaO3eu9u3bp46ODpWVlSk9PV2SVFxcrGAwOODtRKNRRSKRuA0AgNEm6aEOBoOaMWOGnnnmGQWDQaWkpKi6ulqRSET5+fmx6zkcDjmdToVCoYS3U1dXp8zMzNiWm5ubrLsAAEDSJD3UCxcuVHt7u0pLS5Wfn6/HH39cW7Zs0cmTJ+V2u+Oum5aWpt7e3oS3U1NTo3A4HNu6urqSMT4AAEnlsnuArKwsnTx5UlOmTFEgEIi7rKenR6mpqQn3c7vdZ4UdAIDRJumPqJctW6bnnnsudvrtt9/WuHHjdNVVV6m9vT12fmdnp6LRqDweT7JHBADAGEl/RH311VfrkUc
"text/plain": [
"<Figure size 500x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
2023-02-16 16:11:54 +08:00
}
],
"source": [
2023-02-18 16:46:38 +08:00
"import seaborn as sns\n",
"data = Firm_copy[Firm_copy['Num_Employ'] > 0]['Num_Employ']\n",
2023-02-18 18:44:26 +08:00
"print(data)\n",
"sns.displot(data)"
]
},
{
"cell_type": "code",
2023-02-20 17:40:26 +08:00
"execution_count": 210,
2023-02-18 18:44:26 +08:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 1.089000e+10\n",
"1 1.380000e+08\n",
"6 1.590000e+08\n",
"11 6.750000e+08\n",
"13 2.470000e+09\n",
" ... \n",
"160 6.894667e+09\n",
"162 5.880760e+07\n",
"167 4.110000e+10\n",
"168 4.519000e+09\n",
"169 3.470400e+10\n",
"Name: Revenue, Length: 110, dtype: float64\n"
]
},
{
"data": {
"text/plain": [
2023-02-20 17:40:26 +08:00
"<seaborn.axisgrid.FacetGrid at 0x1dda1ef1ca0>"
2023-02-18 18:44:26 +08:00
]
},
2023-02-20 17:40:26 +08:00
"execution_count": 210,
2023-02-18 18:44:26 +08:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAeoAAAHpCAYAAABN+X+UAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAn60lEQVR4nO3df3RU9Z3/8dc4Qyak5KekICGQH3SVH8bSGInpWWy3Ed1NIkh1l4WtK10FpGuL0pxKwa3YbUh3aRZ32wXiQkMUZV2PLGI3QlcoUj0ogyUlZ7ICSmpMRQKOM8HIEJLP9w+O8zVCfprMfDJ5Ps6553Rm7p15X26TpzO5M+MwxhgBAAArXRHpAQAAQNcINQAAFiPUAABYjFADAGAxQg0AgMUINQAAFiPUAABYLGpCbYxRIBAQbwsHAESTqAl1S0uLEhMT1dLSEulRAAAYMFETagAAohGhBgDAYoQaAACLEWoAACxGqAEAsBihBgDAYoQaAACLEWoAACxGqAEAsBihBgDAYoQaAACLEWoAACxGqAEAsBihBgDAYoQaAACLEWoAACxGqAEAsBihBgDAYoQaAACLEWoAACzmivQANsudUaD3Tp7s8varxo7VoddeDeNEAIDhhlB3472TJzVz5dYub3/5JwvCOA0AYDjipW8AACxGqAEAsBihBgDAYoQaAACLEWoAACxGqAEAsBihBgDAYoQaAACLEWoAACxGqAEAsBihBgDAYoQaAACLEWoAACxGqAEAsBihBgDAYoQaAACLEWoAACxGqAEAsBihBgDAYoQaAACLEWoAACwW9lBXVVXJ4XBcslRVVamurk55eXlKTk5WaWmpjDHhHg8AAKuEPdTz58+Xz+cLLY2NjRo9erRuvPFGlZSUKDc3Vx6PR16vV1VVVeEeDwAAq4Q91DExMUpKSgot1dXVmjt3rurr6+X3+1VRUaHs7GyVlZVp06ZN4R4PAACruCL54OfOndNjjz2m1157TVu2bFF+fr7i4uIkSTk5OfJ6vV1uGwwGFQwGQ5cDgcCgzwsAQLhF9GSyp556Svn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lpaFBMTE6HJAACIvLCH+sEHH9QzzzwTunzw4EFdccUVuvbaa3XgwIHQ9Q0NDQoGg0pJSQn3iAAAWCPsL31/+ctf1sqVKzV27FhduHBB999/v+6++27NmjVLfr9f1dXVuuuuu1ReXq7CwkI5nc5wjwgAgDXCHuq77rpL9fX1mj17tuLj43X77berrKxMLpdLlZWVmj9/vkpLS9Xe3q59+/aFezwAAKziMJZ9/FdTU5M8Ho8KCgqUmpra6+0CgYASExPl9/uVkJAwILOMm5ilmSu3dnn7yz9ZoD/+4e0BeSwAAC4n7M+oe5KWlqa0tLRIjwEAgBUiftY3AADoGqEGAMBihBoAAIsRagAALEaoAQCwGKEGAMBihBoAAIsRagAALEaoAQCwGKEGAMBihBoAAIsRagAALEaoAQCwGKEGAMBihBoAAIsRagAALEaoAQCwGKEGAMBihBoAAIsRagAALEaoAQCwGKEGAMBihBoAAIsRagAALEaoAQCwGKEGAMBihBoAAIsRagAALEaoAQCwGKEGAMBihBoAAIsRagAALEaoAQCwGKEGAMBihBoAAIsNSKiNMWpvbx+IuwIAAJ/S51AvXbpUwWCw03V79uzRlClTBmwoAABwUZ9DvXHjxktCPXXqVL3zzjsDNhQAALjI1dsVq6urJV18mfupp55SXFxc6PL//u//6vrrrx+cCQEAGMZ6Hepf/vKXkiSHw6GtW7fK5bq46RVXXKFJkybp6aefHpwJAQAYxnod6r1790q6GOZf/epXSkhIGLShAADARX3+G/XixYvldrsHYxYAAPAZvX5G/Yn169c
"text/plain": [
"<Figure size 500x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import seaborn as sns\n",
"data = Firm_copy[Firm_copy['Revenue'] > 0]['Revenue']\n",
"print(data)\n",
"sns.displot(data)"
2023-02-16 16:11:54 +08:00
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"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"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "bcdafc093860683ffb58d6956591562b7f8ed5d58147d17d71a5d4d6605a08df"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}