Last active
March 14, 2020 23:09
-
-
Save mianuddin/3ce7114ae98df9bf52afa700060a5a7b to your computer and use it in GitHub Desktop.
Classify MNIST with Random Forest Classifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import [tensorflow [keras]]) | |
(import [numpy :as np]) | |
(import [sklearn.ensemble [RandomForestClassifier]]) | |
(import [sklearn.metrics [accuracy_score]]) | |
(setv mnist keras.datasets.mnist) | |
(setv [[train-images train-labels] [test-images test-labels]] (.load_data mnist)) | |
(print f"train-images: {(. train-images shape)}") | |
(print f"train-labels: {(. train-labels shape)}") | |
(print f"test-images: {(. test-images shape)}") | |
(print f"test-labels: {(. test-labels shape)}") | |
(setv trees (RandomForestClassifier)) | |
(.fit trees (.reshape np train-images [60000, 784]) train-labels) | |
(print (accuracy_score test-labels | |
(.predict trees (.reshape np test-images [10000, 784])))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment