{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":59575,"databundleVersionId":8060720,"sourceType":"competition"}],"dockerImageVersionId":30732,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"from tqdm import tqdm\nimport numpy as np\nimport pandas as pd\nimport gc\n\nmeta_df = pd.read_parquet(\"/kaggle/input/uspto-explainable-ai/patent_metadata.parquet\")","metadata":{"execution":{"iopub.status.busy":"2024-06-11T18:09:23.536582Z","iopub.execute_input":"2024-06-11T18:09:23.537060Z","iopub.status.idle":"2024-06-11T18:09:56.594354Z","shell.execute_reply.started":"2024-06-11T18:09:23.537026Z","shell.execute_reply":"2024-06-11T18:09:56.593233Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2024-06-11T18:17:21.078288Z","iopub.execute_input":"2024-06-11T18:17:21.078739Z","iopub.status.idle":"2024-06-11T18:17:21.087089Z","shell.execute_reply.started":"2024-06-11T18:17:21.078697Z","shell.execute_reply":"2024-06-11T18:17:21.084221Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"meta_df['publication_date'] = pd.to_datetime(meta_df['publication_date'], errors='coerce')\nmeta_df['Year'] = meta_df['publication_date'].dt.year\nmeta_df","metadata":{"execution":{"iopub.status.busy":"2024-06-11T18:09:56.596550Z","iopub.execute_input":"2024-06-11T18:09:56.597120Z","iopub.status.idle":"2024-06-11T18:09:57.731616Z","shell.execute_reply.started":"2024-06-11T18:09:56.597085Z","shell.execute_reply":"2024-06-11T18:09:57.730295Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# อันนี้เป็นดาต้าที่มาจาก \nGoogle Patents Public Data by IFI CLAIMS Patent Services and Google\nแต่ส่วนตัวคิดว่าไม่ได้น่าสนใจเท่าไร","metadata":{}},{"cell_type":"code","source":"patent_data_file = \"/kaggle/input/uspto-explainable-ai/patent_data/1838_4.parquet\"\npatent_data_sample = pd.read_parquet(patent_data_file)","metadata":{"execution":{"iopub.status.busy":"2024-06-11T18:09:57.733217Z","iopub.execute_input":"2024-06-11T18:09:57.733580Z","iopub.status.idle":"2024-06-11T18:09:57.757367Z","shell.execute_reply.started":"2024-06-11T18:09:57.733548Z","shell.execute_reply":"2024-06-11T18:09:57.755899Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"patent_data_sample","metadata":{"execution":{"iopub.status.busy":"2024-06-11T18:09:57.759203Z","iopub.execute_input":"2024-06-11T18:09:57.759703Z","iopub.status.idle":"2024-06-11T18:09:57.786944Z","shell.execute_reply.started":"2024-06-11T18:09:57.759656Z","shell.execute_reply":"2024-06-11T18:09:57.785564Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# นับค่า Unique ในแต่ละ Col\nที่เห็นคือ จากจำนวน patent 13307751 มี family ที่ต่างกันถึง 13273553 แปลว่ามีที่ซ้ำกันแค่ประมาณ3-4หมื่น","metadata":{}},{"cell_type":"code","source":"for col in meta_df.columns:\n    try:\n        print(f\"Total unique values of column {col} : {meta_df[col].nunique()}\")\n    except:\n        print(f\"Can't find unique values of column {col}\")","metadata":{"execution":{"iopub.status.busy":"2024-06-11T18:09:57.789615Z","iopub.execute_input":"2024-06-11T18:09:57.790033Z","iopub.status.idle":"2024-06-11T18:10:17.641317Z","shell.execute_reply.started":"2024-06-11T18:09:57.789991Z","shell.execute_reply":"2024-06-11T18:10:17.639852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# กราฟโชว์การเติบโตของการจดสิทธิบัตร","metadata":{}},{"cell_type":"code","source":"patent_count = meta_df.groupby('Year').size().reset_index(name='patent_count')\npatent_count","metadata":{"execution":{"iopub.status.busy":"2024-06-11T18:19:30.569530Z","iopub.execute_input":"2024-06-11T18:19:30.569984Z","iopub.status.idle":"2024-06-11T18:19:30.953898Z","shell.execute_reply.started":"2024-06-11T18:19:30.569951Z","shell.execute_reply":"2024-06-11T18:19:30.952725Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(15,12))\nplt.plot(patent_count['Year'], patent_count['patent_count'], marker='o')\n\nplt.title('Growth of number of patent')\nplt.xlabel('Year')\nplt.ylabel('Number of patent')\nplt.grid(True)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-06-11T18:25:08.962954Z","iopub.execute_input":"2024-06-11T18:25:08.963394Z","iopub.status.idle":"2024-06-11T18:25:09.317044Z","shell.execute_reply.started":"2024-06-11T18:25:08.963361Z","shell.execute_reply":"2024-06-11T18:25:09.315394Z"},"trusted":true},"execution_count":null,"outputs":[]}]}