def computeError(trainingSamples, weights, classifier):
    """
    Compute error.
    
    :param trainingSamples: Training samples.
    :param weights: Sample weights.
    :param classifier: Weak classifier.
    
    :return: Error
    """
    error = 0
    for i in range(0, len(trainingSamples)):
        sample = trainingSamples[i]
        error += weights[i]*(classifier.classify(sample[0], 0, 0) != sample[1])
        
    # used dataset is very small so it is possible to have error = 0, in this case set error to small value so program
    # does not fail
    if error == 0:
        error = 0.001
    return error