Skip to content

Typo in err_array #18

Description

@Maqil

the function dataset3Params on Excercice6 declares an array calls 'my_array' but uses another undeclared one called 'err_array'

`def dataset3Params(X, y, Xval, yval):
C = 1
sigma = 0.3
# ====================== YOUR CODE HERE ======================

C_array = np.array([0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30])
sigma_array = np.array([0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30])

**my_array** = np.zeros([C_array.size, sigma_array.size])

for i in np.arange(C_array.size):
    for j in np.arange(sigma_array.size):
        model= utils.svmTrain(X, y, C_array[i], gaussianKernel, args=(sigma_array[j],))
        predictions = utils.svmPredict(model, Xval)
        pred_error = np.mean(predictions != yval)
        
        **err_array**[i, j] = pred_error
    
ind = np.unravel_index(np.argmin(err_array, axis = None), err_array.shape)
C = C_array[ind[0]]
sigma = sigma_array[ind[1]]

# ============================================================
return C, sigma`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions