Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I just need answers for all TODO. I do not need any explanation in detail. Just only answer for all TODO Please. TODO 13 Complete

I just need answers for all TODO. I do not need any explanation in detail. Just only answer for all TODO Please.

TODO 13

Complete the TODO by getting our data, training the PocketPerceptron class and making predictions for our training and validation data.

Call the data_prep() function to get the setosa-vs-all data where the sepal length and width features are dropped. To do so, pass the arguments corresponding to the following descriptions:

Pass the Iris dataset.

Set setosa as the positive class.

Set versicolor and virginica to represent the negative class.

Set the column 'class' to act as the labels/targets.

Drop the 'sepal length' and 'sepal width' features.

Return all data as NumPy arrays.

Create an instance of the PocketPerceptron. Make sure to pass the arguments corresponding to the following descriptions:

Allow for training to occur for 10 passes over the data.

# TODO 13.1 data = X_trn, y_trn, X_vld, y_vld, _, _, feature_names = data

# TODO 13.2 perceptron =

perceptron.fit(X_trn, y_trn)

y_hat_trn = perceptron.predict(X_trn)

todo_check([ (np.all(feature_names == ['bias', 'petal length', 'petal width']), "features names for training and validation data incorrect! Make sure you dropped the right features."), (np.all(np.isclose(X_trn[4].flatten(), [1., 0.97932518, 1.17336698])), "'X_trn' values are incorrect"), (np.all(np.isclose(perceptron.w_best, np.array([-0.1254, -0.12089, -0.2218]), rtol=.1)), "best weight values potentially incorrect") ])

TODO 14

Complete the TODO by getting our data, training the PocketPerceptron class and making predictions for our training and validation data.

Call the data_prep() function to get the versicolor-vs-all data where the sepal length and width features are dropped. To do so, pass the arguments corresponding to the following descriptions:

Pass the Iris dataset.

Set versicolor as the positive class.

Set setosa and virginica to represent the negative class.

Set the column 'class' to act as the labels/targets.

Drop the 'sepal length' and 'sepal width' features.

Return all data as NumPy arrays.

Create an instance of the PocketPerceptron. Make sure to pass the arguments corresponding to the following descriptions:

Allow for training to occur for 10 passes over the data.

# TODO 14.1 data = X_trn, y_trn, X_vld, y_vld, _, _, feature_names = data

# TODO 14.2 perceptron =

perceptron.fit(X_trn, y_trn)

y_hat_trn = perceptron.predict(X_trn)

todo_check([ (np.all(feature_names == ['bias', 'petal length', 'petal width']), "features names for training and validation data incorrect! Make sure you dropped the right features."), (np.all(np.isclose(X_trn[4].flatten(), [1., 0.95237765, 1.14980508])), "'X_trn' values are incorrect"), (np.all(np.isclose(perceptron.w_best, np.array([-0.02545988, 0.26595776, -0.2066903 ]), rtol=.1)), "best weight values potentially incorrect") ])

TODO 15

Complete the TODO by getting our data, training the PocketPerceptron class and making predictions for our training and validation data.

Call the data_prep() function to get the versicolor-vs-all data. To do so, pass the arguments corresponding to the following descriptions:

Pass the Iris dataset.

Set versicolor as the positive class.

Set setosa and virginica to represent the negative class.

Set the column 'class' to act as the labels/targets.

Return all data as NumPy arrays.

Create an instance of the PocketPerceptron. Make sure to pass the arguments corresponding to the following descriptions:

Allow for training to occur for 10 passes over the data.

# TODO 15.1 data = X_trn, y_trn, X_vld, y_vld, _, _, feature_names = data

# TODO 15.2 perceptron =

perceptron.fit(X_trn, y_trn)

y_hat_trn = perceptron.predict(X_trn)

todo_check([ (np.all(np.isclose(X_trn[4].flatten(), [1., 1.13365878, -0.15635243, 0.95237765, 1.14980508])), "'X_trn' values are incorrect"), (np.all(np.isclose(perceptron.w_best, np.array([-0.12545988, 0.15590326, -0.25504385, 0.18552363, -0.2858944 ]), rtol=.1)), "best weight values potentially incorrect") ])

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

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions