- fit:
- 对于 kmeans 来说,fit 的过程,就是训练,自然所需的参数,主要是数据集和聚类中心数,
1. classification(分类)
def train(train_images, train_labels):
# build a model for images -> labels ...
return model
def predict(model, test_images):
# predict the test_labels using the model ...
return test_labels
- 需要给定,训练样本(数据及其 label),显然这是一种数据驱动型的方法(data-driven approach)
如果以类的形式封装的话:
class Clf():
def __init__(self):
pass
def train(self, X, y):
self.Xtr = X
self.ytr = y
def predict(self, X):
return y_pred