Question: please provide matlab code to answer #2. we are looking for accurancy and sample images we are given a datasheet but here is the information

please provide matlab code to answer #2. we are looking for accurancy and sample images
please provide matlab code to answer #2. we are looking for accurancy
we are given a datasheet but here is the information provided as well
and sample images we are given a datasheet but here is the

2 (40 points) Classifying an Image using Grayscale Histograms For each image in your dataset, compute a grayscale histogram with 256 bins and extract a class label from the first three characters of the file name, neg.pos. For simplicity you may want to enumerate these class labels. Note: It may take a while to traverse this directory and make your data matrioes. Therefore, you may consider saving your representations and labels in some file and read them in as needed. Now we want to make our training and validation sets. First set the random number generator's seed to zero so that you can have reproducible results. Next shuffle the data and select 2/3 of it for training and the remaining for validation. Now that we have our datasets created, let's classify! Go through each validatioon sample's histogram and classify them as car or not-car using a k-nearest neighbors approach, where k=5. For our similarity metric, we'll use the histogram intersection (where D is the number of bins): sim(a,b)=j=1Dmin(aj,bj) For your report, compute the accuracy as the percentage of the validation images classified correctly. In addition show: 1. One image correctly labeled as a car 2. One image correctly labeled as not a car 3. One image incorrectly labeled as a car 4. One image incorrectly labeled as not a car The Dataset The success of traditional machine learning algorithms is highly dependent on feature extraction. In this assignment you will get experience: 1. Forming training and testing data sets 2. Implementing and evaluating a K-Nearest-Neighbors classifier. 3. Extracting global and local features On BBlearn we have provided a dataset for use in training a classifier to detect images as containing a car vs not containing a car. Since we need labels (for our training set and to evaluate our testing set) we will only use the Trainlmages subdirectory for both training and and testing data. The dataset is structured as follows: http://cogcomp.org/Data/Car/ The following code can be used to parse this subdirectory: d=, /CarData/TrainImages' files = dir (d); X=[]; Y=[]; for f= files' if - f.isdir im = imread([d, '/', f.name]); \%do whatever you need to in order to generate feature vector for im \%which I11 call fv X(end+1,;)= fv; Y(end+1,1)= strcmp(f.name (1:3), 'neg'); end end And to shuffle and divide your data in to training and validation subsets... rag (0); inds = randperm (size(X,1)); num = size (X,1)/3; X=X( inds, ); Y=Y( inds, ); X train =X(1:2 num, ); Y train =Y(1:2 num, ); X Xalid =X(2 num +1 :end ;:) Yvalid =Y(2 *num +1 :end, ;)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!