1

I want to calculate the accuracy of my dataset using Restricted Boltzman Machine (RBM) in R. I have installed rbm packages from Github; Timo Matzen in order to use the package in my coding with my own dataset. I have success in training and testing my dataset. However, I am not able to calculate the rbm accuracy when I run the PredictRBM function in R. I don't know what is the error to obtain the accuracy. My number of rows and columns for both train and test dataset is already the same.

I have created for CSV files which is trainX.csv, trainY.csv, testX.csv, testY.csv and upload it in my R coding. All of the dataset have same number of colums and rows. Then, I have train and test all of the dataset CSV files using RBM method in packages installed from GitHub. The train and testing dataset is successfully run. However, when I tried to run the PredictRBM function, there is an error which may refer to the i and j columns in dataset. So, I could not calculate the accuracy of dataset using RBM method.

#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)

I expect to obtain the accuracy of dataset using RBM method using PredictRBM function : PredictRBM(test = test, labels = TestY, model = modelClassRBM) However, there is an error which is :

#Give our ClassRBM model as input  
PredictRBM(test = test, labels = TestY, model = modelClassRBM)
Error in `[<-`(`*tmp*`, , 12, value =0): subscript out of bounds '''

Do you know why these error appear? Thank you in advance.

This is my output if it does not have error This is my output if it does not have error

Shijith
  • 4,602
  • 2
  • 20
  • 34
  • How does your data differ from the working examples in the documentation? Can you please properly format your code chunk (remove `>` where not necessary, comment non-executable code, remove `*` where not appropriate...)? – Roman Luštrik Apr 25 '19 at 06:54
  • thank you for your suggestion. My post has been edited. I would like to ask for your help on how to get the dataset accuracy using RBM method. I have an error if I run the PredictRBM function in R. Do you know why does the error appear ? – Syafiqah Zaidi Apr 27 '19 at 03:36

0 Answers0