Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Machine Learning without PhD :)

Machine Learning without PhD :)

Байрам Аннаков @ MoscowPython Meetup 49

"Расскажем и покажем, как обучать машины и нейросети для решения простых и не очень задач классификации и распознавания".

Видео: http://www.moscowpython.ru/meetup/49/ml-no-phd/

Moscow Python Meetup

September 20, 2017
Tweet

More Decks by Moscow Python Meetup

Other Decks in Programming

Transcript

  1. Recognize image from keras.applications.resnet50 import ResNet50 from keras.preprocessing import image

    from keras.applications.resnet50 import preprocess_input, decode_predictions import numpy as np model = ResNet50(weights='imagenet')
  2. Recognize image img_path = 'elephant.jpg' img = image.load_img(img_path, target_size=(224, 224))

    x = image.img_to_array(img) x = np.expand_dims(x, axis=0) x = preprocess_input(x)
  3. Recognize image preds = model.predict(x) # decode the results into

    a list of tuples (class, description, probability) # (one such list for each sample in the batch) print('Predicted:', decode_predictions(preds, top=3)[0]) # Predicted: [(u'n02504013', u'Indian_elephant', 0.82658225), (u'n01871265', u'tusker', 0.1122357), (u'n02504458', u'African_elephant', 0.061040461)]
  4. CNN

  5. 72%

  6. Approach • Collect data
 Simple iPhone app that helps draw

    and export • Prepare data
 Image = Grid. Each cell = 1 (black) or 0 (white)
 Convert Grid to Line
 Image = 000100011000011100011… • Train + Analyze
 Until satisfied with the score
  7. Train and Analyze 1. K-neighbors 78% from sklearn.neighbors import KNeighborsClassifier

    clf = KNeighborsClassifier(n_neighbors=1) clf.fit(x_train, y_train) clf.score(x_test, y_test)
  8. Train and Analyze 2. K-neighbors + PCA 81% from sklearn.decomposition

    import PCA pca = PCA(n_components=40, whiten=True) pca.fit(x_train) x_train_pca = pca.transform(x_train) x_test_pca = pca.transform(x_test) //repeat KNN
  9. 3. SVM 90% from sklearn import svm classifier = svm.SVC(gamma=0.001)

    classifier.fit(x_train, y_train) predicted = classifier.predict(x_test)