{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "200d2dc6",
   "metadata": {},
   "source": [
    "# 02 분석 — 증가 배수, 가속, 국가 비중, 기술의 산업 확산\n",
    "\n",
    "2015년과 2024년을 비교 구간으로 두고, 2022년(생성형 AI 공개)을 전후로 증가 속도가 어떻게 달라졌는지 본다.\n",
    "특허의 동시분류(IPC)는 AI 기술이 어느 산업 분야와 결합하는지 보여 주므로, 설문에 기초한 산업 배분을 점검하는 근거가 된다."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a2a4b4b1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-07T19:42:40.496877Z",
     "iopub.status.busy": "2026-10-07T19:42:40.496877Z",
     "iopub.status.idle": "2026-10-07T19:42:42.839047Z",
     "shell.execute_reply": "2026-10-07T19:42:42.838044Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Python 3.12.10 · pandas 2.2.3 · numpy 2.4.6 · matplotlib 3.11.0\n",
      "  ONLINE=0(스냅샷)  OpenAlex 키 없음  Event Registry 키 없음\n",
      "  특허_연도            있음  data\\inputs\\findip_g06n_by_year.csv\n",
      "  특허_국가            있음  data\\inputs\\findip_g06n_by_country.csv\n",
      "  특허_동시분류          있음  data\\inputs\\findip_kr_g06n_coipc.csv\n",
      "  특허_출원인           있음  data\\inputs\\findip_kr_g06n_applicants.csv\n",
      "  논문_OpenAlex      있음  data\\inputs\\openalex_by_year.csv\n",
      "  논문_PubMed        있음  data\\inputs\\pubmed_by_year.csv\n",
      "  뉴스_EventRegistry 있음  data\\inputs\\eventregistry_ai_eng_daily.csv\n",
      "  뉴스_네이버_표본        있음  data\\inputs\\naver_daily_counts_생성형AI_sample.csv\n"
     ]
    }
   ],
   "source": [
    "import os, hashlib\n",
    "import numpy as np, pandas as pd\n",
    "import config as C\n",
    "import landscape as L\n",
    "pd.set_option(\"display.float_format\", lambda v: f\"{v:,.2f}\")\n",
    "C.setup()\n",
    "pat = pd.read_csv(C.FILES[\"특허_연도\"], index_col=0)\n",
    "cty = pd.read_csv(C.FILES[\"특허_국가\"], index_col=0).iloc[:, 0]\n",
    "coipc = pd.read_csv(C.FILES[\"특허_동시분류\"], index_col=0).iloc[:, 0]\n",
    "oa = pd.read_csv(C.FILES[\"논문_OpenAlex\"], index_col=0)\n",
    "pm = pd.read_csv(C.FILES[\"논문_PubMed\"], index_col=0).iloc[:, 0]\n",
    "er = pd.read_csv(C.FILES[\"뉴스_EventRegistry\"], index_col=0, parse_dates=True).iloc[:, 0]\n",
    "er_y = L.to_annual(er)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4ce70135",
   "metadata": {},
   "source": [
    "## 1. 증가 배수와 연평균 증가율(2015→2024)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "76fcc986",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-07T19:42:42.840047Z",
     "iopub.status.busy": "2026-10-07T19:42:42.840047Z",
     "iopub.status.idle": "2026-10-07T19:42:42.898708Z",
     "shell.execute_reply": "2026-10-07T19:42:42.898204Z"
    }
   },
   "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 th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2015</th>\n",
       "      <th>2024</th>\n",
       "      <th>배수</th>\n",
       "      <th>연평균(%)</th>\n",
       "      <th>2015–2022 연평균(%)</th>\n",
       "      <th>2022–2024 연평균(%)</th>\n",
       "    </tr>\n",
       "    <tr>\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>특허 G06N(한국)</th>\n",
       "      <td>513.00</td>\n",
       "      <td>12,081.00</td>\n",
       "      <td>23.55</td>\n",
       "      <td>42.05</td>\n",
       "      <td>60.38</td>\n",
       "      <td>-7.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>특허 G06N(5개국)</th>\n",
       "      <td>11,236.00</td>\n",
       "      <td>224,600.00</td>\n",
       "      <td>19.99</td>\n",
       "      <td>39.49</td>\n",
       "      <td>48.67</td>\n",
       "      <td>11.59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>논문 AI(OpenAlex 전체)</th>\n",
       "      <td>587,875.00</td>\n",
       "      <td>1,344,532.00</td>\n",
       "      <td>2.29</td>\n",
       "      <td>9.63</td>\n",
       "      <td>5.67</td>\n",
       "      <td>24.70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>논문 AI(OpenAlex 한국)</th>\n",
       "      <td>11,173.00</td>\n",
       "      <td>19,908.00</td>\n",
       "      <td>1.78</td>\n",
       "      <td>6.63</td>\n",
       "      <td>7.26</td>\n",
       "      <td>4.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>논문 AI·ML(PubMed)</th>\n",
       "      <td>6,478.00</td>\n",
       "      <td>38,072.00</td>\n",
       "      <td>5.88</td>\n",
       "      <td>21.75</td>\n",
       "      <td>24.30</td>\n",
       "      <td>13.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>뉴스 AI(영문)</th>\n",
       "      <td>24,403.00</td>\n",
       "      <td>949,803.00</td>\n",
       "      <td>38.92</td>\n",
       "      <td>50.21</td>\n",
       "      <td>39.56</td>\n",
       "      <td>94.27</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         2015         2024    배수  연평균(%)  2015–2022 연평균(%)  \\\n",
       "지표                                                                           \n",
       "특허 G06N(한국)            513.00    12,081.00 23.55   42.05             60.38   \n",
       "특허 G06N(5개국)        11,236.00   224,600.00 19.99   39.49             48.67   \n",
       "논문 AI(OpenAlex 전체) 587,875.00 1,344,532.00  2.29    9.63              5.67   \n",
       "논문 AI(OpenAlex 한국)  11,173.00    19,908.00  1.78    6.63              7.26   \n",
       "논문 AI·ML(PubMed)     6,478.00    38,072.00  5.88   21.75             24.30   \n",
       "뉴스 AI(영문)           24,403.00   949,803.00 38.92   50.21             39.56   \n",
       "\n",
       "                    2022–2024 연평균(%)  \n",
       "지표                                    \n",
       "특허 G06N(한국)                    -7.11  \n",
       "특허 G06N(5개국)                   11.59  \n",
       "논문 AI(OpenAlex 전체)             24.70  \n",
       "논문 AI(OpenAlex 한국)              4.46  \n",
       "논문 AI·ML(PubMed)               13.24  \n",
       "뉴스 AI(영문)                      94.27  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "series = {\"특허 G06N(한국)\": pat[\"KR_G06N\"], \"특허 G06N(5개국)\": pat[\"5개국_G06N\"],\n",
    "          \"논문 AI(OpenAlex 전체)\": oa[\"AI_개념_전체\"], \"논문 AI(OpenAlex 한국)\": oa[\"AI_개념_한국\"],\n",
    "          \"논문 AI·ML(PubMed)\": pm, \"뉴스 AI(영문)\": er_y}\n",
    "rows = []\n",
    "for k, s in series.items():\n",
    "    pre, post = L.acceleration(s, C.BREAK, C.Y0, C.Y1)\n",
    "    rows.append({\"지표\": k, f\"{C.Y0}\": s.loc[C.Y0], f\"{C.Y1}\": s.loc[C.Y1], \"배수\": L.growth_multiple(s, C.Y0, C.Y1),\n",
    "                 \"연평균(%)\": L.cagr(s, C.Y0, C.Y1), f\"{C.Y0}–{C.BREAK} 연평균(%)\": pre, f\"{C.BREAK}–{C.Y1} 연평균(%)\": post})\n",
    "growth = pd.DataFrame(rows).set_index(\"지표\")\n",
    "growth.to_csv(os.path.join(C.OUTPUT, \"growth_summary.csv\"), encoding=\"utf-8-sig\")\n",
    "growth"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "54157f7a",
   "metadata": {},
   "source": [
    "생성형 AI 논문은 2015년 값이 매우 작아 배수가 의미 없으므로 2022년을 기준으로 따로 본다."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "06e74005",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-07T19:42:42.899709Z",
     "iopub.status.busy": "2026-10-07T19:42:42.899709Z",
     "iopub.status.idle": "2026-10-07T19:42:42.903287Z",
     "shell.execute_reply": "2026-10-07T19:42:42.902781Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "생성형 AI·LLM 논문: 2022년 1,071편 → 2024년 57,411편(54배)\n",
      "영문 AI 뉴스: 2022년 25.2만 건 → 2024년 95.0만 건(3.8배)\n"
     ]
    }
   ],
   "source": [
    "gen = oa[\"생성형AI_LLM\"]\n",
    "print(f\"생성형 AI·LLM 논문: 2022년 {gen.loc[2022]:,}편 → 2024년 {gen.loc[2024]:,}편({gen.loc[2024] / gen.loc[2022]:.0f}배)\")\n",
    "print(f\"영문 AI 뉴스: 2022년 {er_y.loc[2022] / 1e4:.1f}만 건 → 2024년 {er_y.loc[2024] / 1e4:.1f}만 건({er_y.loc[2024] / er_y.loc[2022]:.1f}배)\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d16abf20",
   "metadata": {},
   "source": [
    "## 2. 국가 비중(G06N 출원, 2010–2025 누계)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4feaa9e9",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-07T19:42:42.904285Z",
     "iopub.status.busy": "2026-10-07T19:42:42.904285Z",
     "iopub.status.idle": "2026-10-07T19:42:42.925578Z",
     "shell.execute_reply": "2026-10-07T19:42:42.909540Z"
    }
   },
   "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 th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>비중(%)</th>\n",
       "      <th>건수</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>국가</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>CN</th>\n",
       "      <td>67.31</td>\n",
       "      <td>948774</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>US</th>\n",
       "      <td>18.51</td>\n",
       "      <td>260945</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>KR</th>\n",
       "      <td>6.18</td>\n",
       "      <td>87064</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>JP</th>\n",
       "      <td>4.13</td>\n",
       "      <td>58155</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>EP</th>\n",
       "      <td>3.88</td>\n",
       "      <td>54705</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    비중(%)      건수\n",
       "국가               \n",
       "CN  67.31  948774\n",
       "US  18.51  260945\n",
       "KR   6.18   87064\n",
       "JP   4.13   58155\n",
       "EP   3.88   54705"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "share = (100 * cty / cty.sum()).rename(\"비중(%)\").to_frame()\n",
    "share[\"건수\"] = cty\n",
    "share.to_csv(os.path.join(C.OUTPUT, \"patent_country_share.csv\"), encoding=\"utf-8-sig\")\n",
    "share"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3b3a10e7",
   "metadata": {},
   "source": [
    "## 3. AI 특허의 산업 결합 — 한국 G06N 출원의 동시분류\n",
    "\n",
    "한 특허에 붙은 다른 분류는 AI가 적용된 분야를 나타낸다. 컴퓨팅(G06F) 다음으로 경영·상거래(G06Q), 영상(G06T·G06V), 의료(G16H·A61B), 공정 제어(G05B), 주행 제어(B60W)가 이어진다."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "cb154ea2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-10-07T19:42:42.926575Z",
     "iopub.status.busy": "2026-10-07T19:42:42.926575Z",
     "iopub.status.idle": "2026-10-07T19:42:42.933587Z",
     "shell.execute_reply": "2026-10-07T19:42:42.933587Z"
    }
   },
   "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 th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>건수</th>\n",
       "      <th>G06N 대비(%)</th>\n",
       "      <th>대응 분야</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>IPC</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>G06F</th>\n",
       "      <td>30990</td>\n",
       "      <td>35.59</td>\n",
       "      <td>정보통신(컴퓨팅)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G06Q</th>\n",
       "      <td>21827</td>\n",
       "      <td>25.07</td>\n",
       "      <td>금융·도소매·사업서비스(경영·상거래)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G06T</th>\n",
       "      <td>17593</td>\n",
       "      <td>20.21</td>\n",
       "      <td>정보통신(영상처리)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G06V</th>\n",
       "      <td>15062</td>\n",
       "      <td>17.30</td>\n",
       "      <td>정보통신(영상인식)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H04N</th>\n",
       "      <td>6766</td>\n",
       "      <td>7.77</td>\n",
       "      <td>통신·방송(영상통신)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G16H</th>\n",
       "      <td>6536</td>\n",
       "      <td>7.51</td>\n",
       "      <td>보건(의료정보)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H04L</th>\n",
       "      <td>6061</td>\n",
       "      <td>6.96</td>\n",
       "      <td>통신(데이터 전송)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>A61B</th>\n",
       "      <td>4968</td>\n",
       "      <td>5.71</td>\n",
       "      <td>보건(진단·의료기기)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G06K</th>\n",
       "      <td>4185</td>\n",
       "      <td>4.81</td>\n",
       "      <td>정보통신(인식·데이터 처리)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G10L</th>\n",
       "      <td>3876</td>\n",
       "      <td>4.45</td>\n",
       "      <td>정보통신(음성)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G01N</th>\n",
       "      <td>3779</td>\n",
       "      <td>4.34</td>\n",
       "      <td>화학·정밀(물질 분석)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H04W</th>\n",
       "      <td>3120</td>\n",
       "      <td>3.58</td>\n",
       "      <td>통신(무선망)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G05B</th>\n",
       "      <td>2896</td>\n",
       "      <td>3.33</td>\n",
       "      <td>기계·제조(공정 제어)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G08B</th>\n",
       "      <td>2884</td>\n",
       "      <td>3.31</td>\n",
       "      <td>사업서비스(경보·보안)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G01S</th>\n",
       "      <td>2033</td>\n",
       "      <td>2.34</td>\n",
       "      <td>정밀기기(측위·레이더)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B60W</th>\n",
       "      <td>1851</td>\n",
       "      <td>2.13</td>\n",
       "      <td>자동차(주행 제어)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G01R</th>\n",
       "      <td>1801</td>\n",
       "      <td>2.07</td>\n",
       "      <td>전기·정밀(전기 측정)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G05D</th>\n",
       "      <td>1313</td>\n",
       "      <td>1.51</td>\n",
       "      <td>기계(위치·자율 제어)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G08G</th>\n",
       "      <td>1298</td>\n",
       "      <td>1.49</td>\n",
       "      <td>운수(교통 제어)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         건수  G06N 대비(%)                 대응 분야\n",
       "IPC                                          \n",
       "G06F  30990       35.59             정보통신(컴퓨팅)\n",
       "G06Q  21827       25.07  금융·도소매·사업서비스(경영·상거래)\n",
       "G06T  17593       20.21            정보통신(영상처리)\n",
       "G06V  15062       17.30            정보통신(영상인식)\n",
       "H04N   6766        7.77           통신·방송(영상통신)\n",
       "G16H   6536        7.51              보건(의료정보)\n",
       "H04L   6061        6.96            통신(데이터 전송)\n",
       "A61B   4968        5.71           보건(진단·의료기기)\n",
       "G06K   4185        4.81       정보통신(인식·데이터 처리)\n",
       "G10L   3876        4.45              정보통신(음성)\n",
       "G01N   3779        4.34          화학·정밀(물질 분석)\n",
       "H04W   3120        3.58               통신(무선망)\n",
       "G05B   2896        3.33          기계·제조(공정 제어)\n",
       "G08B   2884        3.31          사업서비스(경보·보안)\n",
       "G01S   2033        2.34          정밀기기(측위·레이더)\n",
       "B60W   1851        2.13            자동차(주행 제어)\n",
       "G01R   1801        2.07          전기·정밀(전기 측정)\n",
       "G05D   1313        1.51          기계(위치·자율 제어)\n",
       "G08G   1298        1.49             운수(교통 제어)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "co = coipc.drop(\"G06N\").rename(\"건수\").to_frame()\n",
    "co[\"G06N 대비(%)\"] = 100 * co[\"건수\"] / coipc.loc[\"G06N\"]\n",
    "co[\"대응 분야\"] = [L.IPC_INDUSTRY.get(k, \"\") for k in co.index]\n",
    "co.to_csv(os.path.join(C.OUTPUT, \"patent_coipc_industry.csv\"), encoding=\"utf-8-sig\")\n",
    "co"
   ]
  }
 ],
 "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.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
