<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Using deep features to create an image classifier
Step1:  Load CIFAR-10 dataset
This is a popular computer vision dataset used for benchmarking.
It is already split into a training and testing set.
Step2:  Train classifier using raw image pixels, no deep features yet
This will be compared against the model that uses deep features later on. Goal is to predict the image's label using other features.
Step3:  Predict five images with this raw pixel model
Step4:  Raw pixel model only got one out of five predictions correct. That's an F.
More general evaluation of the raw pixel model
Step5:  The accuracy of this model is only 47.6%.
Next, a model leveraging deep features
This model will use transfer learning, since the dataset is so small. It will use the ImageNet dataset's deep features training, along with a simple classifier.
Computing deep features for the images
The two lines below will computer deep features. However, this is computationally intensive, so the deep features are already contained in the dataset for this reason. If they were not, I would run the two lines below.
Step6:  Train a classifier using the deep features
Step7:  Try predicting the first five images again
Step8:  It got them all correct! A+.
More general evaluation of the model, similar to evalution of the raw pixels model
<ASSISTANT_TASK:>
Python Code:
import graphlab
Explanation: Using deep features to create an image classifier
End of explanation
image_train_url = 'https://d396qusza40orc.cloudfront.net/phoenixassets/image_train_data.csv'
image_test_url = 'https://d396qusza40orc.cloudfront.net/phoenixassets/image_test_data.csv'
image_train_data = graphlab.SFrame(image_train_url)
image_train_data.head()
image_test_data = graphlab.SFrame(image_test_url)
image_test_data.head()
Explanation: Load CIFAR-10 dataset
This is a popular computer vision dataset used for benchmarking.
It is already split into a training and testing set.
End of explanation
raw_pixel_model = graphlab.logistic_classifier.create(image_train_data, target='label',
                                                     features=['image_array'])
Explanation: Train classifier using raw image pixels, no deep features yet
This will be compared against the model that uses deep features later on. Goal is to predict the image's label using other features.
End of explanation
# actual image labels (correct answers)
image_test_data[0:5]['label']
# model output
raw_pixel_model.predict(image_test_data[0:5])
Explanation: Predict five images with this raw pixel model
End of explanation
raw_pixel_model.evaluate(image_test_data)
Explanation: Raw pixel model only got one out of five predictions correct. That's an F.
More general evaluation of the raw pixel model
End of explanation
# deep_learning_model = graphlab.load_model('http://s3.amazonaws.com/GraphLab-Datasets/deeplearning/imagenet_model_iter45')
# image_train_data['deep_features'] = deep_learning_model.extract_features(image_train_data)
Explanation: The accuracy of this model is only 47.6%.
Next, a model leveraging deep features
This model will use transfer learning, since the dataset is so small. It will use the ImageNet dataset's deep features training, along with a simple classifier.
Computing deep features for the images
The two lines below will computer deep features. However, this is computationally intensive, so the deep features are already contained in the dataset for this reason. If they were not, I would run the two lines below.
End of explanation
deep_features_model = graphlab.logistic_classifier.create(image_train_data,
                                                         features=['deep_features'],
                                                         target='label')
Explanation: Train a classifier using the deep features
End of explanation
# actual image labels (correct answers)
image_test_data[0:5]['label']
# model output
deep_features_model.predict(image_test_data[0:5])
Explanation: Try predicting the first five images again
End of explanation
deep_features_model.evaluate(image_test_data)
Explanation: It got them all correct! A+.
More general evaluation of the model, similar to evalution of the raw pixels model
End of explanation
<END_TASK>