[R] "ipredknn" - How may I find values?

Max Kuhn mxkuhn at gmail.com
Tue Oct 27 14:34:30 CET 2009


I think we are having some difficulty understanding what you are
looking for. If you are looking to find which of the training samples
were closest to the prediction sample, I don't think that you can get
it from this function.

If this is what you want, I use the dist function in the proxy package.

Max

On Tue, Oct 27, 2009 at 8:46 AM, David Winsemius <dwinsemius at comcast.net> wrote:
>
> On Oct 27, 2009, at 6:02 AM, Grzes wrote:
>
>>
>> Hi everybody!
>>
>> I want to find a closer neighbourins observation. This is my code:
>> ##########################
>> library(klaR)
>> library(ipred)
>> library(mlbench)
>> data(PimaIndiansDiabetes2)
>> dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
>> dane[,2]=log(dane[,2])
>> dane[,1:2]=scale(dane[,1:2])
>> zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)
>>
>>
>> klasyfikatorKNN=ipredknn(diabetes~glucose+insulin,data=dane,subset=zbior.uczacy,k=3)
>>
>> oceny=predict(klasyfikatorKNN,dane[-zbior.uczacy,],"class")
>>
>> #data frames with my result from klasyfikatorKNN
>>
>> df=data.frame(glucose=c(klasyfikatorKNN$learn$X[,1]),insulin=klasyfikatorKNN$learn$X[,2],diabetes=c(klasyfikatorKNN$learn$y))
>> #And picture
>> drawparti(as.factor(df$diabetes), df$glucose, df$insulin, method = "sknn",
>> prec = 100, xlab = NULL, ylab = NULL)
>
> I get an error: Error: could not find function "drawparti"
>
>>
>> ##########################
>> My question is:  How or where may I find correct or wrong values which
>> were
>> drawn (found,classification) in this picture?
>
> No picture resulted.
>
>> It means I'm looking for  x, y
>> values.
>
> Not sure exactly what you are asking. Does this modification to df and
> fairly obvious the cross table help?
>
>>
>> df=data.frame(glucose=c(klasyfikatorKNN$learn$X[,1]),insulin=klasyfikatorKNN$learn$X[,2],pred.diabetes=klasyfikatorKNN$learn$y,
>> trueDiab=dane[,3])
> Warning message:
> In data.frame(glucose = c(klasyfikatorKNN$learn$X[, 1]), insulin =
> klasyfikatorKNN$learn$X[,  :
>  row names were found from a short variable and have been discarded
>> with( df, table(pred.diabetes, trueDiab))
>             trueDiab
> pred.diabetes neg pos
>          neg 174  86
>          pos  88  44
>
>
>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/%22ipredknn%22---How-may-I-find-values--tp26074994p26074994.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 

Max



More information about the R-help mailing list