diff --git a/PCLR/PCLR_MTBLS92_Working_Copy.ipynb b/PCLR/PCLR_MTBLS92_Working_Copy.ipynb index 7d135e097e7b583aaa101140bb5cbf541949d257..bb599d387f13b040953220d77d6ea110cf2e6e0f 100644 --- a/PCLR/PCLR_MTBLS92_Working_Copy.ipynb +++ b/PCLR/PCLR_MTBLS92_Working_Copy.ipynb @@ -1606,179 +1606,32 @@ { "cell_type": "code", "source": [ - "coef = model.model.coef_\n", - "important_feat = abs(coef)\n", - "#get indices of those important features\n", - "idx = important_feat.argsort(kind= \"quicksort\")\n", - "idx= idx[::-1][:5]\n", - "#get more information from peaktable:\n", - "top_met = PeakList.iloc[idx]\n", - "top_met_info = PeakTable.iloc[top_met.index-1]\n", - "#5 most important metabolites\n", - "top_met_info" + "coefficients = model.model.coef_\n", + "top_features = abs(coefficients)\n", + "ids = top_features.argsort(kind= \"quicksort\")\n", + "ids = ids[::-1][:3] # extracting top 3 IDs\n", + "top_three_features = PeakList.iloc[ids]\n", + "top_three_features_info = PeakTable.iloc[top_three_features.index-1]\n", + "print(top_three_features_info)" ], "metadata": { "colab": { - "base_uri": "https://localhost:8080/", - "height": 206 + "base_uri": "https://localhost:8080/" }, "id": "KtMTPUQelblb", - "outputId": "555d795d-4803-4329-c4e2-83cf2b4dca03" + "outputId": "a7db8b73-53e2-4dca-b416-450c5e4ecff8" }, - "execution_count": 9, + "execution_count": 10, "outputs": [ { - "output_type": "execute_result", - "data": { - "text/plain": [ - " Idx Name Label\n", - "6 6 M6 LysoPC(18:0)\n", - "42 42 M42 PC(38:2e)\n", - "8 8 M8 LysoPC(18:2)\n", - "16 16 M16 PC(32:0)\n", - "53 53 M53 PC(40:4e)" - ], - "text/html": [ - "\n", - " <div id=\"df-79be1546-9158-4080-a131-8d218476c06e\">\n", - " <div class=\"colab-df-container\">\n", - " <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>Idx</th>\n", - " <th>Name</th>\n", - " <th>Label</th>\n", - " </tr>\n", - " </thead>\n", - " <tbody>\n", - " <tr>\n", - " <th>6</th>\n", - " <td>6</td>\n", - " <td>M6</td>\n", - " <td>LysoPC(18:0)</td>\n", - " </tr>\n", - " <tr>\n", - " <th>42</th>\n", - " <td>42</td>\n", - " <td>M42</td>\n", - " <td>PC(38:2e)</td>\n", - " </tr>\n", - " <tr>\n", - " <th>8</th>\n", - " <td>8</td>\n", - " <td>M8</td>\n", - " <td>LysoPC(18:2)</td>\n", - " </tr>\n", - " <tr>\n", - " <th>16</th>\n", - " <td>16</td>\n", - " <td>M16</td>\n", - " <td>PC(32:0)</td>\n", - " </tr>\n", - " <tr>\n", - " <th>53</th>\n", - " <td>53</td>\n", - " <td>M53</td>\n", - " <td>PC(40:4e)</td>\n", - " </tr>\n", - " </tbody>\n", - "</table>\n", - "</div>\n", - " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-79be1546-9158-4080-a131-8d218476c06e')\"\n", - " title=\"Convert this dataframe to an interactive table.\"\n", - " style=\"display:none;\">\n", - " \n", - " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n", - " width=\"24px\">\n", - " <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n", - " <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n", - " </svg>\n", - " </button>\n", - " \n", - " <style>\n", - " .colab-df-container {\n", - " display:flex;\n", - " flex-wrap:wrap;\n", - " gap: 12px;\n", - " }\n", - "\n", - " .colab-df-convert {\n", - " background-color: #E8F0FE;\n", - " border: none;\n", - " border-radius: 50%;\n", - " cursor: pointer;\n", - " display: none;\n", - " fill: #1967D2;\n", - " height: 32px;\n", - " padding: 0 0 0 0;\n", - " width: 32px;\n", - " }\n", - "\n", - " .colab-df-convert:hover {\n", - " background-color: #E2EBFA;\n", - " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n", - " fill: #174EA6;\n", - " }\n", - "\n", - " [theme=dark] .colab-df-convert {\n", - " background-color: #3B4455;\n", - " fill: #D2E3FC;\n", - " }\n", - "\n", - " [theme=dark] .colab-df-convert:hover {\n", - " background-color: #434B5C;\n", - " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n", - " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n", - " fill: #FFFFFF;\n", - " }\n", - " </style>\n", - "\n", - " <script>\n", - " const buttonEl =\n", - " document.querySelector('#df-79be1546-9158-4080-a131-8d218476c06e button.colab-df-convert');\n", - " buttonEl.style.display =\n", - " google.colab.kernel.accessAllowed ? 'block' : 'none';\n", - "\n", - " async function convertToInteractive(key) {\n", - " const element = document.querySelector('#df-79be1546-9158-4080-a131-8d218476c06e');\n", - " const dataTable =\n", - " await google.colab.kernel.invokeFunction('convertToInteractive',\n", - " [key], {});\n", - " if (!dataTable) return;\n", - "\n", - " const docLinkHtml = 'Like what you see? Visit the ' +\n", - " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n", - " + ' to learn more about interactive tables.';\n", - " element.innerHTML = '';\n", - " dataTable['output_type'] = 'display_data';\n", - " await google.colab.output.renderOutput(dataTable, element);\n", - " const docLink = document.createElement('div');\n", - " docLink.innerHTML = docLinkHtml;\n", - " element.appendChild(docLink);\n", - " }\n", - " </script>\n", - " </div>\n", - " </div>\n", - " " - ] - }, - "metadata": {}, - "execution_count": 9 + "output_type": "stream", + "name": "stdout", + "text": [ + " Idx Name Label\n", + "6 6 M6 LysoPC(18:0)\n", + "42 42 M42 PC(38:2e)\n", + "8 8 M8 LysoPC(18:2)\n" + ] } ] }