Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using HDF5
- using DecisionTree
- fn = "/home/phil/Downloads/mnist-original.h5"
- n = 70000
- data = float64(h5read( fn, "data/data", (1:n,:) ))
- labels = uint64(h5read( fn, "data/label", )[1:n])
- nData = size(data,1)
- nTraining = 0.7*nData
- selection = shuffle!(int(linspace(1,nData,nData)))
- trainingData = data[selection[1:nTraining],:]
- trainingLabels = labels[selection[1:nTraining]]
- testData = data[selection[nTraining+1:end],:]
- testLabels = labels[selection[nTraining+1:end]]
- model = build_forest(trainingLabels, trainingData, 20, 10, 1.0)
- pred = apply_forest(model, testData)
- accuracy = sum( pred .== testLabels ) / size(testLabels,1)
- @printf "Accuracy=%f" accuracy
Advertisement
Add Comment
Please, Sign In to add comment