Example #1
0
def test_extended_inputs():
    inputs = np.array([[3]])
    assert np.all(utils.extended_inputs(inputs) == np.array([[1, 3]]))

    inputs = np.array([[3], [4]])
    assert np.all(utils.extended_inputs(inputs) == np.array([[1, 3], [1, 4]]))

    inputs = np.array([[3, 4, 5], [6, 7, 8]])
    assert np.all(
        utils.extended_inputs(inputs) == np.array([[1, 3, 4, 5], [1, 6, 7, 8]
                                                   ]))
Example #2
0
def normal_equation(inputs, outputs):
    X = utils.extended_inputs(inputs)
    theta = np.linalg.inv(X.T @ X) @ X.T @ outputs
    return theta
Example #3
0
def linear_model(theta, inputs):
    inputs_extended = utils.extended_inputs(inputs)
    return inputs_extended @ theta
Example #4
0
def jacobien_rms(theta, inputs, outputs, model):
    n_samples = outputs.shape[0]
    return 1 / n_samples * (
        (model(theta, inputs) - outputs) @ utils.extended_inputs(inputs))
Example #5
0
def logistic_model(theta, inputs):
    inputs_extended = utils.extended_inputs(inputs)
    return sigmoid(inputs_extended @ theta)