{ "cells": [ { "cell_type": "markdown", "source": [ "# HW5 Training and Validation\r\n", "\r\n", "## Deadline: Oct. 27th, Wed, 12:00 PM (Noon)\r\n", "\r\n", "* No unapproved extension of the deadline...

Question is attached. Please email at [email protected]



{ "cells": [ { "cell_type": "markdown", "source": [ "# HW5 Training and Validation\r\n", "\r\n", "## Deadline: Oct. 27th, Wed, 12:00 PM (Noon)\r\n", "\r\n", "* No unapproved extension of the deadline is allowed. Late submission will lead to 0 credit. \r\n", "\r\n", "* Discussion is encouraged on Piazza as part of the Q/A. However, all assignments should be done individually.\r\n", "\r\n", "## About this assignment:\r\n", "\r\n", "In this homework, we will utilize the dataset and featureExtractor classes from previous homeworks to train and validate a supervised learning model. \r\n", "\r\n", "\r\n", "## Submission: \r\n", "\r\n", "- You only need to submit this notebook file to Canvas." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "## From previous homework\r\n", "\r\n", "Before we start, make sure you have placed this notebook in the code folder from the previous homeworks. In the code folder, you should also have the dataset_class.py file and featureExtractor_class.py.\r\n", "\r\n", "### **Make sure to update the dataset_class.py file !!!**\r\n", "\r\n", "**First, copy the content in the dataset_class_updated.py to your dataset_class.py file.** The new file updated the `showImageByIndex()` function in the myDataset implementation to allow it to show predicted result in the plot." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "Now let's import the myDataset and featureExtractor, and initialize them. Recall that we need to use the dataset as part of the input for initializing the featureExtractor.\r\n" ], "metadata": {} }, { "cell_type": "code", "execution_count": 1, "source": [ "from dataset_class import myDataset\r\n", "from featureExtractor_class import featureExtractor\r\n", "\r\n", "# initiate dataset\r\n", "raveling_dataset = myDataset()\r\n", "# initiate extractor\r\n", "textureExtractor = featureExtractor(raveling_dataset, hSize=75, wSize=75, numOfCDFSamples=50)" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## Feature Extraction\r\n", "\r\n", "Now, let's talk about how to extract the features using the featureExtractor class that we implemented. \r\n", "\r\n", "First, we need to define a list of images that we want the features to be extracted. We will pass a list of indices to the featureExtractor. \r\n", "\r\n", "Since we will extract features on the entire dataset, all indices will be included in the `listOfIndices`." ], "metadata": {} }, { "cell_type": "code", "execution_count": 2, "source": [ "# Since we will extract features on the entire dataset, all indices will be included in the `listOfIndices`.\r\n", "listOfIndices = list(range(len(raveling_dataset.allData)))\r\n" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## Feature Extraction at Image-Level Only\r\n", "The extractFeature() function that we implemented in the last homework by default extracts feature at both the image-level and patch-level. `(patchFeature=True, imageFeature=True)`\r\n", "\r\n", "We can also ask the extractor to only extract image-level features by setting the `patchFeature=False` in the input arguments." ], "metadata": {} }, { "cell_type": "code", "execution_count": 3, "source": [ "# extract only the image-level features\r\n", "imageOnlyFeatures = textureExtractor.extractFeatures(listOfIndices,patchFeature=False)\r\n" ], "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ "100%|██████████| 2682/2682 [01:06<00:00, 40.14it/s]\n">
Oct 19, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here