[MODELS] Cleanup Jupyter Notebooks.
[thoth.git] / models / failure_prediction / jnotebooks / FeatureCreation.ipynb
1 {
2  "cells": [
3   {
4    "cell_type": "markdown",
5    "metadata": {
6     "id": "zyycU3DFlecK"
7    },
8    "source": [
9     "Contributors: **Rohit Singh Rathaur, Girish L.** \n",
10     "\n",
11     "Copyright [2021](2021) [*Rohit Singh Rathaur, BIT Mesra and Girish L., CIT GUBBI, Karnataka*]\n",
12     "\n",
13     "Licensed under the Apache License, Version 2.0 (the \"License\");\n",
14     "you may not use this file except in compliance with the License.\n",
15     "You may obtain a copy of the License at\n",
16     "\n",
17     "    http://www.apache.org/licenses/LICENSE-2.0\n",
18     "\n",
19     "Unless required by applicable law or agreed to in writing, software\n",
20     "distributed under the License is distributed on an \"AS IS\" BASIS,\n",
21     "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
22     "See the License for the specific language governing permissions and\n",
23     "limitations under the License."
24    ]
25   },
26   {
27    "cell_type": "code",
28    "execution_count": null,
29    "metadata": {
30     "id": "gehKp2rySVf8"
31    },
32    "outputs": [],
33    "source": [
34     "# Import libraries use for visualization and analysis\n",
35     "import pandas as pd\n",
36     "import numpy as np\n",
37     "\n",
38     "%matplotlib inline\n",
39     "import matplotlib\n",
40     "import matplotlib.pyplot as plt\n",
41     "\n",
42     "from pandas import Series,DataFrame\n",
43     "import matplotlib.pyplot as plt\n",
44     "import seaborn as sns\n",
45     "from sklearn.preprocessing import scale\n",
46     "from sklearn.decomposition import PCA\n",
47     "from sklearn.discriminant_analysis import LinearDiscriminantAnalysis\n",
48     "from scipy import stats\n",
49     "from IPython.display import display, HTML"
50    ]
51   },
52   {
53    "cell_type": "code",
54    "execution_count": null,
55    "metadata": {
56     "colab": {
57      "base_uri": "https://localhost:8080/"
58     },
59     "id": "tkuBlbCXSsdP",
60     "outputId": "2b3ef633-a851-4c53-80eb-6b1bf4ffcc1c"
61    },
62    "outputs": [],
63    "source": [
64     "from google.colab import drive\n",
65     "drive.mount('/gdrive')"
66    ]
67   },
68   {
69    "cell_type": "markdown",
70    "metadata": {
71     "id": "wZXe8D88S-6R"
72    },
73    "source": [
74     "# **Loading the Data**"
75    ]
76   },
77   {
78    "cell_type": "code",
79    "execution_count": null,
80    "metadata": {
81     "id": "KiDSpl37Sy39"
82    },
83    "outputs": [],
84    "source": [
85     "df_Ellis  = pd.read_csv(\"/gdrive/MyDrive/LFN Anuket/Analysis/data/Final/Final.csv\")\n",
86     "#df_Bono  = pd.read_csv(\"/gdrive/MyDrive/LFN Anuket/Analysis/data/matrices/df_Bono.csv\", error_bad_lines=False)\n",
87     "#df_Sprout  = pd.read_csv(\"/gdrive/MyDrive/LFN Anuket/Analysis/data/matrices/df_Sprout.csv\", error_bad_lines=False)\n",
88     "#df_Homer  = pd.read_csv(\"/gdrive/MyDrive/LFN Anuket/Analysis/data/matrices/df_Homer.csv\", error_bad_lines=False)\n",
89     "#df_Homestead  = pd.read_csv(\"/gdrive/MyDrive/LFN Anuket/Analysis/data/matrices/df_Homestead.csv\", error_bad_lines=False)\n",
90     "#df_Ralf  = pd.read_csv(\"/gdrive/MyDrive/LFN Anuket/Analysis/data/matrices/df_Ralf.csv\", error_bad_lines=False)"
91    ]
92   },
93   {
94    "cell_type": "code",
95    "execution_count": null,
96    "metadata": {
97     "colab": {
98      "base_uri": "https://localhost:8080/",
99      "height": 204
100     },
101     "id": "dpy8jAm-TsCs",
102     "outputId": "d8ad2072-1fa3-4b3c-fb55-b5128767b349"
103    },
104    "outputs": [],
105    "source": [
106     "df_Ellis.head()"
107    ]
108   },
109   {
110    "cell_type": "code",
111    "execution_count": null,
112    "metadata": {
113     "colab": {
114      "base_uri": "https://localhost:8080/",
115      "height": 297
116     },
117     "id": "dJa9FgJNgqpI",
118     "outputId": "54d6c43d-489f-4347-93e5-12e4a4da2066"
119    },
120    "outputs": [],
121    "source": [
122     "df_Ellis.describe()"
123    ]
124   },
125   {
126    "cell_type": "code",
127    "execution_count": null,
128    "metadata": {
129     "id": "xGVleQbnhRm6"
130    },
131    "outputs": [],
132    "source": [
133     "#df_Ellis['SLO1'] = 0\n",
134     "#print('Column names are: ',list(df_Ellis.columns))"
135    ]
136   },
137   {
138    "cell_type": "code",
139    "execution_count": null,
140    "metadata": {
141     "colab": {
142      "base_uri": "https://localhost:8080/"
143     },
144     "id": "b-F_gA61xowR",
145     "outputId": "f9bd6232-2603-40ad-ccff-18887839e2da"
146    },
147    "outputs": [],
148    "source": [
149     "df4 = df_Ellis[\"ellis-load.avg_1_min\"] > 2.45\n",
150     "df4\n",
151     "df4.to_csv('/gdrive/MyDrive/LFN Anuket/Analysis/data/Final/EllisLoadAvgLabel_lessthan0198.csv')\n",
152     "df4.head(50)"
153    ]
154   },
155   {
156    "cell_type": "code",
157    "execution_count": null,
158    "metadata": {
159     "colab": {
160      "base_uri": "https://localhost:8080/"
161     },
162     "id": "8xcPRerCz8nA",
163     "outputId": "fb66f20e-7365-40ec-857a-9dd9a8072401"
164    },
165    "outputs": [],
166    "source": [
167     "df3 = df_Ellis[\"ellis-cpu.wait_perc\"] > 5\n",
168     "df3\n",
169     "df3.to_csv('/gdrive/MyDrive/LFN Anuket/Analysis/data/Final/ellis-cpu>5.csv')\n",
170     "df3.head(50)"
171    ]
172   },
173   {
174    "cell_type": "code",
175    "execution_count": null,
176    "metadata": {
177     "colab": {
178      "base_uri": "https://localhost:8080/"
179     },
180     "id": "EED56Wiq_NjM",
181     "outputId": "20b06258-c5ba-457b-a022-cf5823217cbf"
182    },
183    "outputs": [],
184    "source": [
185     "df5 = df_Ellis[\"ellis-net.out_packets_sec\"] > 1000\n",
186     "df5\n",
187     "df5.to_csv('/gdrive/MyDrive/LFN Anuket/Analysis/data/Final/ellis-net.in_bytes_sec21139.csv')\n",
188     "df5.head(50)"
189    ]
190   },
191   {
192    "cell_type": "code",
193    "execution_count": null,
194    "metadata": {
195     "colab": {
196      "base_uri": "https://localhost:8080/"
197     },
198     "id": "phlI40_y0mug",
199     "outputId": "7fa177b9-bf9a-4b96-db65-7402f7f6cf32"
200    },
201    "outputs": [],
202    "source": [
203     "# We are applying Logical OR Operator between df4 and df3\n",
204     "df6 = (df4[0:176999]) | (df3[0:176999])\n",
205     "df6.head(50)"
206    ]
207   },
208   {
209    "cell_type": "code",
210    "execution_count": null,
211    "metadata": {
212     "colab": {
213      "base_uri": "https://localhost:8080/"
214     },
215     "id": "9xKYzZcLAZGy",
216     "outputId": "bc15e547-c791-4104-8bb2-8ed4d3288ac1"
217    },
218    "outputs": [],
219    "source": [
220     "df6.to_csv('/gdrive/MyDrive/LFN Anuket/Analysis/data/Final/OR_TwoCondition(2).csv')\n",
221     "df6.head(50)"
222    ]
223   },
224   {
225    "cell_type": "code",
226    "execution_count": null,
227    "metadata": {
228     "colab": {
229      "base_uri": "https://localhost:8080/"
230     },
231     "id": "wRADpDibBZo5",
232     "outputId": "dfc6dc79-3d9f-4979-8210-e62e77b1aa6e"
233    },
234    "outputs": [],
235    "source": [
236     "df7 = (df6[0:176999]) | (df5[0:176999])\n",
237     "df7.head(50)"
238    ]
239   },
240   {
241    "cell_type": "code",
242    "execution_count": null,
243    "metadata": {
244     "colab": {
245      "base_uri": "https://localhost:8080/"
246     },
247     "id": "w6BrDjX4CODn",
248     "outputId": "a6c956e7-6aed-4bdd-f37f-505a994de51a"
249    },
250    "outputs": [],
251    "source": [
252     "df7.to_csv('/gdrive/MyDrive/LFN Anuket/Analysis/data/Final/FinalORLabel8.5.csv')\n",
253     "df7.head(50)"
254    ]
255   },
256   {
257    "cell_type": "code",
258    "execution_count": null,
259    "metadata": {
260     "id": "wwv2cjFAIFHL"
261    },
262    "outputs": [],
263    "source": [
264     "df_Ellis.insert (7, \"Label\", df7)"
265    ]
266   },
267   {
268    "cell_type": "code",
269    "execution_count": null,
270    "metadata": {
271     "id": "hrPqpjd96I1x"
272    },
273    "outputs": [],
274    "source": [
275     "#df_Ellis.insert (8, \"Label\", df7)"
276    ]
277   },
278   {
279    "cell_type": "code",
280    "execution_count": null,
281    "metadata": {
282     "id": "_zKkQLOz6qPY"
283    },
284    "outputs": [],
285    "source": [
286     "# We applied Logical OR operator in two features only known as  and df3 and df4 and stored result in df6 which is known as Final Label after applying OR condition\n",
287     "df_Ellis\n",
288     "df_Ellis.to_csv('/gdrive/MyDrive/LFN Anuket/Analysis/data/Final/Ellis_FinalTwoConditionwithOR.csv')"
289    ]
290   },
291   {
292    "cell_type": "code",
293    "execution_count": null,
294    "metadata": {
295     "colab": {
296      "base_uri": "https://localhost:8080/",
297      "height": 606
298     },
299     "id": "3rEy1vtp67M9",
300     "outputId": "4e2175cc-dccb-4aaf-a152-e2452de241b0"
301    },
302    "outputs": [],
303    "source": [
304     "df_Ellis.head(100)"
305    ]
306   },
307   {
308    "cell_type": "code",
309    "execution_count": null,
310    "metadata": {
311     "colab": {
312      "base_uri": "https://localhost:8080/"
313     },
314     "id": "11Qu45RY0HNG",
315     "outputId": "305c5dd5-ec61-48a8-abb6-e29bbc4b9e42"
316    },
317    "outputs": [],
318    "source": [
319     "# pandas count distinct values in column\n",
320     "df_Ellis['Label'].value_counts()"
321    ]
322   },
323   {
324    "cell_type": "code",
325    "execution_count": null,
326    "metadata": {
327     "id": "0sB-W_Ny4eHk"
328    },
329    "outputs": [],
330    "source": [
331     "#final.to_csv('/gdrive/MyDrive/LFN Anuket/Analysis/data/New/FinalLabel.csv')"
332    ]
333   },
334   {
335    "cell_type": "code",
336    "execution_count": null,
337    "metadata": {
338     "id": "ERsufys7wcSg"
339    },
340    "outputs": [],
341    "source": [
342     "#df_Ellis.loc[(df_Ellis[\"ellis-cpu.wait_perc\"] > 5) & (df_Ellis[\"ellis-load.avg_1_min\"] > 2)]"
343    ]
344   },
345   {
346    "cell_type": "markdown",
347    "metadata": {
348     "id": "9le7MwnDhlnH"
349    },
350    "source": [
351     "# **Creating New Features**"
352    ]
353   },
354   {
355    "cell_type": "code",
356    "execution_count": null,
357    "metadata": {
358     "id": "090QXGpPlEF6"
359    },
360    "outputs": [],
361    "source": []
362   }
363  ],
364  "metadata": {
365   "colab": {
366    "name": "FeatureCreation.ipynb",
367    "provenance": []
368   },
369   "kernelspec": {
370    "display_name": "Python 3 (ipykernel)",
371    "language": "python",
372    "name": "python3"
373   },
374   "language_info": {
375    "codemirror_mode": {
376     "name": "ipython",
377     "version": 3
378    },
379    "file_extension": ".py",
380    "mimetype": "text/x-python",
381    "name": "python",
382    "nbconvert_exporter": "python",
383    "pygments_lexer": "ipython3",
384    "version": "3.9.7"
385   }
386  },
387  "nbformat": 4,
388  "nbformat_minor": 1
389 }