def test_load(self): examples = train_example.load() print("X length: ", len(examples[0].x)) print("Y length: ", len(examples[0].y)) self.assertEqual(len(examples), 1)
def train(): examples = train_example.load() # Split examples in train and validation using 5-fold print("examples size:", len(examples)) wLength = len(examples[0].x[0].coref.feat) w = np.array([0]*wLength) w = perceptron.structured(w, examples, test=None, epochs=38, argmax=quotation.argmax, phi=quotation.phi) return w
def calibration(): examples = train_example.load() # Split examples in train and validation using 5-fold print("examples size:", len(examples)) kf = KFold(len(examples), n_folds=5) wLength = len(examples[0].x[0].coref.feat) for trainIndex, testIndex in kf: train = [ examples[e] for e in trainIndex ] print("\n\ntrain size:", len(train)) validation = [ examples[e] for e in testIndex ] print("validation size:", len(validation)) w = np.array([0]*wLength) w = perceptron.structured(w, train, test=validation, epochs=65, argmax=quotation.argmax, phi=quotation.phi)