diff --git a/README.md b/README.md index 9bd633e..8e4b242 100644 --- a/README.md +++ b/README.md @@ -29,4 +29,4 @@ https://www.kaggle.com/datasets/lakritidis/product-classification-and-categoriza https://medium.com/analytics-vidhya/classification-using-long-short-term-memory-glove-global-vectors-for-word-representation-254d02d5e158 -test \ No newline at end of file +https://www.kaggle.com/code/leekahwin/text-classification-using-n-gram-0-8-f1 \ No newline at end of file diff --git a/fetchDatafromDb/Multiclasstextclasification.ipynb b/fetchDatafromDb/Multiclasstextclasification.ipynb index 413b5fb..81bfa8e 100644 --- a/fetchDatafromDb/Multiclasstextclasification.ipynb +++ b/fetchDatafromDb/Multiclasstextclasification.ipynb @@ -43,7 +43,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -57,7 +57,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -66,7 +66,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -90,7 +90,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -154,13 +154,14 @@ " for i in range (0,9-len(list_row)):\n", " list_row.append(np.nan)\n", "\n", - " df_eng.loc[len(df_eng)] = list_row\n", + " df_eng=df_eng.append(pd.Series(list_row, index=df_eng.columns[:len(list_row)],ignore_index=True))\n", + " # df_eng.loc[len(df_eng)] = list_row\n", "\n" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -283,7 +284,7 @@ "4 wheel suspension track control arm NaN NaN " ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -294,7 +295,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -303,7 +304,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -323,7 +324,7 @@ "Name: name, Length: 492, dtype: object" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -335,7 +336,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -375,7 +376,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -384,7 +385,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -418,7 +419,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -433,7 +434,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -442,7 +443,7 @@ "torch.Size([33, 1, 67])" ] }, - "execution_count": 21, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -487,7 +488,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -523,7 +524,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -535,14 +536,14 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "output size = torch.Size([1, 9])\n", + "output size = torch.Size([1, 17])\n", "next_hidden size = torch.Size([1, 256])\n" ] } @@ -560,7 +561,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -573,15 +574,25 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(next_hidden)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "tensor([[-2.2812, -2.2042, -2.2270, -2.1712, -2.1616, -2.1168, -2.2543, -2.1659,\n", - " -2.2031]], grad_fn=)\n" + "tensor([[-2.8616, -2.7816, -2.8194, -2.8661, -2.8955, -2.8495, -2.8488, -2.8467,\n", + " -2.9117, -2.7902, -2.8215, -2.7953, -2.8066, -2.7708, -2.8125, -2.8050,\n", + " -2.8961]], grad_fn=)\n" ] } ], @@ -591,7 +602,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -606,14 +617,14 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "('tensioner pulley', 5)\n" + "('air mass sensor', 13)\n" ] } ], @@ -631,7 +642,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -655,23 +666,23 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "category = air supply , name = mahle original lx 923 air filter\n", + "category = accessory kit , name = mapco 9167 accessory kit brake shoes\n", + "category = air 47 electric horn , name = vemo v30 77 0150 1 air electric horn\n", "category = adjust screw , name = adjust screw headlight\n", - "category = air horn , name = vemo v10 77 0911 1 air horn\n", - "category = air horn , name = vemo v10 77 0911 1 air horn\n", - "category = air 47 electric horn , name = vemo v10 77 0918 1 air electric horn\n", - "category = adapter cable , name = hella 8ja 005 952 101 adapter cable towbar socket\n", - "category = air 47 electric horn , name = vemo v10 77 0918 1 air electric horn\n", - "category = accelerator cable , name = vaico v10 2459 accelerator cable\n", - "category = air quality sensor , name = vemo v95 72 0098 air quality sensor\n", - "category = additional water pump , name = vemo v70 16 0002 additional water pump\n" + "category = accelerator cable , name = vaico v24 0376 accelerator cable\n", + "category = air conditioning , name = mahle original ad 114 000s dryer air conditioning\n", + "category = aerial head , name = vemo v25 22 0001 aerial head\n", + "category = air 47 electric horn , name = vemo v30 77 0150 1 air electric horn\n", + "category = air conditioning , name = mahle original acp 1234 000p compressor air conditioning\n", + "category = accessory kit , name = accessory kit disc brake pads\n", + "category = aerial , name = vemo v10 22 0001 aerial\n" ] } ], @@ -692,7 +703,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ @@ -718,7 +729,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -750,7 +761,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 26, "metadata": {}, "outputs": [], "source": [ @@ -762,14 +773,14 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "/tmp/ipykernel_2589/665512115.py:14: UserWarning: This overload of add_ is deprecated:\n", + "/tmp/ipykernel_2627/665512115.py:14: UserWarning: This overload of add_ is deprecated:\n", "\tadd_(Number alpha, Tensor other)\n", "Consider using one of the following signatures instead:\n", "\tadd_(Tensor other, *, Number alpha) (Triggered internally at ../torch/csrc/utils/python_arg_parser.cpp:1485.)\n", @@ -780,58 +791,43 @@ "name": "stdout", "output_type": "stream", "text": [ - "5000 2% nan vemo v95 72 0098 air quality sensor / air conditioning ✗ (air quality sensor)\n", - "10000 5% nan valeo 585051 air filter / air conditioning ✗ (air filter)\n", - "15000 7% nan vemo v70 16 0002 additional water pump / air conditioning ✗ (additional water pump)\n", - "20000 10% nan adaptor cigarette lighter / air conditioning ✗ (adaptor)\n", - "25000 12% nan vemo v10 77 0917 1 air electric horn / air conditioning ✗ (air 47 electric horn)\n", - "30000 15% nan vaico v52 0075 air filter / air conditioning ✗ (air filter)\n", - "35000 17% nan hella 8ja 005 952 101 adapter cable towbar socket / air conditioning ✗ (adapter cable)\n", - "40000 20% nan vemo v10 77 0912 1 air horn / air conditioning ✗ (air horn)\n", - "45000 22% nan vemo v70 16 0002 additional water pump / air conditioning ✗ (additional water pump)\n", - "50000 25% nan adjust screw headlight / air conditioning ✗ (adjust screw)\n", - "55000 27% nan vaico v24 0376 accelerator cable / air conditioning ✗ (accelerator cable)\n", - "60000 30% nan hella 8ja 005 952 101 adapter cable towbar socket / air conditioning ✗ (adapter cable)\n", - "65000 32% nan accessory kit disc brake pads / air conditioning ✗ (accessory kit)\n", - "70000 35% nan adaptor cigarette lighter / air conditioning ✗ (adaptor)\n", - "75000 37% nan vemo v95 72 0098 air quality sensor / air conditioning ✗ (air quality sensor)\n", - "80000 40% nan accessory kit brake caliper / air conditioning ✗ (accessory kit)\n", - "85000 42% nan vemo v24 72 0002 air mass sensor / air conditioning ✗ (air mass sensor)\n", - "90000 45% nan hella 8ja 005 952 041 adapter cable towbar socket / air conditioning ✗ (adapter cable)\n", - "95000 47% nan accessory kit disc brake pads / air conditioning ✗ (accessory kit)\n", - "100000 50% nan aks dasis 853130n compressor air conditioning / air conditioning ✓\n", - "105000 52% nan vemo v25 22 0001 aerial head / air conditioning ✗ (aerial head)\n", - "110000 55% nan vemo v10 77 0917 1 air electric horn / air conditioning ✗ (air 47 electric horn)\n", - "115000 57% nan vemo v10 77 0912 1 air horn / air conditioning ✗ (air horn)\n", - "120000 60% nan accessory kit disc brake pads / air conditioning ✗ (accessory kit)\n", - "125000 62% nan vemo v10 77 0918 1 air electric horn / air conditioning ✗ (air 47 electric horn)\n", - "130000 65% nan vemo v25 22 0002 aerial / air conditioning ✗ (aerial)\n", - "135000 67% nan accessory kit disc brake pads / air conditioning ✗ (accessory kit)\n", - "140000 70% nan vemo v10 22 0001 aerial / air conditioning ✗ (aerial)\n", - "145000 72% nan vaico v10 2459 accelerator cable / air conditioning ✗ (accelerator cable)\n", - "150000 75% nan vemo v10 77 0912 1 air horn / air conditioning ✗ (air horn)\n" - ] - }, - { - "ename": "KeyboardInterrupt", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[21], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[39mfor\u001b[39;00m epoch \u001b[39min\u001b[39;00m \u001b[39mrange\u001b[39m(\u001b[39m1\u001b[39m, n_iters \u001b[39m+\u001b[39m \u001b[39m1\u001b[39m):\n\u001b[0;32m----> 3\u001b[0m category, name, category_tensor, name_tensor \u001b[39m=\u001b[39m randomTrainingExample()\n\u001b[1;32m 5\u001b[0m output, loss \u001b[39m=\u001b[39m train(category_tensor, name_tensor)\n\u001b[1;32m 6\u001b[0m current_loss \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m loss\n", - "Cell \u001b[0;32mIn[16], line 9\u001b[0m, in \u001b[0;36mrandomTrainingExample\u001b[0;34m()\u001b[0m\n\u001b[1;32m 6\u001b[0m randcategory \u001b[39m=\u001b[39m all_categories[random_cat_index]\n\u001b[1;32m 8\u001b[0m \u001b[39m# get feature name from the category\u001b[39;00m\n\u001b[0;32m----> 9\u001b[0m random_feature_names \u001b[39m=\u001b[39m df_category\u001b[39m.\u001b[39;49mget_group(randcategory)[\u001b[39m'\u001b[39m\u001b[39mname\u001b[39m\u001b[39m'\u001b[39m]\n\u001b[1;32m 11\u001b[0m name \u001b[39m=\u001b[39m random_feature_names\u001b[39m.\u001b[39marray[random\u001b[39m.\u001b[39mrandint(\u001b[39m0\u001b[39m, \u001b[39mlen\u001b[39m(random_feature_names) \u001b[39m-\u001b[39m \u001b[39m1\u001b[39m)]\n\u001b[1;32m 13\u001b[0m category_tensor \u001b[39m=\u001b[39m torch\u001b[39m.\u001b[39mtensor([all_categories\u001b[39m.\u001b[39mindex(randcategory)], dtype\u001b[39m=\u001b[39mtorch\u001b[39m.\u001b[39mlong)\n", - "File \u001b[0;32m~/dev/.venv/lib/python3.10/site-packages/pandas/core/groupby/groupby.py:802\u001b[0m, in \u001b[0;36mBaseGroupBy.get_group\u001b[0;34m(self, name, obj)\u001b[0m\n\u001b[1;32m 799\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mlen\u001b[39m(inds):\n\u001b[1;32m 800\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mKeyError\u001b[39;00m(name)\n\u001b[0;32m--> 802\u001b[0m \u001b[39mreturn\u001b[39;00m obj\u001b[39m.\u001b[39;49m_take_with_is_copy(inds, axis\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49maxis)\n", - "File \u001b[0;32m~/dev/.venv/lib/python3.10/site-packages/pandas/core/generic.py:3948\u001b[0m, in \u001b[0;36mNDFrame._take_with_is_copy\u001b[0;34m(self, indices, axis)\u001b[0m\n\u001b[1;32m 3940\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m_take_with_is_copy\u001b[39m(\u001b[39mself\u001b[39m: NDFrameT, indices, axis: Axis \u001b[39m=\u001b[39m \u001b[39m0\u001b[39m) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m NDFrameT:\n\u001b[1;32m 3941\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 3942\u001b[0m \u001b[39m Internal version of the `take` method that sets the `_is_copy`\u001b[39;00m\n\u001b[1;32m 3943\u001b[0m \u001b[39m attribute to keep track of the parent dataframe (using in indexing\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 3946\u001b[0m \u001b[39m See the docstring of `take` for full explanation of the parameters.\u001b[39;00m\n\u001b[1;32m 3947\u001b[0m \u001b[39m \"\"\"\u001b[39;00m\n\u001b[0;32m-> 3948\u001b[0m result \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_take(indices\u001b[39m=\u001b[39;49mindices, axis\u001b[39m=\u001b[39;49maxis)\n\u001b[1;32m 3949\u001b[0m \u001b[39m# Maybe set copy if we didn't actually change the index.\u001b[39;00m\n\u001b[1;32m 3950\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m result\u001b[39m.\u001b[39m_get_axis(axis)\u001b[39m.\u001b[39mequals(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_get_axis(axis)):\n", - "File \u001b[0;32m~/dev/.venv/lib/python3.10/site-packages/pandas/core/generic.py:3932\u001b[0m, in \u001b[0;36mNDFrame._take\u001b[0;34m(self, indices, axis, convert_indices)\u001b[0m\n\u001b[1;32m 3924\u001b[0m \u001b[39mif\u001b[39;00m (\n\u001b[1;32m 3925\u001b[0m axis \u001b[39m==\u001b[39m \u001b[39m0\u001b[39m\n\u001b[1;32m 3926\u001b[0m \u001b[39mand\u001b[39;00m indices\u001b[39m.\u001b[39mndim \u001b[39m==\u001b[39m \u001b[39m1\u001b[39m\n\u001b[1;32m 3927\u001b[0m \u001b[39mand\u001b[39;00m using_copy_on_write()\n\u001b[1;32m 3928\u001b[0m \u001b[39mand\u001b[39;00m is_range_indexer(indices, \u001b[39mlen\u001b[39m(\u001b[39mself\u001b[39m))\n\u001b[1;32m 3929\u001b[0m ):\n\u001b[1;32m 3930\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mcopy(deep\u001b[39m=\u001b[39m\u001b[39mNone\u001b[39;00m)\n\u001b[0;32m-> 3932\u001b[0m new_data \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_mgr\u001b[39m.\u001b[39;49mtake(\n\u001b[1;32m 3933\u001b[0m indices,\n\u001b[1;32m 3934\u001b[0m axis\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_get_block_manager_axis(axis),\n\u001b[1;32m 3935\u001b[0m verify\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m,\n\u001b[1;32m 3936\u001b[0m convert_indices\u001b[39m=\u001b[39;49mconvert_indices,\n\u001b[1;32m 3937\u001b[0m )\n\u001b[1;32m 3938\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_constructor(new_data)\u001b[39m.\u001b[39m__finalize__(\u001b[39mself\u001b[39m, method\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mtake\u001b[39m\u001b[39m\"\u001b[39m)\n", - "File \u001b[0;32m~/dev/.venv/lib/python3.10/site-packages/pandas/core/internals/managers.py:963\u001b[0m, in \u001b[0;36mBaseBlockManager.take\u001b[0;34m(self, indexer, axis, verify, convert_indices)\u001b[0m\n\u001b[1;32m 960\u001b[0m indexer \u001b[39m=\u001b[39m maybe_convert_indices(indexer, n, verify\u001b[39m=\u001b[39mverify)\n\u001b[1;32m 962\u001b[0m new_labels \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39maxes[axis]\u001b[39m.\u001b[39mtake(indexer)\n\u001b[0;32m--> 963\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mreindex_indexer(\n\u001b[1;32m 964\u001b[0m new_axis\u001b[39m=\u001b[39;49mnew_labels,\n\u001b[1;32m 965\u001b[0m indexer\u001b[39m=\u001b[39;49mindexer,\n\u001b[1;32m 966\u001b[0m axis\u001b[39m=\u001b[39;49maxis,\n\u001b[1;32m 967\u001b[0m allow_dups\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m,\n\u001b[1;32m 968\u001b[0m copy\u001b[39m=\u001b[39;49m\u001b[39mNone\u001b[39;49;00m,\n\u001b[1;32m 969\u001b[0m )\n", - "File \u001b[0;32m~/dev/.venv/lib/python3.10/site-packages/pandas/core/internals/managers.py:747\u001b[0m, in \u001b[0;36mBaseBlockManager.reindex_indexer\u001b[0;34m(self, new_axis, indexer, axis, fill_value, allow_dups, copy, only_slice, use_na_proxy)\u001b[0m\n\u001b[1;32m 740\u001b[0m new_blocks \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_slice_take_blocks_ax0(\n\u001b[1;32m 741\u001b[0m indexer,\n\u001b[1;32m 742\u001b[0m fill_value\u001b[39m=\u001b[39mfill_value,\n\u001b[1;32m 743\u001b[0m only_slice\u001b[39m=\u001b[39monly_slice,\n\u001b[1;32m 744\u001b[0m use_na_proxy\u001b[39m=\u001b[39muse_na_proxy,\n\u001b[1;32m 745\u001b[0m )\n\u001b[1;32m 746\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m--> 747\u001b[0m new_blocks \u001b[39m=\u001b[39m [\n\u001b[1;32m 748\u001b[0m blk\u001b[39m.\u001b[39mtake_nd(\n\u001b[1;32m 749\u001b[0m indexer,\n\u001b[1;32m 750\u001b[0m axis\u001b[39m=\u001b[39m\u001b[39m1\u001b[39m,\n\u001b[1;32m 751\u001b[0m fill_value\u001b[39m=\u001b[39m(\n\u001b[1;32m 752\u001b[0m fill_value \u001b[39mif\u001b[39;00m fill_value \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39melse\u001b[39;00m blk\u001b[39m.\u001b[39mfill_value\n\u001b[1;32m 753\u001b[0m ),\n\u001b[1;32m 754\u001b[0m )\n\u001b[1;32m 755\u001b[0m \u001b[39mfor\u001b[39;00m blk \u001b[39min\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mblocks\n\u001b[1;32m 756\u001b[0m ]\n\u001b[1;32m 758\u001b[0m new_axes \u001b[39m=\u001b[39m \u001b[39mlist\u001b[39m(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39maxes)\n\u001b[1;32m 759\u001b[0m new_axes[axis] \u001b[39m=\u001b[39m new_axis\n", - "File \u001b[0;32m~/dev/.venv/lib/python3.10/site-packages/pandas/core/internals/managers.py:748\u001b[0m, in \u001b[0;36m\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 740\u001b[0m new_blocks \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_slice_take_blocks_ax0(\n\u001b[1;32m 741\u001b[0m indexer,\n\u001b[1;32m 742\u001b[0m fill_value\u001b[39m=\u001b[39mfill_value,\n\u001b[1;32m 743\u001b[0m only_slice\u001b[39m=\u001b[39monly_slice,\n\u001b[1;32m 744\u001b[0m use_na_proxy\u001b[39m=\u001b[39muse_na_proxy,\n\u001b[1;32m 745\u001b[0m )\n\u001b[1;32m 746\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 747\u001b[0m new_blocks \u001b[39m=\u001b[39m [\n\u001b[0;32m--> 748\u001b[0m blk\u001b[39m.\u001b[39;49mtake_nd(\n\u001b[1;32m 749\u001b[0m indexer,\n\u001b[1;32m 750\u001b[0m axis\u001b[39m=\u001b[39;49m\u001b[39m1\u001b[39;49m,\n\u001b[1;32m 751\u001b[0m fill_value\u001b[39m=\u001b[39;49m(\n\u001b[1;32m 752\u001b[0m fill_value \u001b[39mif\u001b[39;49;00m fill_value \u001b[39mis\u001b[39;49;00m \u001b[39mnot\u001b[39;49;00m \u001b[39mNone\u001b[39;49;00m \u001b[39melse\u001b[39;49;00m blk\u001b[39m.\u001b[39;49mfill_value\n\u001b[1;32m 753\u001b[0m ),\n\u001b[1;32m 754\u001b[0m )\n\u001b[1;32m 755\u001b[0m \u001b[39mfor\u001b[39;00m blk \u001b[39min\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mblocks\n\u001b[1;32m 756\u001b[0m ]\n\u001b[1;32m 758\u001b[0m new_axes \u001b[39m=\u001b[39m \u001b[39mlist\u001b[39m(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39maxes)\n\u001b[1;32m 759\u001b[0m new_axes[axis] \u001b[39m=\u001b[39m new_axis\n", - "File \u001b[0;32m~/dev/.venv/lib/python3.10/site-packages/pandas/core/internals/blocks.py:945\u001b[0m, in \u001b[0;36mBlock.take_nd\u001b[0;34m(self, indexer, axis, new_mgr_locs, fill_value)\u001b[0m\n\u001b[1;32m 942\u001b[0m allow_fill \u001b[39m=\u001b[39m \u001b[39mTrue\u001b[39;00m\n\u001b[1;32m 944\u001b[0m \u001b[39m# Note: algos.take_nd has upcast logic similar to coerce_to_target_dtype\u001b[39;00m\n\u001b[0;32m--> 945\u001b[0m new_values \u001b[39m=\u001b[39m algos\u001b[39m.\u001b[39;49mtake_nd(\n\u001b[1;32m 946\u001b[0m values, indexer, axis\u001b[39m=\u001b[39;49maxis, allow_fill\u001b[39m=\u001b[39;49mallow_fill, fill_value\u001b[39m=\u001b[39;49mfill_value\n\u001b[1;32m 947\u001b[0m )\n\u001b[1;32m 949\u001b[0m \u001b[39m# Called from three places in managers, all of which satisfy\u001b[39;00m\n\u001b[1;32m 950\u001b[0m \u001b[39m# these assertions\u001b[39;00m\n\u001b[1;32m 951\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(\u001b[39mself\u001b[39m, ExtensionBlock):\n\u001b[1;32m 952\u001b[0m \u001b[39m# NB: in this case, the 'axis' kwarg will be ignored in the\u001b[39;00m\n\u001b[1;32m 953\u001b[0m \u001b[39m# algos.take_nd call above.\u001b[39;00m\n", - "File \u001b[0;32m~/dev/.venv/lib/python3.10/site-packages/pandas/core/array_algos/take.py:117\u001b[0m, in \u001b[0;36mtake_nd\u001b[0;34m(arr, indexer, axis, fill_value, allow_fill)\u001b[0m\n\u001b[1;32m 114\u001b[0m \u001b[39mreturn\u001b[39;00m arr\u001b[39m.\u001b[39mtake(indexer, fill_value\u001b[39m=\u001b[39mfill_value, allow_fill\u001b[39m=\u001b[39mallow_fill)\n\u001b[1;32m 116\u001b[0m arr \u001b[39m=\u001b[39m np\u001b[39m.\u001b[39masarray(arr)\n\u001b[0;32m--> 117\u001b[0m \u001b[39mreturn\u001b[39;00m _take_nd_ndarray(arr, indexer, axis, fill_value, allow_fill)\n", - "File \u001b[0;32m~/dev/.venv/lib/python3.10/site-packages/pandas/core/array_algos/take.py:159\u001b[0m, in \u001b[0;36m_take_nd_ndarray\u001b[0;34m(arr, indexer, axis, fill_value, allow_fill)\u001b[0m\n\u001b[1;32m 156\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 157\u001b[0m out \u001b[39m=\u001b[39m np\u001b[39m.\u001b[39mempty(out_shape, dtype\u001b[39m=\u001b[39mdtype)\n\u001b[0;32m--> 159\u001b[0m func \u001b[39m=\u001b[39m _get_take_nd_function(\n\u001b[1;32m 160\u001b[0m arr\u001b[39m.\u001b[39;49mndim, arr\u001b[39m.\u001b[39;49mdtype, out\u001b[39m.\u001b[39;49mdtype, axis\u001b[39m=\u001b[39;49maxis, mask_info\u001b[39m=\u001b[39;49mmask_info\n\u001b[1;32m 161\u001b[0m )\n\u001b[1;32m 162\u001b[0m func(arr, indexer, out, fill_value)\n\u001b[1;32m 164\u001b[0m \u001b[39mif\u001b[39;00m flip_order:\n", - "File \u001b[0;32m~/dev/.venv/lib/python3.10/site-packages/pandas/core/array_algos/take.py:339\u001b[0m, in \u001b[0;36m_get_take_nd_function\u001b[0;34m(ndim, arr_dtype, out_dtype, axis, mask_info)\u001b[0m\n\u001b[1;32m 336\u001b[0m func \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m 337\u001b[0m \u001b[39mif\u001b[39;00m ndim \u001b[39m<\u001b[39m\u001b[39m=\u001b[39m \u001b[39m2\u001b[39m:\n\u001b[1;32m 338\u001b[0m \u001b[39m# for this part we don't need `mask_info` -> use the cached algo lookup\u001b[39;00m\n\u001b[0;32m--> 339\u001b[0m func \u001b[39m=\u001b[39m _get_take_nd_function_cached(ndim, arr_dtype, out_dtype, axis)\n\u001b[1;32m 341\u001b[0m \u001b[39mif\u001b[39;00m func \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 343\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mfunc\u001b[39m(arr, indexer, out, fill_value\u001b[39m=\u001b[39mnp\u001b[39m.\u001b[39mnan) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m \u001b[39mNone\u001b[39;00m:\n", - "\u001b[0;31mKeyboardInterrupt\u001b[0m: " + "5000 2% nan vemo v10 77 0917 1 air electric horn / air conditioning ✗ (air 47 electric horn)\n", + "10000 5% nan hella 8ja 005 952 041 adapter cable towbar socket / air conditioning ✗ (adapter cable)\n", + "15000 7% nan mahle original acp 873 000p compressor air conditioning / air conditioning ✓\n", + "20000 10% nan aks dasis 850811n compressor air conditioning / air conditioning ✓\n", + "25000 12% nan adaptor cigarette lighter / air conditioning ✗ (adaptor)\n", + "30000 15% nan ngk 92710 air mass sensor / air conditioning ✗ (air mass sensor)\n", + "35000 17% nan vemo v70 16 0002 additional water pump / air conditioning ✗ (additional water pump)\n", + "40000 20% nan ngk 93373 air mass sensor / air conditioning ✗ (air mass sensor)\n", + "45000 22% nan denso dat23001 actuator air conditioning / air conditioning ✗ (actuator)\n", + "50000 25% nan vemo v52 72 0135 sensor intake manifold pressure / air conditioning ✗ (air pressure sensor)\n", + "55000 27% nan adaptor cigarette lighter / air conditioning ✗ (adaptor)\n", + "60000 30% nan adjust screw headlight / air conditioning ✗ (adjust screw)\n", + "65000 32% nan vemo v70 16 0002 additional water pump / air conditioning ✗ (additional water pump)\n", + "70000 35% nan vemo v40 72 0484 air mass sensor / air conditioning ✗ (air mass sensor)\n", + "75000 37% nan adjust screw headlight / air conditioning ✗ (adjust screw)\n", + "80000 40% nan vemo v26 72 0008 sensor intake manifold pressure / air conditioning ✗ (air pressure sensor)\n", + "85000 42% nan vemo v70 16 0002 additional water pump / air conditioning ✗ (additional water pump)\n", + "90000 45% nan vemo v10 77 0911 1 air horn / air conditioning ✗ (air horn)\n", + "95000 47% nan vemo v25 22 0001 aerial head / air conditioning ✗ (aerial head)\n", + "100000 50% nan denso dat23001 actuator air conditioning / air conditioning ✗ (actuator)\n", + "105000 52% nan adjust screw headlight / air conditioning ✗ (adjust screw)\n", + "110000 55% nan aks dasis 042170n condenser air conditioning / air conditioning ✓\n", + "115000 57% nan vemo v20 72 0025 air mass sensor / air conditioning ✗ (air mass sensor)\n", + "120000 60% nan mahle original lx 542 air filter / air conditioning ✗ (air supply)\n", + "125000 62% nan mahle original lx 1266 air filter / air conditioning ✗ (air supply)\n", + "130000 65% nan vemo v30 72 0798 air quality sensor / air conditioning ✗ (air quality sensor)\n", + "135000 67% nan vemo v25 22 0002 aerial / air conditioning ✗ (aerial)\n", + "140000 70% nan vemo v95 72 0098 air quality sensor / air conditioning ✗ (air quality sensor)\n", + "145000 72% nan vemo v10 77 0911 1 air horn / air conditioning ✗ (air horn)\n", + "150000 75% nan vemo v25 22 0002 aerial / air conditioning ✗ (aerial)\n", + "155000 77% nan vemo v70 16 0002 additional water pump / air conditioning ✗ (additional water pump)\n", + "160000 80% nan mahle original lx 144 air filter / air conditioning ✗ (air supply)\n", + "165000 82% nan vemo v10 72 1028 sensor intake manifold pressure / air conditioning ✗ (air pressure sensor)\n", + "170000 85% nan vemo v10 22 0001 aerial / air conditioning ✗ (aerial)\n", + "175000 87% nan vemo v70 16 0002 additional water pump / air conditioning ✗ (additional water pump)\n", + "180000 90% nan vemo v26 72 0008 sensor intake manifold pressure / air conditioning ✗ (air pressure sensor)\n", + "185000 92% nan mahle original lx 494 air filter / air conditioning ✗ (air supply)\n" ] } ], @@ -859,6 +855,12 @@ " current_loss = 0" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, { "cell_type": "code", "execution_count": 68, diff --git a/rm_clasificationmodel/DataFrameClass.py b/rm_clasificationmodel/DataFrameClass.py new file mode 100644 index 0000000..bd9aead --- /dev/null +++ b/rm_clasificationmodel/DataFrameClass.py @@ -0,0 +1,28 @@ +import pandas as pd +class DataFrame: + def __init__(self,es): + self.es = es + + + def create(self): + df_eng = pd.DataFrame(columns=['name','category']) + resp=self.es.getFeatures() + + for hit in resp['hits']['hits']: + list_row =[] + for name in hit['_source']['nameSource']: + if (name["language"]=="en"): + list_row.append((name["value"])) + + + for cats in hit['_source']['categoriesSource']: + if (cats["language"]=="en"): + list_row.append((cats["label"])) + + + df_eng.loc[len(df_eng)] = list_row + + return df_eng + + + diff --git a/rm_clasificationmodel/ElasticSearchClass.py b/rm_clasificationmodel/ElasticSearchClass.py new file mode 100644 index 0000000..2369e1c --- /dev/null +++ b/rm_clasificationmodel/ElasticSearchClass.py @@ -0,0 +1,13 @@ +from elasticsearch import Elasticsearch +class ElasticSearchDb: + + def __init__(self,url): + self.url=url + self.client = Elasticsearch(url) + + def getFeatures(self): + resp = self.client.search(index="retromotion-indexer_development_products", + body={"_source":["descriptions","descriptionsSource","nameSource","shortDescriptionSource","categoriesSource"], + 'size' : 65000, + "query": {"match_all": {}}}) + return resp \ No newline at end of file diff --git a/rm_clasificationmodel/main.py b/rm_clasificationmodel/main.py index 91a2bc2..70478ef 100644 --- a/rm_clasificationmodel/main.py +++ b/rm_clasificationmodel/main.py @@ -1,3 +1,18 @@ -import torch -print(torch.__version__) \ No newline at end of file +from ElasticSearchClass import ElasticSearchDb +from DataFrameClass import DataFrame + +def main(): + es =ElasticSearchDb("http://172.17.212.35:9200") + + df=DataFrame(es) + + df_eng=df.create() + + print(df_eng) + + + + +if __name__=="__main__": + main() \ No newline at end of file diff --git a/tuitorials/demo02-MulticlassTextClassification_Characters.ipynb b/tuitorials/demo02-MulticlassTextClassification_Characters.ipynb index fcb365d..f10d15f 100644 --- a/tuitorials/demo02-MulticlassTextClassification_Characters.ipynb +++ b/tuitorials/demo02-MulticlassTextClassification_Characters.ipynb @@ -12,7 +12,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -23,7 +23,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -40,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -49,7 +49,7 @@ "\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .,;'\"" ] }, - "execution_count": 14, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -66,7 +66,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -75,7 +75,7 @@ "57" ] }, - "execution_count": 15, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -94,7 +94,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -122,7 +122,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -136,7 +136,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -153,7 +153,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -163,7 +163,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -194,7 +194,7 @@ }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -8203,7 +8203,7 @@ " 'Yunokawa']}" ] }, - "execution_count": 63, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -8214,7 +8214,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -8240,7 +8240,7 @@ " 'Japanese']" ] }, - "execution_count": 21, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -8251,7 +8251,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -8260,7 +8260,7 @@ "18" ] }, - "execution_count": 22, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -8272,7 +8272,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -8281,7 +8281,7 @@ "20074" ] }, - "execution_count": 23, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -8330,7 +8330,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -8339,7 +8339,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -8353,7 +8353,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -8393,7 +8393,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -8408,7 +8408,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -8417,7 +8417,7 @@ "torch.Size([4, 1, 57])" ] }, - "execution_count": 30, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -8425,12 +8425,12 @@ "source": [ "mary_tensor = nameToTensor('Mary')\n", "\n", - "mary_tensor.size()" + "mary_tensor.size()\n" ] }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -8457,7 +8457,7 @@ " 0., 0., 0., 0., 0., 0.]]])" ] }, - "execution_count": 31, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -8468,7 +8468,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 21, "metadata": {}, "outputs": [], "source": [ @@ -8504,7 +8504,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 25, "metadata": {}, "outputs": [], "source": [ @@ -8523,7 +8523,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -8556,7 +8556,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 27, "metadata": {}, "outputs": [], "source": [ @@ -8569,16 +8569,16 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "tensor([[-2.8706, -2.8853, -2.9478, -2.8859, -2.8609, -2.8323, -2.7922, -2.9129,\n", - " -2.9421, -2.9352, -2.8637, -2.8673, -2.9028, -2.9262, -2.8646, -2.8892,\n", - " -2.9638, -2.8996]], grad_fn=)\n" + "tensor([[-2.8588, -2.9890, -2.9064, -2.8552, -2.8594, -2.8804, -2.8285, -2.8627,\n", + " -2.8729, -2.9659, -2.8634, -2.9597, -2.9374, -2.8008, -2.9305, -2.8022,\n", + " -2.9571, -2.9236]], grad_fn=)\n" ] } ], @@ -8588,46 +8588,65 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "tensor([[ 0.0314, -0.0111, 0.0079, -0.0942, 0.0172, -0.0430, -0.0761, -0.0495,\n", - " -0.0590, -0.0527, -0.1060, -0.0301, -0.0630, -0.0274, 0.0298, 0.0365,\n", - " -0.0496, -0.0172, -0.0554, -0.0214, -0.0292, 0.0780, 0.0079, 0.0076,\n", - " -0.0191, 0.0006, 0.0363, 0.0001, 0.0389, 0.0204, -0.0374, -0.0048,\n", - " 0.0242, 0.0009, -0.0386, 0.0413, -0.0197, -0.0223, -0.0143, -0.0368,\n", - " -0.0107, -0.0125, -0.0227, 0.0010, -0.0092, -0.0199, -0.0209, 0.0483,\n", - " -0.0636, -0.0363, -0.0156, 0.0614, 0.0262, -0.0527, -0.0129, -0.0292,\n", - " 0.0730, 0.0725, 0.0134, -0.0360, 0.0186, -0.0181, -0.0488, -0.0369,\n", - " 0.0412, 0.0163, 0.0625, 0.0540, 0.0588, 0.0813, 0.0162, 0.0052,\n", - " 0.0863, -0.0271, -0.0069, 0.0277, -0.0018, 0.0163, -0.0477, -0.0152,\n", - " 0.0535, -0.0630, -0.0224, -0.0319, 0.0346, 0.0786, 0.0346, 0.0808,\n", - " 0.0882, 0.0117, 0.0120, -0.0133, -0.0133, 0.0414, 0.0893, -0.0261,\n", - " -0.0869, 0.0226, -0.0823, 0.0608, 0.0597, -0.0537, -0.0252, -0.0149,\n", - " 0.0117, 0.0376, 0.0470, 0.0106, 0.0799, 0.0320, -0.0540, 0.0892,\n", - " 0.0179, -0.0240, -0.0460, -0.0548, -0.0702, 0.0468, 0.0491, 0.0460,\n", - " 0.0272, 0.0958, -0.0271, -0.0470, -0.0139, 0.0291, -0.0912, 0.0628,\n", - " -0.0859, 0.0121, 0.0504, -0.1050, 0.0219, 0.0606, 0.0615, -0.0418,\n", - " 0.0642, -0.0659, 0.0019, 0.0259, -0.0239, 0.0469, 0.0375, -0.0753,\n", - " 0.0503, -0.0332, 0.0122, -0.0054, 0.0108, 0.0596, -0.0614, -0.1087,\n", - " 0.0594, -0.0270, 0.0329, 0.0338, -0.0531, -0.0053, -0.0822, 0.0576,\n", - " -0.0420, -0.0189, 0.0610, -0.0968, 0.0182, -0.0065, 0.0189, 0.0025,\n", - " -0.0151, -0.0043, 0.0236, -0.0446, 0.0298, 0.0893, 0.0207, 0.0941,\n", - " 0.0036, -0.0405, -0.0122, 0.0634, -0.0402, -0.0080, -0.0579, -0.0475,\n", - " -0.0675, -0.0285, 0.0469, -0.0041, -0.0721, 0.0460, -0.0315, 0.0654,\n", - " 0.0136, -0.0679, -0.0644, 0.0302, 0.0249, 0.0221, 0.0164, -0.0547,\n", - " 0.0762, 0.1059, -0.0835, 0.0221, 0.0003, 0.0098, 0.0743, -0.0168,\n", - " -0.0654, -0.0109, 0.0640, 0.0738, -0.0643, -0.0037, -0.0655, 0.0651,\n", - " -0.0680, 0.0831, -0.0247, -0.0410, 0.0656, 0.0408, -0.0468, -0.0806,\n", - " -0.0006, -0.0149, -0.0136, 0.0855, -0.0364, -0.0465, -0.0065, -0.0409,\n", - " 0.0301, -0.0053, 0.0631, -0.0179, -0.0186, -0.0011, -0.0252, -0.0782,\n", - " -0.0617, -0.0555, 0.0307, -0.0669, 0.0580, 0.0386, -0.0595, 0.0203,\n", - " 0.0519, -0.0302, 0.0773, 0.0263, 0.0494, -0.0149, 0.0112, -0.0056]],\n", - " grad_fn=)\n" + "tensor([[ 6.9377e-02, 6.9443e-02, 1.5033e-02, 5.0495e-03, -5.1603e-02,\n", + " -3.0612e-04, 9.8759e-02, 2.9364e-02, -5.2589e-02, 3.8139e-02,\n", + " -8.8449e-02, -3.7035e-02, 6.0725e-02, -6.7454e-02, -8.3625e-02,\n", + " 3.3739e-02, -6.7409e-02, 3.7716e-02, 2.0668e-03, -2.0646e-02,\n", + " 4.8826e-02, -6.0965e-02, -2.6667e-02, -1.9737e-02, -5.5209e-02,\n", + " 7.9600e-02, -1.5173e-02, 8.2466e-02, 5.7330e-02, -2.0365e-02,\n", + " -2.4430e-03, -1.1986e-02, -7.7797e-02, 4.6474e-02, 4.2708e-02,\n", + " -6.9755e-02, 3.2388e-02, -2.6623e-02, -1.6402e-02, 2.1690e-02,\n", + " -3.2086e-02, 1.7979e-02, -2.6773e-02, -8.0930e-02, -8.7834e-02,\n", + " 7.0939e-02, -9.9595e-03, 1.1019e-01, -2.9785e-02, 4.2834e-02,\n", + " 7.5432e-02, 2.6643e-02, -2.6027e-02, -3.9575e-02, 2.5185e-02,\n", + " 3.3576e-02, 2.0129e-02, -2.0736e-02, -9.4645e-03, 2.5034e-02,\n", + " -1.8453e-02, 4.7665e-02, 2.3963e-02, 1.4428e-02, -4.2276e-02,\n", + " -1.0703e-02, -6.1554e-02, 6.6917e-02, 7.6238e-02, 8.3268e-02,\n", + " 9.5985e-03, -1.0657e-02, 6.3176e-03, -6.9779e-02, -8.4993e-03,\n", + " 1.4913e-02, 2.5807e-02, 8.5635e-02, 7.7313e-02, 7.1725e-02,\n", + " -4.9314e-02, 5.1572e-02, -1.4738e-02, 1.2790e-02, -8.7678e-02,\n", + " 4.0495e-03, 3.2518e-02, -9.1584e-03, 5.5400e-02, -7.1356e-04,\n", + " -3.5589e-02, -8.6984e-02, 1.1296e-02, -3.4089e-02, 8.5081e-02,\n", + " 1.5890e-02, 1.0172e-01, 4.3318e-02, -4.4650e-03, 4.3302e-02,\n", + " 9.0492e-02, -8.9424e-02, -2.5107e-02, -4.9521e-02, -2.3523e-02,\n", + " 4.7702e-02, -4.1813e-02, -9.2071e-02, 1.0447e-01, -2.0033e-02,\n", + " -3.1037e-02, -8.9069e-02, -6.6211e-02, 1.6878e-02, 3.1741e-02,\n", + " -6.2498e-02, -3.2693e-02, 4.9427e-02, -1.0262e-03, -6.7825e-02,\n", + " -5.4861e-02, -1.8367e-02, 7.7815e-02, -4.9213e-02, -7.3490e-02,\n", + " -3.2061e-02, -5.0428e-02, -6.0120e-02, -6.4401e-02, 2.1502e-02,\n", + " 2.0909e-03, 7.0734e-02, -5.2603e-02, -2.4489e-02, 2.7323e-02,\n", + " 6.2038e-02, -3.3178e-03, 3.0697e-02, -2.9959e-02, 2.9696e-02,\n", + " -2.4168e-02, -9.1004e-03, 7.1510e-02, 3.2263e-03, -7.0667e-02,\n", + " -3.5298e-03, -4.0718e-02, 9.7801e-03, 1.1820e-02, -1.7135e-02,\n", + " -3.3705e-02, -8.3573e-02, -1.0451e-02, -1.5103e-02, -7.4721e-02,\n", + " -2.4091e-02, -1.0808e-01, 3.9984e-02, 1.5215e-02, 7.8993e-03,\n", + " 2.4987e-02, -5.7177e-02, -5.6020e-02, -1.6950e-02, -8.1137e-02,\n", + " -2.1211e-02, 6.4455e-03, -1.8096e-02, -7.2886e-02, 1.0153e-02,\n", + " -5.2461e-02, 6.1551e-02, -8.6261e-02, -2.2624e-02, -8.7579e-03,\n", + " 3.0144e-02, -7.9856e-02, -6.6437e-02, -4.7967e-03, -2.0270e-02,\n", + " 2.0910e-02, -3.5062e-02, -4.9663e-02, 7.2058e-03, 9.1088e-02,\n", + " 6.1340e-02, -6.8429e-02, 4.9638e-02, 1.2541e-03, -3.9519e-02,\n", + " -1.5270e-02, -1.6189e-02, 9.4702e-02, 1.0362e-03, 1.9386e-02,\n", + " -5.8166e-02, -7.9797e-03, -9.8845e-02, -4.4711e-02, -1.0297e-01,\n", + " 2.6100e-02, -8.3014e-03, 7.5541e-02, -5.8366e-02, -4.9692e-02,\n", + " -5.5794e-05, -2.9606e-02, 5.0104e-02, 5.2645e-02, 6.6881e-02,\n", + " -4.5483e-02, 1.6255e-02, 1.7013e-03, -5.9972e-02, 1.9701e-02,\n", + " -1.0478e-01, 1.0771e-02, 3.5183e-02, 4.9473e-02, 1.1997e-02,\n", + " -4.0331e-02, 7.2886e-02, 6.1306e-03, 5.1759e-02, 1.5809e-02,\n", + " -4.2575e-02, 4.1543e-02, -7.3644e-02, -2.4258e-02, 6.4694e-02,\n", + " -3.2197e-02, -3.6705e-02, 3.6029e-02, 4.2647e-02, -5.7219e-02,\n", + " 1.5589e-02, 6.7316e-03, 6.8950e-03, -6.5685e-02, 1.9517e-03,\n", + " 3.0885e-02, -5.9294e-02, -6.8630e-02, -2.9299e-02, 4.8240e-02,\n", + " -2.6846e-02, 5.4406e-03, 2.5266e-02, 4.9038e-03, 4.9033e-02,\n", + " -2.2067e-02, -5.1688e-02, -8.5373e-02, 4.5386e-02, -3.4061e-02,\n", + " -4.2483e-02]], grad_fn=)\n" ] } ], @@ -8653,7 +8672,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ @@ -8668,14 +8687,14 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "('Chinese', 6)\n" + "('Portuguese', 13)\n" ] } ], @@ -8693,7 +8712,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ @@ -8716,23 +8735,23 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "language = English , name = Stroud\n", - "language = Dutch , name = Rademakers\n", - "language = French , name = Denis\n", - "language = English , name = Sheehan\n", - "language = Czech , name = Pesek\n", - "language = Greek , name = Antonopoulos\n", - "language = Polish , name = Wiater\n", - "language = Greek , name = Close\n", - "language = Portuguese , name = Albuquerque\n", - "language = Arabic , name = Moghadam\n" + "language = Greek , name = Belesis\n", + "language = Polish , name = Slazak\n", + "language = Vietnamese , name = Kieu\n", + "language = Vietnamese , name = Dinh\n", + "language = French , name = Bonhomme\n", + "language = Czech , name = Janutka\n", + "language = Japanese , name = Miyazawa\n", + "language = Dutch , name = Seelen\n", + "language = Italian , name = Guttuso\n", + "language = Portuguese , name = Santiago\n" ] } ], @@ -8753,7 +8772,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 36, "metadata": {}, "outputs": [], "source": [ @@ -8779,7 +8798,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 37, "metadata": {}, "outputs": [], "source": [ @@ -8811,7 +8830,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 34, "metadata": {}, "outputs": [], "source": [ @@ -8833,64 +8852,52 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 39, "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/tmp/ipykernel_3599/3313719204.py:14: UserWarning: This overload of add_ is deprecated:\n", - "\tadd_(Number alpha, Tensor other)\n", - "Consider using one of the following signatures instead:\n", - "\tadd_(Tensor other, *, Number alpha) (Triggered internally at ../torch/csrc/utils/python_arg_parser.cpp:1485.)\n", - " p.data.add_(-learning_rate, p.grad.data)\n" - ] - }, { "name": "stdout", "output_type": "stream", "text": [ - "5000 2% 3.1348 Nacar / Arabic ✗ (Italian)\n", - "10000 5% 2.8061 Houte / English ✗ (Dutch)\n", - "15000 7% 0.7605 Yuhara / Japanese ✓\n", - "20000 10% 2.8016 Silva / Czech ✗ (Portuguese)\n", - "25000 12% 2.3714 Martin / Irish ✗ (Scottish)\n", - "30000 15% 0.4144 Sakiyurai / Japanese ✓\n", - "35000 17% 3.7255 Cerny / English ✗ (Czech)\n", - "40000 20% 1.5041 Halabi / Italian ✗ (Arabic)\n", - "45000 22% 0.8936 Roijakker / Dutch ✓\n", - "50000 25% 1.8352 Tsen / Dutch ✗ (Chinese)\n", - "55000 27% 2.0594 Hanania / Czech ✗ (Arabic)\n", - "60000 30% 1.2546 Maille / Irish ✓\n", - "65000 32% 1.1838 Marquez / Spanish ✓\n", - "70000 35% 0.3159 Gomulka / Polish ✓\n", - "75000 37% 0.8446 Soares / Portuguese ✓\n", - "80000 40% 0.4197 Lefurgey / French ✓\n", - "85000 42% 3.7713 Augustin / Russian ✗ (French)\n", - "90000 45% 0.2647 Kijek / Polish ✓\n", - "95000 47% 0.5736 Kijek / Polish ✓\n", - "100000 50% 1.3014 Santos / Greek ✗ (Portuguese)\n", - "105000 52% 2.8657 Schrijnemakers / Greek ✗ (Dutch)\n", - "110000 55% 0.0139 Zhuravov / Russian ✓\n", - "115000 57% 1.0761 O'Shea / Spanish ✗ (Irish)\n", - "120000 60% 0.1046 Vamvakidis / Greek ✓\n", - "125000 62% 0.9131 Kieu / Vietnamese ✓\n", - "130000 65% 2.6827 Penzig / Scottish ✗ (German)\n", - "135000 67% 1.9621 Tedd / German ✗ (English)\n", - "140000 70% 0.3312 Hadad / Arabic ✓\n", - "145000 72% 0.3755 Mccallum / Scottish ✓\n", - "150000 75% 1.5424 Sulzbach / Czech ✗ (German)\n", - "155000 77% 1.3112 Scott / Scottish ✓\n", - "160000 80% 0.8444 Caomh / Irish ✓\n", - "165000 82% 0.5783 Ienari / Japanese ✓\n", - "170000 85% 0.8806 Niu / Chinese ✓\n", - "175000 87% 0.0703 Shakhmaev / Russian ✓\n", - "180000 90% 2.4085 Garb / Arabic ✗ (German)\n", - "185000 92% 1.8865 Costa / Czech ✗ (Spanish)\n", - "190000 95% 0.0548 Wyrzyk / Polish ✓\n", - "195000 97% 9.3082 Konstantatos / German ✗ (Greek)\n", - "200000 100% 2.3740 Frierdich / English ✗ (Czech)\n" + "5000 2% 2.0702 Gok / Korean ✗ (Chinese)\n", + "10000 5% 0.3152 Okura / Japanese ✓\n", + "15000 7% 0.0011 Moraitopoulos / Greek ✓\n", + "20000 10% 0.9455 Sardelis / Greek ✓\n", + "25000 12% 2.0836 Sleiman / Czech ✗ (Arabic)\n", + "30000 15% 0.5883 Newman / English ✓\n", + "35000 17% 0.8222 Dagher / Arabic ✓\n", + "40000 20% 3.4747 Michel / Irish ✗ (French)\n", + "45000 22% 0.0336 Ricchetti / Italian ✓\n", + "50000 25% 3.8208 Keir / Scottish ✗ (English)\n", + "55000 27% 2.4019 Kwak / Polish ✗ (Korean)\n", + "60000 30% 2.0889 Solos / Greek ✗ (Spanish)\n", + "65000 32% 0.3139 Piatek / Polish ✓\n", + "70000 35% 2.9499 Rompa / Czech ✗ (Dutch)\n", + "75000 37% 1.0251 Shi / Korean ✗ (Chinese)\n", + "80000 40% 0.0333 Kanegawa / Japanese ✓\n", + "85000 42% 0.9742 Song / Korean ✗ (Chinese)\n", + "90000 45% 2.7500 Durante / Italian ✗ (Spanish)\n", + "95000 47% 0.7623 Geracimos / Greek ✓\n", + "100000 50% 0.6451 Rim / Korean ✓\n", + "105000 52% 2.8468 Keefe / German ✗ (Irish)\n", + "110000 55% 0.3063 Cathasach / Irish ✓\n", + "115000 57% 3.2352 Mazza / Portuguese ✗ (Italian)\n", + "120000 60% 3.3270 Rosales / Dutch ✗ (Spanish)\n", + "125000 62% 1.4190 Viola / Spanish ✗ (Italian)\n", + "130000 65% 1.5535 Santos / Greek ✗ (Portuguese)\n", + "135000 67% 0.8502 Klerk / Dutch ✓\n", + "140000 70% 2.3285 Pereira / Italian ✗ (Portuguese)\n", + "145000 72% 0.4392 Schwarzenegger / German ✓\n", + "150000 75% 0.2945 Chun / Korean ✓\n", + "155000 77% 1.9939 Duncan / Irish ✗ (Scottish)\n", + "160000 80% 3.4147 Chmiel / German ✗ (Polish)\n", + "165000 82% 1.5220 Johnston / English ✗ (Scottish)\n", + "170000 85% 0.4709 Luo / Chinese ✓\n", + "175000 87% 1.3566 Schmeiser / German ✗ (Czech)\n", + "180000 90% 0.1557 Adelardi / Italian ✓\n", + "185000 92% 0.0966 Paterson / Scottish ✓\n", + "190000 95% 1.3970 Rotolo / Spanish ✗ (Italian)\n", + "195000 97% 0.1152 Yatzenko / Russian ✓\n" ] } ],