示例#1
0
def calibration():
    """Calibrates the model.

    It uses default values for epochs and n-folds.
    """
    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)
示例#2
0
def train():
	"""Train the model, based of the default GloboQuotes dataset.

    Returns:
        The w model trained.
    """
	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
示例#3
0
def calibration():
	"""Calibrates the model.

    It uses default values for epochs and n-folds.
    """
	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)
示例#4
0
def train():
    """Train the model, based of the default GloboQuotes dataset.

    Returns:
        The w model trained.
    """
    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