(self, x)
| 49 | return -x*(first-second) + self.weight_lambda*self.w[j] |
| 50 | |
| 51 | def predict_(self, x): |
| 52 | result = np.dot(self.w,x) |
| 53 | row, column = result.shape |
| 54 | |
| 55 | # 找最大值所在的列 |
| 56 | _positon = np.argmax(result) |
| 57 | m, n = divmod(_positon, column) |
| 58 | |
| 59 | return m |
| 60 | |
| 61 | def train(self, features, labels): |
| 62 | self.k = len(set(labels)) |