带包实现:
rm(list=ls()) setwd("C:/Users/Administrator/Desktop/R语言与数据挖掘作业/实验4-人工神经网络") Data=read.csv("sales_data.csv")[,2:5] library(nnet) colnames(Data)<-c("x1","x2","x3","y") model1=nnet(y~.,data=Data,size=6,decay=5e-4,maxit=1000) pred=predict(model1,Data[,1:3],type="class") (p=sum(as.numeric(pred==Data$y))/nrow(Data)) table(Data$y,pred) prop.table(table(Data$y,pred),1)
原文地址:https://www.cnblogs.com/caiyishuai/p/9928186.html
时间: 2024-11-08 16:37:00