Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in the following R program, the plot is not fully satisfactory. Find a way to shade the red region, say, rather than show it as

in the following R program, the plot is not fully satisfactory.

Find a way to shade the red region, say, rather than show it as red crosses.

Then there will be no need to show the green region - it will just be white.

Try making other improvements as they occur to you, such as including a legend or distinguishing data points which were misclassified!

NewProbeKnnBig =

function (TrialX, ProbeX, TrialY, k)

{

library(class)

ProbeYhat = knn(TrialX,ProbeX,TrialY,k)

MinX = min(TrialX)

MaxX = max(TrialX)

ProbeColor = c(cbind(ProbeYhat)+1)

plot(ProbeX[,1],ProbeX[,2],

main=c("knn Classification Space", k),

xlab="X1",ylab="X2",

cex=2, pch=3,

col=ProbeColor,

xlim=c(MinX,MaxX),

ylim=c(MinX,MaxX))

par(new=TRUE)

plot(TrialX[,1],TrialX[,2],

ann=FALSE,

pch=".",

col=c(cbind(TrialY)+17),

xlim=c(MinX,MaxX),

ylim=c(MinX,MaxX),

cex=2)

return()

}

image text in transcribed
\f

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

An Introduction to the Mathematics of Financial Derivatives

Authors: Ali Hirsa, Salih N. Neftci

3rd edition

012384682X, 978-0123846822

More Books

Students also viewed these Mathematics questions