For classification-based projects, the dependent variable can be binary or can have multiple levels, such as credit card fraud detection, classification of customers into different clusters as far as the marketing is concerned, and so on. In the current scenario from the ArtPiece
dataset, we are trying to predict whether a work of art is a good purchase, or not, by taking a few business-relevant variables. For demo purposes, we have considered only a few features, but other features present in the dataset can be used to generate a better result:
> fit<-neuralnet(IsGood.Purchase_1~Brush.Size_1+Brush.Size_2+Brush.Size_3+ + Brush.Finesse_Coarse+Brush.Finesse_Fine+ + Art.Nationality_American+Art.Nationality_Asian+ + Art.Nationality_European+GoodArt.check_YES,data=train[1:2000,], + hidden = 25,err.fct = "ce",linear.output = F) > fit Call: neuralnet(formula = IsGood.Purchase_1 ~ Brush.Size_1 + Brush.Size_2 + Brush.Size_3 + Brush.Finesse_Coarse + Brush.Finesse_Fine + Art.Nationality_American + Art.Nationality_Asian + Art.Nationality_European + GoodArt.check_YES, data = train[1:2000, ], hidden = 25, err.fct = "ce", linear.output = F) 1 repetition was calculated. Error Reached Threshold Steps 1 666.1522488 0.009864324362 8254 > output<-cbind(fit$covariate,fit$result.matrix[[1]]) > head(output) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1 0 0 0 1 0 0 1 0 666.1522488 [2,] 1 0 0 0 1 1 0 0 0 666.1522488 [3,] 1 0 0 0 1 0 0 1 0 666.1522488 [4,] 0 1 0 1 0 0 0 1 0 666.1522488 [5,] 0 1 0 1 0 1 0 0 0 666.1522488 [6,] 1 0 0 0 1 1 0 0 0 666.1522488
The following graph shows the neural network model for classification:
Using another library, nnet
, for classification-based problems, the following result is derived:
> fit.nnet<-nnet(factor(IsGood.Purchase_1)~Brush.Size_1+Brush.Size_2+Brush.Size_3+ + Brush.Finesse_Coarse+Brush.Finesse_Fine+ + Art.Nationality_American+Art.Nationality_Asian+ + Art.Nationality_European+GoodArt.check_YES,data=train[1:2000,], + size=9) # weights: 100 initial value 872.587818 iter 10 value 684.034783 iter 20 value 667.751170 iter 30 value 667.027963 iter 40 value 666.337669 iter 50 value 666.156889 iter 60 value 666.138741 iter 70 value 666.137048 iter 80 value 666.136505 final value 666.136439 converged > fit.nnet a 9-9-1 network with 100 weights inputs: Brush.Size_1 Brush.Size_2 Brush.Size_3 Brush.Finesse_Coarse Brush.Finesse_Fine Art.Nationality_American Art.Nationality_Asian Art.Nationality_European GoodArt.check_YES output(s): factor(IsGood.Purchase_1) options were - entropy fitting
13.58.50.156