LucasPinhheiro commited on
Commit
d4d77ca
·
1 Parent(s): 7df4657

edit to lab2 exercise

Browse files
app/evaluate.csv CHANGED
@@ -1,11 +1,11 @@
1
  temperature,pressure,diagnosis
2
- 77,153,N
3
- 93,170,N
4
- 87,43,P
5
- 49,198,P
6
- 110,30,P
7
- 68,142,N
8
- 104,38,P
9
- 55,175,P
10
- 82,157,N
11
- 96,55,P
 
1
  temperature,pressure,diagnosis
2
+ 11,177,P
3
+ 11,193,P
4
+ 63,176,P
5
+ 96,119,P
6
+ 10,176,P
7
+ 28,177,P
8
+ 11,125,A
9
+ 62,81,N
10
+ 53,190,P
11
+ 99,197,P
app/factory_predictor.py CHANGED
@@ -2,10 +2,11 @@ import pandas as pd
2
  from sklearn.linear_model import LogisticRegression
3
  from sklearn.preprocessing import LabelEncoder
4
  from sklearn.metrics import accuracy_score
 
5
 
6
  class FactoryPredictor:
7
  def __init__(self):
8
- self.model = LogisticRegression()
9
  self.le_diagnosis = LabelEncoder()
10
  self.temperature = 0
11
  self.pressure = 0
@@ -59,10 +60,6 @@ class FactoryPredictor:
59
  [[temperature, pressure]],
60
  columns=['temperature', 'pressure'])
61
 
62
- # Make prediction
63
  prediction = self.model.predict(input_data)
64
-
65
- # Decode prediction
66
- diagnosis = self.le_diagnosis.inverse_transform(prediction)[0]
67
-
68
  return diagnosis
 
2
  from sklearn.linear_model import LogisticRegression
3
  from sklearn.preprocessing import LabelEncoder
4
  from sklearn.metrics import accuracy_score
5
+ from sklearn.tree import DecisionTreeRegressor
6
 
7
  class FactoryPredictor:
8
  def __init__(self):
9
+ self.model = DecisionTreeRegressor()
10
  self.le_diagnosis = LabelEncoder()
11
  self.temperature = 0
12
  self.pressure = 0
 
60
  [[temperature, pressure]],
61
  columns=['temperature', 'pressure'])
62
 
 
63
  prediction = self.model.predict(input_data)
64
+ diagnosis = self.le_diagnosis.inverse_transform([int(round(prediction[0]))])[0]
 
 
 
65
  return diagnosis
app/static/gallery/factory-ai.html CHANGED
@@ -17,6 +17,7 @@
17
  <state-pane-oid initial="N" subscribe="update/alert~state">
18
  <image-oid id="N" source="assets:images/light-green.svg"></image-oid>
19
  <image-oid id="P" source="assets:images/light-red.svg"></image-oid>
 
20
  </state-pane-oid>
21
  </span>
22
  <span id="train" style="width: 20%; display: inline-block; vertical-align: middle">
 
17
  <state-pane-oid initial="N" subscribe="update/alert~state">
18
  <image-oid id="N" source="assets:images/light-green.svg"></image-oid>
19
  <image-oid id="P" source="assets:images/light-red.svg"></image-oid>
20
+ <image-oid id="Y" source="assets:images/light-yellow.svg"></image-oid>
21
  </state-pane-oid>
22
  </span>
23
  <span id="train" style="width: 20%; display: inline-block; vertical-align: middle">
app/test.csv CHANGED
@@ -1,11 +1,31 @@
1
  temperature,pressure,diagnosis
2
- 70,145,N
3
- 88,162,N
4
- 83,158,N
5
- 97,47,P
6
- 53,188,P
7
- 45,200,P
8
- 105,35,P
9
- 65,140,N
10
- 102,42,P
11
- 58,182,P
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  temperature,pressure,diagnosis
2
+ 11,177,P
3
+ 11,193,P
4
+ 63,176,P
5
+ 96,119,P
6
+ 10,176,P
7
+ 28,177,P
8
+ 11,125,A
9
+ 62,81,N
10
+ 53,190,P
11
+ 99,197,P
12
+ 41,157,P
13
+ 79,68,N
14
+ 41,111,N
15
+ 77,133,A
16
+ 64,158,P
17
+ 84,40,A
18
+ 65,180,P
19
+ 26,188,P
20
+ 47,71,N
21
+ 33,128,A
22
+ 78,36,P
23
+ 79,173,P
24
+ 95,119,P
25
+ 20,141,A
26
+ 25,89,N
27
+ 82,142,A
28
+ 68,31,P
29
+ 79,158,P
30
+ 89,77,A
31
+ 12,169,P
app/train.csv CHANGED
@@ -1,17 +1,101 @@
1
  temperature,pressure,diagnosis
2
- 75,150,N
3
- 80,155,N
4
- 72,148,N
5
- 85,160,N
6
- 78,152,N
7
- 90,165,N
8
- 95,50,P
9
- 100,45,P
10
- 85,40,P
11
- 92,48,P
12
- 98,52,P
13
- 50,180,P
14
- 55,190,P
15
- 48,195,P
16
- 60,185,P
17
- 52,192,P
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  temperature,pressure,diagnosis
2
+ 61,94,N
3
+ 24,118,N
4
+ 81,100,A
5
+ 70,38,P
6
+ 30,117,N
7
+ 92,158,P
8
+ 96,165,P
9
+ 84,92,A
10
+ 84,168,A
11
+ 97,110,P
12
+ 33,165,P
13
+ 12,192,P
14
+ 31,192,P
15
+ 62,62,N
16
+ 11,152,P
17
+ 97,34,P
18
+ 39,70,N
19
+ 47,57,N
20
+ 11,164,P
21
+ 73,101,N
22
+ 69,41,A
23
+ 30,191,P
24
+ 42,62,N
25
+ 85,77,A
26
+ 67,180,P
27
+ 31,91,N
28
+ 98,66,P
29
+ 58,128,A
30
+ 100,133,A
31
+ 68,64,N
32
+ 51,130,A
33
+ 69,160,P
34
+ 89,30,A
35
+ 24,34,P
36
+ 71,171,P
37
+ 71,132,A
38
+ 56,56,N
39
+ 71,166,P
40
+ 60,44,A
41
+ 64,119,N
42
+ 73,71,N
43
+ 12,153,P
44
+ 60,92,N
45
+ 16,125,A
46
+ 30,81,N
47
+ 82,125,A
48
+ 48,161,P
49
+ 27,180,P
50
+ 13,172,P
51
+ 98,200,P
52
+ 69,58,N
53
+ 23,65,N
54
+ 18,42,A
55
+ 99,189,P
56
+ 62,100,N
57
+ 11,115,P
58
+ 93,57,P
59
+ 69,95,N
60
+ 80,199,P
61
+ 53,74,N
62
+ 17,91,A
63
+ 56,163,P
64
+ 44,57,N
65
+ 87,57,A
66
+ 90,137,A
67
+ 45,73,N
68
+ 59,113,N
69
+ 13,59,P
70
+ 11,104,P
71
+ 15,157,A
72
+ 63,121,A
73
+ 13,158,P
74
+ 63,150,A
75
+ 72,56,N
76
+ 27,150,A
77
+ 99,145,A
78
+ 53,32,P
79
+ 43,132,A
80
+ 83,184,A
81
+ 71,166,P
82
+ 23,91,N
83
+ 57,194,P
84
+ 24,80,N
85
+ 81,181,A
86
+ 87,88,A
87
+ 96,147,A
88
+ 71,189,P
89
+ 49,125,A
90
+ 94,142,A
91
+ 89,91,A
92
+ 91,81,P
93
+ 62,41,A
94
+ 33,68,N
95
+ 35,159,P
96
+ 98,160,P
97
+ 69,142,A
98
+ 50,130,A
99
+ 38,142,A
100
+ 24,110,N
101
+ 54,142,A