[R] Help needed with Traininig a Neural Network
Bonita Willams
bonitajo at gmail.com
Mon Apr 27 04:55:38 CEST 2015
I am attempting to train a dataset but am having a hard time. I am using a
dataset from UCI *archive.ics.uci.edu/ml/datasets/Congressional+Voting+Records
<http://archive.ics.uci.edu/ml/datasets/Congressional+Voting+Records> *. I
am attempting to replicate a study which predicts the political party of
Congress members based on their voting records.
Below is some of what I have accomplished.
>dataset <- read.csv(“ucidatasethouse.vote.84.data”)
> trainset <- dataset[1:305,]
>testset <- dataset[306:435, ]
(1.) *I trained the neural net model*
> polpartynet <- neuralnet(Party ~ HandInfants + WaterProject + AdoptBudget
+ DocFeeFreeze + ElSalvadorAid + ReligiousGroupsSchools + AntiSatellTestBan
+ AidNicaraguaContras + MXMissile + Immigration + SynCorpCutback +
EducationSpending + SuperfundRighttoSue + Crime + DutyFreeExports +
ExportAdminSouthAfrica, trainset, hidden = 4, lifesign = "minimal",
linear.output = FALSE, threshold = 0.1)
hidden: 4 thresh: 0.1 rep: 1/1 steps: 16 error:
58.57427 time: 0.16 secs
(2.) *I put this together but not sure of what I was supposed to get*
> polpartynettestset.results <- compute(polpartynet, testset)
(3.) * The Training set which contains all of the columns is ‘trainset’
> colnames(trainset)
[1] "Party" "HandInfants" "WaterProject"
[4] "AdoptBudget" "DocFeeFreeze" "ElSalvadorAid"
[7] "ReligiousGroupsSchools" "AntiSatellTestBan" "AidNicaraguaContras"
[10] "MXMissile" "Immigration" "SynCorpCutback"
[13] "EducationSpending" "SuperfundRighttoSue" "Crime"
[16] "DutyFreeExports" "ExportAdminSouthAfrica"
(4.) *I removed “Party” column from the testset based but this may
have been a bad move?*** What should I do????
> colnames(testset)
[1] "HandInfants" "WaterProject" "AdoptBudget"
[4] "DocFeeFreeze" "ElSalvadorAid" "ReligiousGroupsSchools"
[7] "AntiSatellTestBan" "AidNicaraguaContras" "MXMissile"
[10] "Immigration" "SynCorpCutback" "EducationSpending"
[13] "SuperfundRighttoSue" "Crime" "DutyFreeExports"
[16] "ExportAdminSouthAfrica"
(5.) ***I would like to create a formula which will provide me neural
network results***
> results <- data.frame(actual = testset$Party, prediction = polpartynettestset.results)
Error in data.frame(actual = testset$Party, prediction =
polpartynettestset.results) :
arguments imply differing number of rows: 0, 130
(6.) I would like to be able to round to the nearest integer to
improve readability. This is what I have tried so far…
> results$Party <- round(results$Party)
Error: object 'results' not found
> results[306:435]
Error: object 'results' not found
> polpartynettestset.results$Party <- round(polpartynettestset.results$Party)
Error in round(polpartynettestset.results$Party) :
non-numeric argument to mathematical function
I appreciate any help that you can provide. It is possible that I am
missing something but will happily add it if you ask. I feel like a
dog chasing its tail.
Bonita Williams
bonitajo at gmail.com
[[alternative HTML version deleted]]
More information about the R-help
mailing list