Skip to content

Week6 Code in Machine_Learning_Foundations:A_Case_Study_Approach

Notifications You must be signed in to change notification settings

SelinaChe/Week6_Code_Assignment_in_Coursera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

Week6-Code-Assignment

for Machine_Learning_Foundations:A_Case_Study_Approach

1.What’s the least common category in the training data?

  • groupby_label = image_train.groupby(key_columns='label', operations={'total_count':graphlab.aggregate.COUNT()})
  • groupby_label.sort('total_count', ascending=True)

2.Of the images below, which is the nearest ‘cat’ labeled image in the training data to the the first image in the test data (image_test[0:1])?

  • image_test[0:1]['image'].show()
  • image_train_cat = image_train.filter_by(['cat'],'label')
  • knn_model_cat = graphlab.nearest_neighbors.create(image_train_cat,features=['deep_features'], label='id')
  • cat_neighbors = get_images_from_ids(knn_model_cat.query(image_test[0:1],k=1))
  • cat_neighbors['image'].show()

3.Of the images below, which is the nearest ‘dog’ labeled image in the training data to the the first image in the test data (image_test[0:1])?

  • image_test[0:1]['image'].show()
  • image_train_dog = image_train.filter_by(['dog'],'label')
  • knn_model_dog = graphlab.nearest_neighbors.create(image_train_dog,features=['deep_features'], label='id')
  • dog_neighbors = get_images_from_ids(knn_model_dog.query(image_test[0:1],k=1))
  • dog_neighbors['image'].show()

4.For the first image in the test data, in what range is the mean distance between this image and its 5 nearest neighbors that were labeled ‘cat’ in the training data?

  • knn_model_cat.query(image_test[0:1],k=5)['distance'].mean()

5.For the first image in the test data, in what range is the mean distance between this image and its 5 nearest neighbors that were labeled ‘dog’ in the training data?

  • knn_model_dog.query(image_test[0:1],k=5)['distance'].mean()

6.On average, is the first image in the test data closer to its 5 nearest neighbors in the ‘cat’ data or in the ‘dog’ data?

  • cat

7.In what range is the accuracy of the 1-nearest neighbor classifier at classifying ‘dog’ images from the test set?

  • knn_classifier_model_dog = graphlab.nearest_neighbor_classifier.create(image_train, features=['deep_features'], target='label' )
  • image_test_dog = image_test.filter_by(['dog'],'label')
  • knn_classifier_model_dog.evaluate(image_test_dog,max_neighbors=1)

About

Week6 Code in Machine_Learning_Foundations:A_Case_Study_Approach

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published