Thank you. For an unscientific, rough benchmark, it runs in 12.4 seconds on my machine vs the F# version which runs in 44 seconds. I was surprised. In other unrelated use cases, I was finding .NET to be faster than J. This an example where J really shines. Your code is compact and readable too. I will study it and may try my own implementation. Thanks for the link to the PDF as well.
On Wed, Jun 11, 2014 at 2:22 AM, Jan-Pieter Jacobs < [email protected]> wrote: > 2014-06-11 4:07 GMT+02:00 Joe Bogner <[email protected]>: > > Thanks Jan-Pieter, how would I recreate the results of the calculating > the > > % correct with yours? I will give it a shot on my own still later.. I > > pasted some code to help jumpstart the reading of the array of data: > > > > Thanks for the info! > > I just tried the classification of the data and this is what I get: > > NB. transformed your loader into a reusable verb. > parsefile =: 3 : 0 > file =. fread y > header_end =. >: file i. LF > arr =. ". ];._2 header_end }. file > ) > > NB. Load training and validation labels and data > Train =: parsefile jpath '~temp/trainingsample.csv' > Validation =: parsefile jpath '~temp/validationsample.csv' > > NB. separate labels (1st column) from data (the rest) > 'TrainLabels TrainData' =: ({."1 ; }."1) Train > 'ValidationLabels ValidationData'=: ({."1 ; }."1) Validation > > NB. Classify one against all: > predicted =: 10 nnClass oaa TrainLabels;TrainData;ValidationData > > NB. Assess the accuracy of our result: > OA =: 100 * (+/%#)@:= > > predicted OA ValidationLabels > 93.6 > > I'd like to recommend the book that started me on implementing this all: > Elements of Statistical Learning > Trevor Hastie, Robert Tibshirani, Jerome Friedman > PDF Freely (legally too) available via > http://statweb.stanford.edu/~tibs/ElemStatLearn/ > > In the future, I'd be interested toying around with more advanced > classifiers, like Support Vector Machines. > > Jan-Pieter > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
