ArashMehdipour commited on
Commit
d9517c1
1 Parent(s): 78685be

Initial commit

Browse files
.gitattributes CHANGED
@@ -25,3 +25,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
  *.zstandard filter=lfs diff=lfs merge=lfs -text
27
  *tfevents* filter=lfs diff=lfs merge=lfs -text
28
+ *.data-00000-of-00001 filter=lfs diff=lfs merge=lfs -binary
CapstoneDeploymentTest.ipynb ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 2,
6
+ "id": "5f81d089",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import pandas as pd\n",
11
+ "import numpy as np\n",
12
+ "import tensorflow as tf\n",
13
+ "import gradio as gr\n",
14
+ "import matplotlib.pyplot as plt\n",
15
+ "\n",
16
+ "from pathlib import Path\n",
17
+ "from sklearn.preprocessing import MinMaxScaler, PowerTransformer\n",
18
+ "\n",
19
+ "pd.options.mode.chained_assignment = 'warn'"
20
+ ]
21
+ },
22
+ {
23
+ "cell_type": "code",
24
+ "execution_count": 3,
25
+ "id": "a4a28281",
26
+ "metadata": {},
27
+ "outputs": [],
28
+ "source": [
29
+ "import warnings\n",
30
+ "warnings.filterwarnings(\"ignore\")"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": 4,
36
+ "id": "d4ec3046",
37
+ "metadata": {},
38
+ "outputs": [],
39
+ "source": [
40
+ "modelPath = Path('trainedModel/')\n",
41
+ "\n",
42
+ "model = tf.keras.models.load_model(modelPath)"
43
+ ]
44
+ },
45
+ {
46
+ "cell_type": "code",
47
+ "execution_count": 5,
48
+ "id": "ef122845",
49
+ "metadata": {},
50
+ "outputs": [],
51
+ "source": [
52
+ "col_names = [ 'setting1'\n",
53
+ " , 'T30', 'T50','P2', 'P15', 'P30', 'Nf', 'Nc', 'Ps30'\n",
54
+ " , 'phi', 'NRf', 'NRc', 'BPR','htBleed',\n",
55
+ " 'W31', 'W32']"
56
+ ]
57
+ },
58
+ {
59
+ "cell_type": "code",
60
+ "execution_count": 6,
61
+ "id": "950efda4",
62
+ "metadata": {},
63
+ "outputs": [],
64
+ "source": [
65
+ "testData1 = pd.read_csv('data/testData.csv')\n",
66
+ "testData1.drop(columns='Unnamed: 0', inplace=True)\n",
67
+ "testData1.columns = col_names"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "code",
72
+ "execution_count": 7,
73
+ "id": "9600ddda",
74
+ "metadata": {},
75
+ "outputs": [],
76
+ "source": [
77
+ "testDataNonNormal = pd.read_csv('data/unnormalizedTestData.csv')\n",
78
+ "testDataNonNormal.drop(columns='Unnamed: 0', inplace=True)\n",
79
+ "testDataNonNormal.columns = col_names"
80
+ ]
81
+ },
82
+ {
83
+ "cell_type": "code",
84
+ "execution_count": 8,
85
+ "id": "3ca99247",
86
+ "metadata": {},
87
+ "outputs": [],
88
+ "source": [
89
+ "col_names = ['id', 'cycle', 'setting1', 'setting2', 'setting3', 'T2', 'T24'\n",
90
+ " , 'T30', 'T50','P2', 'P15', 'P30', 'Nf', 'Nc', 'epr', 'Ps30'\n",
91
+ " , 'phi', 'NRf', 'NRc', 'BPR','farB', 'htBleed', 'Nf_dmd',\n",
92
+ " 'PCNfR_dmd','W31', 'W32', 's22', 's23']"
93
+ ]
94
+ },
95
+ {
96
+ "cell_type": "code",
97
+ "execution_count": 9,
98
+ "id": "715ff95e",
99
+ "metadata": {},
100
+ "outputs": [],
101
+ "source": [
102
+ "testData = pd.read_csv(\"data/test.txt\", sep=' ', names=col_names)\n",
103
+ "testDataNoDrop = pd.read_csv(\"data/test.txt\", sep=' ', names=col_names)\n",
104
+ "testData = testData.drop(['id', 'cycle', 'setting2', 'setting3', 'T2',\n",
105
+ " 'T24', 'epr', 'farB', 'Nf_dmd', 'PCNfR_dmd', 's22', 's23'], axis=1)"
106
+ ]
107
+ },
108
+ {
109
+ "cell_type": "code",
110
+ "execution_count": 10,
111
+ "id": "403d5e69",
112
+ "metadata": {},
113
+ "outputs": [],
114
+ "source": [
115
+ "gen = MinMaxScaler(feature_range=(0,1))\n",
116
+ "pt = PowerTransformer()"
117
+ ]
118
+ },
119
+ {
120
+ "cell_type": "code",
121
+ "execution_count": 11,
122
+ "id": "0e635ec3",
123
+ "metadata": {},
124
+ "outputs": [],
125
+ "source": [
126
+ "def predict(engineId, NRc, T30, P30):\n",
127
+ " # W31 is index 15, T30 is index 1, P30 is index 5\n",
128
+ " engineIdx = testDataNoDrop.index[testDataNoDrop['id'] == engineId].tolist()\n",
129
+ " engineIdx = engineIdx[int(len(engineIdx)/2)]\n",
130
+ " \n",
131
+ " testData.loc[engineIdx,'NRc'] = NRc\n",
132
+ " testData.loc[engineIdx,'T30'] = T30\n",
133
+ " testData.loc[engineIdx,'P30'] = P30\n",
134
+ " \n",
135
+ " testDf = gen.fit_transform(testData)\n",
136
+ " testDf = pd.DataFrame(testDf)\n",
137
+ " testDf = np.nan_to_num(testDf)\n",
138
+ " testDf = pt.fit_transform(testDf)\n",
139
+ " testDf = np.array(testDf)\n",
140
+ " # truncData = np.array(testData.iloc[engineIdx[0],:])\n",
141
+ " # truncData.W31 = W31\n",
142
+ " # truncData.T30 = T30\n",
143
+ " # truncData.P30 = P30\n",
144
+ " # truncData[1] = T30\n",
145
+ " # truncData[5] = P30\n",
146
+ " # truncData[15] = W31\n",
147
+ " # print(truncData)\n",
148
+ " \n",
149
+ " # truncData = gen.fit_transform(np.array(truncData).reshape(-1,1))\n",
150
+ " # print(truncData)\n",
151
+ " # truncData = pt.fit_transform(truncData)\n",
152
+ " # print(truncData)\n",
153
+ " data = testDf[engineIdx]\n",
154
+ " data = data.reshape(1, 16)\n",
155
+ " # print(data)\n",
156
+ " pred = int(model.predict(data))\n",
157
+ " \n",
158
+ " if pred > 30:\n",
159
+ " maintReq = 'No '\n",
160
+ " \n",
161
+ " return pred\n",
162
+ " "
163
+ ]
164
+ },
165
+ {
166
+ "cell_type": "code",
167
+ "execution_count": 12,
168
+ "id": "94a919e7",
169
+ "metadata": {},
170
+ "outputs": [],
171
+ "source": [
172
+ "defaultNrc = int(max(testData['NRc']) - (max(testData['NRc'])-8075)/2)\n",
173
+ "defaultT = int(max(testData['T30']) - (max(testData['T30'])-1580)/2)\n",
174
+ "defaultP = int(max(testData['P30']) - (max(testData['P30'])-550)/2)"
175
+ ]
176
+ },
177
+ {
178
+ "cell_type": "code",
179
+ "execution_count": 13,
180
+ "id": "67a89db6",
181
+ "metadata": {},
182
+ "outputs": [],
183
+ "source": [
184
+ "input = [gr.inputs.Slider(1, 100, step=1, label='Engine ID'),\n",
185
+ " gr.inputs.Slider(8075, max(testData['NRc']), default=defaultNrc, step=0.1, label='Corrected Engine Core Speed (rpm)'),\n",
186
+ " gr.inputs.Slider(1580, max(testData['T30']), default=defaultT, label='Total Temperature at HPC Outlet (\\N{DEGREE SIGN}R)'),\n",
187
+ " gr.inputs.Slider(550, max(testData['P30']), default=defaultP, label='Total Pressure at HPC Outlet (psi)')]\n",
188
+ "\n",
189
+ "output = [gr.outputs.Textbox(type='number', label=\"Remaining Engine Cycles\")]"
190
+ ]
191
+ },
192
+ {
193
+ "cell_type": "code",
194
+ "execution_count": 14,
195
+ "id": "56acae73",
196
+ "metadata": {},
197
+ "outputs": [
198
+ {
199
+ "name": "stdout",
200
+ "output_type": "stream",
201
+ "text": [
202
+ "Running on local URL: http://127.0.0.1:7860/\n",
203
+ "Running on public URL: https://46768.gradio.app\n",
204
+ "\n",
205
+ "This share link expires in 72 hours. For free permanent hosting, check out Spaces (https://huggingface.co/spaces)\n"
206
+ ]
207
+ },
208
+ {
209
+ "data": {
210
+ "text/html": [
211
+ "\n",
212
+ " <iframe\n",
213
+ " width=\"900\"\n",
214
+ " height=\"500\"\n",
215
+ " src=\"https://46768.gradio.app\"\n",
216
+ " frameborder=\"0\"\n",
217
+ " allowfullscreen\n",
218
+ " \n",
219
+ " ></iframe>\n",
220
+ " "
221
+ ],
222
+ "text/plain": [
223
+ "<IPython.lib.display.IFrame at 0x200411ef220>"
224
+ ]
225
+ },
226
+ "metadata": {},
227
+ "output_type": "display_data"
228
+ },
229
+ {
230
+ "data": {
231
+ "text/plain": [
232
+ "(<fastapi.applications.FastAPI at 0x20033b30fd0>,\n",
233
+ " 'http://127.0.0.1:7860/',\n",
234
+ " 'https://46768.gradio.app')"
235
+ ]
236
+ },
237
+ "execution_count": 14,
238
+ "metadata": {},
239
+ "output_type": "execute_result"
240
+ }
241
+ ],
242
+ "source": [
243
+ "iface = gr.Interface(fn=predict, inputs=input, outputs=output, live=True, theme=\"dark-peach\")\n",
244
+ "iface.launch(debug=False, share=True)"
245
+ ]
246
+ }
247
+ ],
248
+ "metadata": {
249
+ "interpreter": {
250
+ "hash": "9cf77d9e31fba3236aefb4748d140888e596bc65dcef8da4aa710fb6056a88b0"
251
+ },
252
+ "kernelspec": {
253
+ "display_name": "ML",
254
+ "language": "python",
255
+ "name": "python3"
256
+ },
257
+ "language_info": {
258
+ "codemirror_mode": {
259
+ "name": "ipython",
260
+ "version": 3
261
+ },
262
+ "file_extension": ".py",
263
+ "mimetype": "text/x-python",
264
+ "name": "python",
265
+ "nbconvert_exporter": "python",
266
+ "pygments_lexer": "ipython3",
267
+ "version": "3.9.10"
268
+ }
269
+ },
270
+ "nbformat": 4,
271
+ "nbformat_minor": 5
272
+ }
data/AutoEncoderTestConnected.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
data/RUL.txt ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 112
2
+ 98
3
+ 69
4
+ 82
5
+ 91
6
+ 93
7
+ 91
8
+ 95
9
+ 111
10
+ 96
11
+ 97
12
+ 124
13
+ 95
14
+ 107
15
+ 83
16
+ 84
17
+ 50
18
+ 28
19
+ 87
20
+ 16
21
+ 57
22
+ 111
23
+ 113
24
+ 20
25
+ 145
26
+ 119
27
+ 66
28
+ 97
29
+ 90
30
+ 115
31
+ 8
32
+ 48
33
+ 106
34
+ 7
35
+ 11
36
+ 19
37
+ 21
38
+ 50
39
+ 142
40
+ 28
41
+ 18
42
+ 10
43
+ 59
44
+ 109
45
+ 114
46
+ 47
47
+ 135
48
+ 92
49
+ 21
50
+ 79
51
+ 114
52
+ 29
53
+ 26
54
+ 97
55
+ 137
56
+ 15
57
+ 103
58
+ 37
59
+ 114
60
+ 100
61
+ 21
62
+ 54
63
+ 72
64
+ 28
65
+ 128
66
+ 14
67
+ 77
68
+ 8
69
+ 121
70
+ 94
71
+ 118
72
+ 50
73
+ 131
74
+ 126
75
+ 113
76
+ 10
77
+ 34
78
+ 107
79
+ 63
80
+ 90
81
+ 8
82
+ 9
83
+ 137
84
+ 58
85
+ 118
86
+ 89
87
+ 116
88
+ 115
89
+ 136
90
+ 28
91
+ 38
92
+ 20
93
+ 85
94
+ 55
95
+ 128
96
+ 137
97
+ 82
98
+ 59
99
+ 117
100
+ 20
data/test.txt ADDED
The diff for this file is too large to render. See raw diff
 
data/testdata.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/testinglabels.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/train.txt ADDED
The diff for this file is too large to render. See raw diff
 
data/trainingdata.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/traininglabels.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/unnormalizedTestData.csv ADDED
The diff for this file is too large to render. See raw diff
 
flagged/log.csv ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Engine ID,Corrected Engine Core Speed (rpm),Total Temperature at HPC Outlet (��R),Total Pressure at HPC Outlet (psi),Remaining Engine Cycles,timestamp
2
+ 49,8143.4,1580,550,114,2022-03-05 16:44:29.560762
3
+ 25,8185.1,1580,550.73,53,2022-03-05 16:45:02.897992
4
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:09.490246
5
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:10.460939
6
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:11.042792
7
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:11.182306
8
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:11.498853
9
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:11.777722
10
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:11.845418
11
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:11.949375
12
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:12.087054
13
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:12.200811
14
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:12.370259
15
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:12.425313
16
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:12.656394
17
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:12.774354
18
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:12.878166
19
+ 100,8220.4,1607.5,555.84,94,2022-03-05 16:45:12.990679
20
+ 44,8220.4,1587.5,555.84,80,2022-03-05 16:45:40.342378
21
+ 1,8220.4,1607.5,555.84,66,2022-03-05 16:45:47.328482
22
+ 1,8220.4,1586.9,555.84,66,2022-03-05 16:45:49.222463
23
+ 1,8129,1586.9,555.84,43,2022-03-05 16:45:50.758329
24
+ 1,8129,1586.9,552.66,170,2022-03-05 16:45:52.357527
25
+ 100,8075,1605.7,550,11,2022-03-05 16:46:00.629897
26
+ 100,8075,1607.5,550,10,2022-03-05 16:46:02.347081
27
+ 1,8220.4,1580,555.84,54,2022-03-05 16:46:06.779748
28
+ 21,8192.1,1593.9,550.97,52,2022-03-05 16:46:15.408668
29
+ 1,8168.8,1593,552,99,2022-03-06 08:21:32.187968
30
+ 1,8168.8,1593,552,99,2022-03-06 08:21:33.080673
31
+ 95,8147,1580,554.12,148,2022-03-06 08:28:29.633487