我如何计算除 MNIST 以外的更大数据集的 RBM 准确性以及 R Studio 中的简单编码是什么?
How do I calculate RBM accuracy for larger dataset other than MNIST and what is the simple coding in R Studio?
我尝试 运行 我在 R studio 中编码,但它无法产生准确的结果。你能帮我举个例子吗?编码以使用 RBM 方法预测 R Studio 中较大数据集的准确性?我的预期输出:1 但是我下面的代码在使用 RBM 方法预测我的数据集的准确性时有一些错误。
install.packages("devtools")
# Load devtools library(devtools)
# install RBM install_github("TimoMatzen/RBM")
# load RBM library(RBM)
Wednesdaydataset <- read.csv('C:\Users\FSKKP\Desktop\R iqa\dataset20181220T065754Z-001\dataset\Wednesday-workingHours.pcap_ISCX.csv')
Wednesdaydataset
class(Wednesdaydataset)
str(Wednesdaydataset)
Wednesdaydataset <-as.matrix(Wednesdaydataset)
Wednesdaydataset <-cbind(Wednesdaydataset)
class(Wednesdaydataset)
str(Wednesdaydataset)
view(Wednesdaydataset)
set.seed(1234)
ind<-sample(2,nrow(Wednesdaydataset),replace = TRUE,prob=c(0.7,0.30))
train.data<-Wednesdaydataset [ind==1,]
test.data<-Wednesdaydataset [ind==2,]
# First get the train data from train.data
train <- train.data$Active.Min
# Then fit the model
modelRBM <- RBM(x = train, n.iter = 1000, n.hidden = 100, size.minibatch = 10)
# First get the train labels of test.data
test <- test.data$Active.Min
# This time we add the labels as the y argument
modelClassRBM <- RBM(x = train, y = test, n.iter = 1000, n.hidden = 100, size.minibatch = 10)
# First get the test labels of test.data
test <- test.data$Active.Min
# Give our ClassRBM model as input
PredictRBM(test = test, labels = test, model = modelClassRBM)
你只需对对角线求和,然后除以总和:
# Some lables (like your outputs from RBM)
lab_true <- c("a", "a", "a", "b", "c")
lab_pred <- c("a", "b", "c", "b", "a")
# Making them into a confusion matrix
confusion_matrix <- table(lab_true, lab_pred)
# Calculating overall precision
overall_precision <- sum(diag(confusion_matrix))/sum(confusion_matrix)
我尝试 运行 我在 R studio 中编码,但它无法产生准确的结果。你能帮我举个例子吗?编码以使用 RBM 方法预测 R Studio 中较大数据集的准确性?我的预期输出:1 但是我下面的代码在使用 RBM 方法预测我的数据集的准确性时有一些错误。
install.packages("devtools")
# Load devtools library(devtools)
# install RBM install_github("TimoMatzen/RBM")
# load RBM library(RBM)
Wednesdaydataset <- read.csv('C:\Users\FSKKP\Desktop\R iqa\dataset20181220T065754Z-001\dataset\Wednesday-workingHours.pcap_ISCX.csv')
Wednesdaydataset
class(Wednesdaydataset)
str(Wednesdaydataset)
Wednesdaydataset <-as.matrix(Wednesdaydataset)
Wednesdaydataset <-cbind(Wednesdaydataset)
class(Wednesdaydataset)
str(Wednesdaydataset)
view(Wednesdaydataset)
set.seed(1234)
ind<-sample(2,nrow(Wednesdaydataset),replace = TRUE,prob=c(0.7,0.30))
train.data<-Wednesdaydataset [ind==1,]
test.data<-Wednesdaydataset [ind==2,]
# First get the train data from train.data
train <- train.data$Active.Min
# Then fit the model
modelRBM <- RBM(x = train, n.iter = 1000, n.hidden = 100, size.minibatch = 10)
# First get the train labels of test.data
test <- test.data$Active.Min
# This time we add the labels as the y argument
modelClassRBM <- RBM(x = train, y = test, n.iter = 1000, n.hidden = 100, size.minibatch = 10)
# First get the test labels of test.data
test <- test.data$Active.Min
# Give our ClassRBM model as input
PredictRBM(test = test, labels = test, model = modelClassRBM)
你只需对对角线求和,然后除以总和:
# Some lables (like your outputs from RBM)
lab_true <- c("a", "a", "a", "b", "c")
lab_pred <- c("a", "b", "c", "b", "a")
# Making them into a confusion matrix
confusion_matrix <- table(lab_true, lab_pred)
# Calculating overall precision
overall_precision <- sum(diag(confusion_matrix))/sum(confusion_matrix)