knn in r script in power bi desktop

时间:2017-08-04 12:37:06

标签: r knn

I have been putting r code concerning knn into the power bi r script. In r studio it was kind of working but in power b it says errors error is cause by last line:

# 'dataset' holds the input data for this script
normalize <- function(x) {
 return ((x - min(x)) / (max(x) - min(x))) }
mpg_n <- as.data.frame(lapply(c(3,5,8,9), normalize))
mpg_train<-mpg_n[101:234,]
mpg_test<-mpg_n[1:100,]
mpg_train_labels<-mpg_n[101:234,2]
mpg_test_labels<-mpg_n[1:100,2]
install.packages("class")
install.packages("kknn")
library("class")
library("kknn")
mpg_test_pred <- knn(train = mpg_train, test = mpg_test,cl= mpg_train_labels, k = 12)

the error announcement is following:

     Błąd w poleceniu 'knn(train = mpg_train, test = mpg_test, cl = mpg_train_labels, ':
  żadne brakujące wartości nie są dozwolone
Wykonywanie wstrzymane

Details:
    DataSourceKind=R
    DataSourcePath=R
    Message=R script error.
Instalowanie pakietu w &#39;C:/Users/bancyr/AppData/Local/Radio/Library&#39;
(ponieważ &#39;lib&#39; nie jest określony)
pr&#243;bowanie adresu URL &#39;https://mran.microsoft.com/snapshot/2017-05-01/bin/windows/contrib/3.4/class_7.3-14.zip&#39;
Content type &#39;application/zip&#39; length 106322 bytes (103 KB)
==================================================
downloaded 103 KB

Instalowanie pakietu w &#39;C:/Users/bancyr/AppData/Local/Radio/Library&#39;
(ponieważ &#39;lib&#39; nie jest określony)
pr&#243;bowanie adresu URL &#39;https://mran.microsoft.com/snapshot/2017-05-01/bin/windows/contrib/3.4/kknn_1.3.1.zip&#39;
Content type &#39;application/zip&#39; length 334769 bytes (326 KB)
==================================================
downloaded 326 KB

Błąd w poleceniu &#39;knn(train = mpg_train, test = mpg_test, cl = mpg_train_labels, &#39;:
  żadne brakujące wartości nie są dozwolone
Wykonywanie wstrzymane

    ErrorCode=-2147467259
    ExceptionType=Microsoft.PowerBI.Radio.RScriptRuntimeException

0 个答案:

没有答案