我想使用 R 中的受限玻尔兹曼机 (RBM) 计算我的数据集的准确性。我已经从 Github 安装了 rbm 包;Timo Matzen,以便在我的编码中使用我自己的数据集的包。我在训练和测试我的数据集方面取得了成功。但是,当我在 R 中运行 PredictRBM 函数时,我无法计算 rbm 准确度。我不知道获得准确度的错误是什么。我的训练数据集和测试数据集的行数和列数已经相同。
我为 CSV 文件创建了 trainX.csv、trainY.csv、testX.csv、testY.csv 并将其上传到我的 R 编码中。所有数据集都具有相同数量的列和行。然后,我在从 GitHub 安装的包中使用 RBM 方法训练和测试所有数据集 CSV 文件。训练和测试数据集已成功运行。但是,当我尝试运行 PredictRBM 函数时,出现了一个错误,它可能引用了数据集中的 i 和 j 列。因此,我无法使用 RBM 方法计算数据集的准确性。
#First install devtools
install.packages("devtools")
#Load devtools
library(devtools)
#install RBM
install_github("TimoMatzen/RBM",force = TRUE)
#load RBM
library(RBM)
trainX <- read.csv('C:\\Users\\DefaultUser.DESKTOP-9JB0E7L\\Desktop\\project R\\trainX.csv')
trainY <-read.csv('C:\\Users\\Default User.DESKTOP-9JB0E7L\\Desktop\\projectR\\trainY.csv')
testX <- read.csv('C:\\Users\\DefaultUser.DESKTOP-9JB0E7L\\Desktop\\project R\\testX.csv')
testY <-read.csv('C:\\Users\\Default User.DESKTOP-9JB0E7L\\Desktop\\projectR\\testY.csv')
attrainX <- as.matrix(trainX)
attrainY <- as.matrix(trainY)
atestX <-as.matrix(testX)
atestY <- as.matrix(testY)
#First get the train data from trainX
train <- attrainX
#Then fit the model
modelRBM <- RBM(x = train, n.iter = 1000, n.hidden = 100, size.minibatch = 10)
#Get the test data from testX
test <- atestX
#First get the train labels of trainY
TrainY <- attrainY
#This time we add the labels as the y argument
modelClassRBM <- RBM(x = train, y = TrainY , n.iter = 1000, n.hidden = 100, size.minibatch = 10)
#First get the test labels of testY
TestY <- atestY
#Give our ClassRBM model as input
PredictRBM(test = test, labels = TestY, model = modelClassRBM)
我希望使用 RBM 方法使用 PredictRBM 函数获得数据集的准确性:PredictRBM(test = test, labels = TestY, model = modelClassRBM)
但是,有一个错误是:
#Give our ClassRBM model as input PredictRBM(test = test, labels = TestY, model = modelClassRBM) Error in `[<-`(`*tmp*`, , 12, value =0): subscript out of bounds '''
你知道为什么会出现这些错误吗?先感谢您。