IIabm/AmendFirm_20230216.ipynb

291 lines
826 KiB
Plaintext
Raw Normal View History

2023-02-16 16:11:54 +08:00
{
"cells": [
{
"cell_type": "code",
2023-02-20 18:17:44 +08:00
"execution_count": 1,
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 20:56:27 +08:00
"C:\\Users\\25759\\AppData\\Local\\Temp\\ipykernel_1080\\1275047540.py:48: 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 20:56:27 +08:00
"C:\\Users\\25759\\AppData\\Local\\Temp\\ipykernel_1080\\1275047540.py:50: 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-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",
2023-02-20 18:17:44 +08:00
"# add attribute, number of firm, to graph bom\n",
"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",
2023-02-18 18:44:26 +08:00
"# 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",
2023-02-20 18:17:44 +08:00
"\n",
"# init criterion for ending the lifting process\n",
"node_check = [k for k, v in nx.get_node_attributes(G, 'Num_Firm').items() if v==0]\n",
"if '1' in node_check:\n",
" node_check.remove('1')\n",
"for node in node_check:\n",
" if G.out_degree(node) == 0:\n",
" node_check.remove(node)\n",
" print(f\"Warning: node, {node}, in tier 0 does not contain firm\")\n",
"\n",
"while node_check:\n",
" for node in node_list[:-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",
" 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.15)\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\n",
"\n",
" # update attribute, number of firm\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",
" # update criterion for ending the lifting process\n",
" node_check = [k for k, v in nx.get_node_attributes(G, 'Num_Firm').items() if v==0]\n",
" if '1' in node_check:\n",
" node_check.remove('1')\n",
" for node in node_check:\n",
" if G.out_degree(node) == 0:\n",
" node_check.remove(node)\n",
" print(f\"Warning: node, {node}, in tier 0 does not contain firm\")\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 18:17:44 +08:00
"execution_count": 2,
2023-02-20 17:03:36 +08:00
"metadata": {},
"outputs": [
{
"data": {
2023-02-20 20:56:27 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAACyIAAAsQCAYAAABS037aAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAC4jAAAuIwF4pT92AAEAAElEQVR4nOzdeXiV9Z03/k8SshCBhH2JCIwLllU6Fre6a0Xnseoz1K3jMu20Y+u0HZ8idVp1vNpnphbtVNunm7UWpdrqD0elrWAdpWJZpFYNiyUiEpYAJhDDYsh+fn9Q0MgiB5LcWV6v6zrXxbnPfX/vdyA5CSfv+3MyUqlUKgAAAAAAAAAAAAAA0pCZdAAAAAAAAAAAAAAAoONRRAYAAAAAAAAAAAAA0qaIDAAAAAAAAAAAAACkTREZAAAAAAAAAAAAAEibIjIAAAAAAAAAAAAAkDZFZAAAAAAAAAAAAAAgbYrIAAAAAAAAAAAAAEDaFJEBAAAAAAAAAAAAgLQpIgMAAAAAAAAAAAAAaVNEBgAAAAAAAAAAAADSpogMAAAAAAAAAAAAAKRNERkAAAAAAAAAAAAASJsiMgAAAAAAAAAAAACQNkVkAAAAAAAAAAAAACBtisgAAAA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AAAAAAEibIjIAAAAAAAAAAAAAkDZFZAAAAAAAAAAAAAAgbYrIAAAAAAAAAAAAAEDaFJEBAAAAAAAAAAAAgLQpIgMAAAAAAAAAAAAAaVNEBgAAAAAAAAAAAADSpogMAAAAAAAAAAAAAKRNERkAAAAAAAAAAAAASJsiMgAAAAAAAAAAAACQNkVkAAAAAAAAAAAAACBtisgAAAAAAAAAAAAAQNoUkQEAAAAAAAAAAACAtCkiAwAAAAAAAAA
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
"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 18:17:44 +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 18:17:44 +08:00
"execution_count": 3,
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 20:56:27 +08:00
"<seaborn.axisgrid.FacetGrid at 0x2bd702fc820>"
2023-02-16 16:11:54 +08:00
]
},
2023-02-20 18:17:44 +08:00
"execution_count": 3,
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/TpzOZi8OyLEsAAMBI4+weAAAADIxQAwBgMEINAIDBCDUAAAYj1AAAGIxQAwBgMEINAIDBRk2oLctSJBIRbwsHAIwmoybUPT09yszMVE9Pj92jAAAwbEZNqAEAGI0INQAABiPUAAAYjFADAGAwQg0AgMEINQAABrMl1E8//bSmTp2qCRMmqKKiQp2dnZKkQCCg0tJSZWdny+fz8Z5oAMCYl/RQ7969W4888og2btyoYDCoK664QosWLVI0GlVlZaVKSkrk9/sVDAbV3Nyc7PEAADBK0kO9fft2lZWV6ZprrtHUqVN1++23a+fOnWptbVU4HFZDQ4MKCwtVW1urpqamAW8nGo0qEonEbQAAjDZJD/X06dO1bds2bd++XeFwWD/72c/0V3/1V+ro6FBZWZn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nnnsudvrtt9/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 18:17:44 +08:00
"execution_count": 4,
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",
"162 5.880760e+07\n",
"167 4.110000e+10\n",
"168 4.519000e+09\n",
"169 3.470400e+10\n",
2023-02-20 18:17:44 +08:00
"170 1.000000e+08\n",
"Name: Revenue, Length: 111, dtype: float64\n"
2023-02-18 18:44:26 +08:00
]
},
{
"data": {
"text/plain": [
2023-02-20 20:56:27 +08:00
"<seaborn.axisgrid.FacetGrid at 0x2bd17758a00>"
2023-02-18 18:44:26 +08:00
]
},
2023-02-20 18:17:44 +08:00
"execution_count": 4,
2023-02-18 18:44:26 +08:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2023-02-20 18:17:44 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAeoAAAHpCAYAAABN+X+UAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAoAklEQVR4nO3dfXSU9Z3//9c4Qyak5FYiaAgkhFa5MZbGaEzPYt1GdDeJINVdFraudBGQri2KOZWCW3F3Q7pLs7jbLhALDfGOdXtkEbsRukKR6kYZLCn5TVZ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ABYj1AAAWIxQAwBgMUINAIDFCDUAABYj1AAAWIxQAwBgMUINAIDFCDUAABYj1AAAWIxQAwBgMUINAIDFCDUAABYj1AAAWIxQAwBgMUINAIDFCDUAABYj1AAAWIxQAwBgMUINAIDFCDUAABYj1AAAWIxQAwBgMUINAIDFCDUAABYj1AAAWIxQAwBgMUINAIDFCDUAABYj1AAAWIxQAwBgMUINAIDFCDUAABYbkFAbY9TR0TEQdwUAAD6nz6FeunSpgsFgp+t2796tKVOmDNhQAADgvD6HeuPGjReEeurUqXrvvfcGbCgAAHCeq7crVlVVSTr/Mvezzz6ruLi40OX//u//1vXXXz84EwIAMIz1OtS/+MUvJEkOh0PPPPOMXK7zm1522WWaNGmSnnvuucGZEACAYazXod6zZ4+k82H+1a9+pYSEhEEbCgAAnNfnv1EvXrxYbrd7MGYBAABf0Otn1J9Zv36
2023-02-18 18:44:26 +08:00
"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
}