Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.2 Splitting our dataset into training data and test data [ ]: from sklearn.cross_validation import train_test_split X_train, X_test, y_train, y_test = train_test_split cancer_dataset [ 'data'],

image text in transcribed

2.2 Splitting our dataset into training data and test data [ ]: from sklearn.cross_validation import train_test_split X_train, X_test, y_train, y_test = train_test_split cancer_dataset [ 'data'], cancer_dataset [ 'target' ], random_state =0 ) 2.3 K Nearest Neighbours We will now learn how to build a classification model for the breast cancer dataset with the use of the k nearest neighbours algorithm. Building and evaluating the model for 1 nearest neighbour Run the code below to create a KNeighborsClassifier model called knn_model. Note that n_neighbors =1 is setting the number of nearest neighbours to 1 . [ ]: from sklearn.neighbors import KNeighborsClassifier knn_model = KNeighborsClassifier (n_neighbors =1 ) knn_model.fit(X_train, y_train) [ ]: print("Test set score: {:.3f} ". format(knn_model.score(X_test, y_test))) Quiz Question 7 Write your code in the next cell(s) to build and evaluate a K Nearest Neighbours model for 5 neighbours. [ ]

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_2

Step: 3

blur-text-image_3

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

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

What are the main differences between rigid and flexible pavements?

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago

Question

6. Discuss the steps involved in conducting a task analysis.

Answered: 1 week ago

Question

8. Explain competency models and the process used to develop them.

Answered: 1 week ago