Fill in Order Details

  • Submit paper details for free using our simple order form

Make Payment Securely

  • Add funds to your account. There are no upfront payments. The writer will only be paid once you have approved your paper

Writing Process

  • The best qualified expert writer is assigned to work on your order
  • Your paper is written to standard and delivered as per your instructions

Download your paper

  • Download the completed paper from your online account or your email
  • You can request a plagiarism and quality report along with your paper

Design and train a neural network to accomplish some classification task.

For this milestone, you will design and train a neural network to accomplish some classification task.

Choose a data set

The UCI Machine Learning Archive hosts various data sets suitable for testing learning algorithms. I suggest clicking on “View ALL Data Sets” on the right side of the page. That provides a nice interface in which you can filter by data type or area of interest.

The data should be suitable for a classification task, not clustering, recommendations, or regression. Neural networks support both categorical and numerical data, you’ll just want to keep the number of attributes to less than 100, because we’ll have to tune the way each attribute is presented to the network.

When you click on the data set, you’ll see a description, citations, and details about the attributes. There are links near the top to the “Data Folder”, and there you’ll find a list of files ending in .data (the raw data) or .names (attribute descriptions).

Download the data and descriptions. I have a lot of experience with the Mushroom data, so I’ll explore that in this explanation – but you can choose something else for your project. For mushrooms, the .names file contains:

1. Title: Mushroom Database



2. Sources:

    (a) Mushroom records drawn from The Audubon Society Field Guide to North

        American Mushrooms (1981). G. H. Lincoff (Pres.), New York: Alfred

        A. Knopf

    (b) Donor: Jeff Schlimmer (Jeffrey.Schlimmer@a.gp.cs.cmu.edu)

    (c) Date: 27 April 1987



3. Past Usage:

    1. Schlimmer,J.S. (1987). Concept Acquisition Through Representational

       Adjustment (Technical Report 87-19).  Doctoral disseration, Department

       of Information and Computer Science, University of California, Irvine.

       --- STAGGER: asymptoted to 95% classification accuracy after reviewing

           1000 instances.



[etc.]

5. Number of Instances: 8124



6. Number of Attributes: 22 (all nominally valued)



7. Attribute Information: (classes: edible=e, poisonous=p)

     1. cap-shape:                bell=b,conical=c,convex=x,flat=f,

                                  knobbed=k,sunken=s

     2. cap-surface:              fibrous=f,grooves=g,scaly=y,smooth=s

     3. cap-color:                brown=n,buff=b,cinnamon=c,gray=g,green=r,

                                  pink=p,purple=u,red=e,white=w,yellow=y



[etc.]

The .data file is a text file with comma-separated values (CSV), which can be imported easily into Excel or other spreadsheet applications:

p,x,s,n,t,p,f,c,n,k,e,e,s,s,w,w,p,w,o,p,k,s,u

e,x,s,y,t,a,f,c,b,k,e,c,s,s,w,w,p,w,o,p,n,n,g

e,b,s,w,t,l,f,c,b,n,e,c,s,s,w,w,p,w,o,p,n,n,m

p,x,y,w,t,p,f,c,n,n,e,e,s,s,w,w,p,w,o,p,k,s,u

e,x,s,g,f,n,f,w,b,k,t,e,s,s,w,w,p,w,o,e,n,a,g

[etc.]

Design your network

Your next task is to design your neural network architecture: how many neurons in each layer, and how to map neuronal activations to and from the data set?

Input layer

The number of input neurons will be based on the number of attributes in your data set, but it may not be a one-to-one match.

Generally, a continuous (real number) attribute can map directly to one neuron. There are no continuous attributes in the mushroom set, but the Heart Disease data contains a few, such as:

 thalach: maximum heart rate achieved

which has values like 127, 154, or 166. It is helpful, however, to normalize these values to the range 0..1, so they are not terribly out of proportion to the inputs from other attributes. In the case of heart rate, we would find the minimum (60) and the maximum (182) in the data file. Then, to convert any value, we subtract the minimum and divide by the size of the range (182-60 = 122):

  Raw value    Normalized value

     60          0.0            = (60-60)/122

    127          0.549180327869 = (127-60)/122

    154          0.770491803279 = (154-60)/122

    166          0.868852459016 = (166-60)/122

    182          1.0            = (182-60)/122

A discrete (categorical) attribute must be translated in some way, usually using a binary encoding. Let’s take the cap-shape of mushrooms as an example. These are the possible values:

bell=b, conical=c, convex=x, flat=f, knobbed=k, sunken=s

Because there are 6 possible values, we can represent them in ?log2(6)?=3?log2(6)?=3 input neurons, like this:

Code  Category  #  Binary  Input[0]  Input[1]  Input[2]

 b     bell     0   000     0.0       0.0       0.0

 c     conical  1   001     0.0       0.0       1.0

 x     convex   2   010     0.0       1.0       0.0

 f     flat     3   011     0.0       1.0       1.0

 k     knobbed  4   100     1.0       0.0       0.0

 s     sunken   5   101     1.0       0.0       1.0

Work through the attribute descriptions for your data set to determine the number of input neurons, the normalization parameters for continuous attributes, and the binary encoding for discrete attributes.

HiIDen layer

You will have to decide how many neurons to use in the hiIDen layer. Too few, and the network will not be sophisticated enough to recognize the patterns in the data. Too many, and the network may take longer to converge on an acceptable solution.

I would recommend starting with the same number of hiIDen neurons as input neurons, and then experiment with reducing it.

Output layer

Most classifications will be discrete categories: poisonous/edible for mushrooms, or the diagnosis of heart disease in that data set:

  num: diagnosis of heart disease (angiographic disease status)

  -- Value 0: < 50% diameter narrowing

  -- Value 1: > 50% diameter narrowing

You will want to have one output neuron for each possible classification, and use the “winner take all” strategy – the neuron with the highest activation determines the result. Here would be the expected outputs for the categories of mushrooms:

Code  Category  Output[0]  Output[1]

 e     edible    1.0        0.0

 p     poison    0.0        1.0

Implementation

Network architecture

Start with your (or my)&nbsp;mazur-nn&nbsp;implementation, but you’ll have to redefine the network architecture, something like this:

// 3-layer network architecture

const int NUM_INPUTS = 57;

const int NUM_HIIDEN = 10;

const int NUM_OUTPUTS = 2;

Those are the numbers I used for the mushroom data, but you can alter them for your own network.

Input data

Next, you’ll need to read the data. Here’s a routine you can use that interprets the comma-separated values (CSV) format generally used by data sets in the UCI archive:

#include <cstdio>

#include <cstdlib>

#include <iostream>

#include <cstring>



void read_csv(const char* filename,

              vector< vector<string> >& data)

{

    const int BUFFER_SIZE = 8192;

    char buffer[BUFFER_SIZE];

    FILE* fp = fopen(filename, "r");

    if(!fp) { perror(filename); exit(1); }

    // Read each line of the file

    while(fgets(buffer, BUFFER_SIZE-1, fp)) {

        // Parse by splitting on commas

        vector<string> row;

        char* elt = strtok(buffer, ",");

        while(elt) {

            row.push_back(elt);

            elt = strtok(NULL, ",");

        }

        data.push_back(row);

    }

    cout << "Read " << data.size() << " records x "

         << data[0].size() << " attributes from " << filename << "n";

    fclose(fp);

}

You’d call it like this:

    vector<vector<string>> data;

    // Read data from file into two-dimensional vector

    read_csv("shrooms.data", data);

If it works, you should see a message like this upon running the program:

Read 8124 records x 23 attributes from shrooms.data

Set target outputs

Next, you’ll have to modify the parts of the&nbsp;mazur-nn&nbsp;code that provides inputs to the network, and that specify the target outputs. Let’s begin with the target outputs. In the&nbsp;mazur-nnexample, we simply used:

vector<double> targets = {0.01, 0.99};

But now we’ll have to vary that for each example in the data file. So declare it this way:

vector<double> targets (NUM_OUTPUTS);

We use this to implement the winner-take-all strategy. In the mushrooms data file, the edible/poisonous classification is the first (0th) attribute, and it’s a single character, ‘e’ or ‘p’. When we access&nbsp;row[0], we grab the&nbsp;string&nbsp;value of the 0th attribute, and the extra&nbsp;[0]&nbsp;grabs the first (0th)&nbsp;character&nbsp;of the string.

    switch(row[0][0]) {

    case 'e':

        out[0] = 1;

        out[1] = 0;

        break;

    case 'p':

        out[0] = 0;

        out[1] = 1;

        break;

    default:

        cout << "Error: unexpected classification " << row[0][0] << "n";

        abort();

    }

The&nbsp;default&nbsp;case helps detect potential errors in parsing the file.

Your output interpretation will be similar, but it must be based on the format of your data and the number of output neurons.

Set network inputs – discrete

As for the network inputs, here’s the code we used in the&nbsp;mazur-nn&nbsp;example:

  // Provide inputs to the network

  inputs.at(0) = .05;

  inputs.at(1) = .10;

But now we have to interpret the data vector and normalize continuous attributes or binary-encode discrete attributes – as described in the Inputs section, above. Here’s an example of specifying just the first attribute in the mushroom database:

    int i = 0;

    // 1. cap-shape: bell=b,conical=c,convex=x,flat=f,

    // knobbed=k,sunken=s

    switch(row[1][0]) {

    case 'b': inputs[i++] = 0; inputs[i++] = 0; inputs[i++] = 0; break;

    case 'c': inputs[i++] = 0; inputs[i++] = 0; inputs[i++] = 1; break;

    case 'x': inputs[i++] = 0; inputs[i++] = 1; inputs[i++] = 0; break;

    case 'f': inputs[i++] = 0; inputs[i++] = 1; inputs[i++] = 1; break;

    case 'k': inputs[i++] = 1; inputs[i++] = 0; inputs[i++] = 0; break;

    case 's': inputs[i++] = 1; inputs[i++] = 0; inputs[i++] = 1; break;

    default:

        cout << "Error: unhandled cap-shape " << row[1][0] << "n";

        abort();

    }

This fragment illustrates converting a discrete value, represented by single characters, into bits in a binary encoding. You can see that the zeroes and ones assigned to&nbsp;inputs[i++]&nbsp;match the binary encodings in the previous table.

If the discrete values in your data file are not represented by a single character, but rather by a string, then you cannot use&nbsp;switch/case&nbsp;statements as above. Instead, you would use a series of&nbsp;if/else&nbsp;statements comparing the completes strings, like this:

    // Here we're illustrating three strings as the possibilities

    // for column K, so we encode them as bits into two inputs.

    if(row[K] == "large") {

        inputs[i++] = 0; inputs[i++] = 0;

    }

    else if(row[K] == "medium") {

        inputs[i++] = 0; inputs[i++] = 1;

    }

    else if(row[K] == "small") {

        inputs[i++] = 1; inputs[i++] = 0;

    }

    else {

        cout << "Error: unhandled: " << row[K] << "n";

        abort();

    }

Set network inputs – continuous

If your data set has real-valued inputs, this is where you would normalize them to the range 0.0–1.0. Here’s what that looks like for an attribute in column&nbsp;K:

double numeric_value = atof(row[K].c_str());    // Convert column K of current row

double normalized_value = (numeric_value - MINIMUM) / RANGE;

  // (where you plug in MINIMUM and RANGE for the column K)

inputs[i++] = normalized_value;

Experiments

Once you have these input and output functions completed, you can experiment with training the network. Determine how many cycles it takes to converge to a solution with different proportions of training vs.&nbsp;test data. Then experiment with different numbers of hiIDen neurons.

WHAT OUR CURRENT CUSTOMERS SAY

  • Google
  • Sitejabber
  • Trustpilot
Zahraa S
Zahraa S
Absolutely spot on. I have had the best experience with Elite Academic Research and all my work have scored highly. Thank you for your professionalism and using expert writers with vast and outstanding knowledge in their fields. I highly recommend any day and time.
Stuart L
Stuart L
Thanks for keeping me sane for getting everything out of the way, I’ve been stuck working more than full time and balancing the rest but I’m glad you’ve been ensuring my school work is taken care of. I'll recommend Elite Academic Research to anyone who seeks quality academic help, thank you so much!
Mindi D
Mindi D
Brilliant writers and awesome support team. You can tell by the depth of research and the quality of work delivered that the writers care deeply about delivering that perfect grade.
Samuel Y
Samuel Y
I really appreciate the work all your amazing writers do to ensure that my papers are always delivered on time and always of the highest quality. I was at a crossroads last semester and I almost dropped out of school because of the many issues that were bombarding but I am glad a friend referred me to you guys. You came up big for me and continue to do so. I just wish I knew about your services earlier.
Cindy L
Cindy L
You can't fault the paper quality and speed of delivery. I have been using these guys for the past 3 years and I not even once have they ever failed me. They deliver properly researched papers way ahead of time. Each time I think I have had the best their professional writers surprise me with even better quality work. Elite Academic Research is a true Gem among essay writing companies.
Got an A and plagiarism percent was less than 10%! Thanks!

ORDER NOW

CategoriesUncategorized

Consider Your Assignments Done

“All my friends and I are getting help from eliteacademicresearch. It’s every college student’s best kept secret!”

Jermaine Byrant
BSN

“I was apprehensive at first. But I must say it was a great experience and well worth the price. I got an A!”

Nicole Johnson
Finance & Economics

Our Top Experts

See Why Our Clients Hire Us Again And Again!


OVER

10.3k
Reviews

RATING
4.89/5
Average

YEARS
13
Mastery

Success Guarantee

When you order form the best, some of your greatest problems as a student are solved!

Reliable

Professional

Affordable

Quick

Using this writing service is legal and is not prohibited by any law, university or college policies. Services of Elite Academic Research are provided for research and study purposes only with the intent to help students improve their writing and academic experience. We do not condone or encourage cheating, academic dishonesty, or any form of plagiarism. Our original, plagiarism-free, zero-AI expert samples should only be used as references. It is your responsibility to cite any outside sources appropriately. This service will be useful for students looking for quick, reliable, and efficient online class-help on a variety of topics.