Answered step by step
Verified Expert Solution
Question
1 Approved Answer
* Load the binary file, filename into a Dataset and return a pointer to * the Dataset. The binary file format is as follows: 4
* Load the binary file, filename into a Dataset and return a pointer to * the Dataset. The binary file format is as follows: 4 bytes : 'N: Number of images / labels in the file 1 byte : Image 1 label NUM_PIXELS bytes : Image 1 data (WIDTHXWIDTH) 1 byte : Image N label NUM_PIXELS bytes : Image N data (WIDTHXWIDTH) * You can set the "sx" and "sy' values for all the images to WIDTH. * Use the NUM_PIXELS and WIDTH constants defined in dectree.h Dataset *load_dataset(const char *filename) { // TODO: Allocate data, read image data / labels, return return NULL; } double gini_impurity(Dataset *data, int M, int *indices, int pixel) { int a_freq[10] = {@}, a_count 0; int b_freq[10] = {@}, b_count 0; for (int i = 0; i images[img_idx].data[pixel] labels[img_idx]]++; a_count : } else { b_freq[data->labels[img_idx]]++; b_count++; } } * Load the binary file, filename into a Dataset and return a pointer to * the Dataset. The binary file format is as follows: 4 bytes : 'N: Number of images / labels in the file 1 byte : Image 1 label NUM_PIXELS bytes : Image 1 data (WIDTHXWIDTH) 1 byte : Image N label NUM_PIXELS bytes : Image N data (WIDTHXWIDTH) * You can set the "sx" and "sy' values for all the images to WIDTH. * Use the NUM_PIXELS and WIDTH constants defined in dectree.h Dataset *load_dataset(const char *filename) { // TODO: Allocate data, read image data / labels, return return NULL; } double gini_impurity(Dataset *data, int M, int *indices, int pixel) { int a_freq[10] = {@}, a_count 0; int b_freq[10] = {@}, b_count 0; for (int i = 0; i images[img_idx].data[pixel] labels[img_idx]]++; a_count : } else { b_freq[data->labels[img_idx]]++; b_count++; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started