Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do a grid-search over a predefined range of the parameters. Loop over all possible combinations of parameters, estimate the accuracy of your model using K-Folds

Do a grid-search over a predefined range of the parameters. Loop over all possible combinations of parameters, estimate the accuracy of your model using K-Folds cross-validation, and then choose the parameter combination that produces the highest validation accuracy.

image text in transcribed

TO DO 1:

from sklearn.model_selection import cross_val_score, GridSearchCV grid=None # ToDo: replace it to proper GridSearchCV object and run the grid search with cross validation

# complete your code here

TO DO 2: The GridSearchCV object scores, among other things, the best combination of parameters as well as the cross-validation accuracy achieved with those parameters. Print those quantities for our model.

TO DO 3: The GridSearchCV object also stores the classifier trained with the best hyperparameters. Pass this best estimator into the nonlinear_plot function to view the best decision boundary. What can you tell about the best decision boundary?

DATA TO BE USED:

def part3data(N=100, seed=1235): np.random.seed(seed) X = np.random.uniform(-1,1,(N,2)) y = np.array([1 if y-x > 0 else -1 for (x,y) in zip(X[:,0]**2 * np.sin(2*np.pi*X[:,0]), X[:,1])]) X = X + np.random.normal(0,.1,(N,2)) return X, y

X, y = part3data(N=300, seed=1235)

MODEL TO BE USED:

nlsvm = SVC(kernel="rbf", C=1, gamma=1) nlsvm.fit(X, y)

Part A: Below is an experiment where we search over a logarithmic range between 25 and 25 for C and a range between 25 and 25 for . For the accuracy measure we use K-Folds CV with K=3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago