The main aim of this project is to study both classification and regression problems by developing our own feed-forward neural network (FFNN) code. We can reuse the regression algorithms studied in project 1. We will include logistic regresion for classification problems and write our own FFNNcode for studying both regression and classification problems. The codes developed in project 1, including bootstrap and/or cross-validation as well as the computation of the mean-squared error and/or the \( R2 \) or the accuracy score (classification problems) functions can also be utilized in the present analysis.
The data sets that we propose here are (the default sets)
In particular, when developing your own Logistic Regression code for classification problems, the so-called Wisconsin Cancer data (which is a binary problem, benign or malignant tumors) may be studied. You find more information about this at the Scikit-Learn site or at the University of California at Irvine. The lecture slides on dimensionality reduction have several code examples on this data set.
If you opt for the credit card data, your first task is to familiarize yourself with the data set and the scientific article. We recommend also that you study the code example in the Logistic Regression.
Write the part of the code which reads in the data and sets up the relevant data sets.
Now you should write your Logistic Regression code with the aim to reproduce the Logistic Regression analysis of the scientific article.
Define your cost function and the design matrix before you start writing your code.
In order to find the optimal parameters of your logistic regressor you should include a gradient descent solver, as discussed in the gradient descent lectures. Since we don't have so many data points, you may just code the standard gradient descent with a given learning rate, or even attempt to use the Newton-Raphson method. Alternatively, it may be useful for the next part on neural networks to implement a stochastic gradient descent with and without mini-batches. Stochastic gradient with mini-batches may give the best results. You could finally compare your code with the output from scikit-learn's toolbox for optimization methods applied to logistic regression.
To measure the performance of our classification problem we use the so-called accuracy score. The accuracy is as you would expect just the number of correctly guessed targets \( t_i \) divided by the total number of targets. A perfect classifier will have an accuracy score of \( 1 \). $$ \text{Accuracy} = \frac{\sum_{i=1}^n I(t_i = y_i)}{n} , $$
where \( I \) is the indicator function, \( 1 \) if \( t_i = y_i \) and \( 0 \) otherwise if we have a binary classifcation problem. Here \( t_i \) represents the target and \( y_i \) the outputs of your Logistic Regression code.
You can compare your own results with those obtained using scikit-learn.
As stated in the introduction, it can also be useful to study other datasets. In particular, when developing your own Logistic Regression code for classification problems, the so-called \ Wisconsin Cancer data (which is a binary problem, benign or malignant tumors) may be studied. You find more \ information about this at the Scikit-Learn site or at the "University of California at Irvine":"https://archive.ics.uci.e\ du/ml/datasets/breast+cancer+wisconsin+(original)". The lecture slides on dimensionality reduction have sev\ eral code examples on this data set.
Your aim now, and this is the central part of this project, is to write to your own Feed Forward Neural Network code implementing the back propagation algorithm discussed in the lecture slides. We start with the Logistic Regression case and the data set discussed in parts a) and b) but train now the network to find the optimal weights and biases. You are free to use the codes in the above lecture slides as starting points.
Discuss again your choice of cost function.
Train your network and compare the results with those from your Logistic Regression code. You should test your results against a similar code using Scikit-Learn (see the examples in the above lecture notes) or tensorflow/keras.
Comment your results and give a critical discussion of the results obtained with the Logistic Regression code and your own Neural Network code. Make an analysis of the regularization parameters and the learning rates employed to find the optimal accurary score.
A useful reference on the back progagation algorithm is Nielsen's book. It is an excellent read.
Here we will change the cost function for our neural network code developed in part c) in order to perform a regression (fitting a function or some data set) analysis. As stated above, our default data sets could be either the Franke function or the terrain data from project 1.
Compare you results from the neural network regression analysis (with a discussion of learning rates and regularization parameters) with those you obtained in project 1. Alternatively, if you opt for other data sets, you would need to run your standard ordinary least squares, Ridge and Lasso calculations using your codes from project 1.
Again, we strongly recommend that you compare your own neural Network code and results against a similar code using Scikit-Learn (see the examples in the above lecture notes) or tensorflow/keras.
After all these glorious calculations, you should now summarize the various algorithms and come with a critical evaluation of their pros and cons. Which algorithm works best for the regression case and which is best for the classification case. These codes can also be part of your final project 3, but now applied to other data sets.
Here follows a brief recipe and recommendation on how to write a report for each project.
The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report:
If you have Python installed (we recommend Python3) and you feel pretty familiar with installing different packages, we recommend that you install the following Python packages via pip as
See below for a discussion of tensorflow and scikit-learn.
For OSX users we recommend also, after having installed Xcode, to install brew. Brew allows for a seamless installation of additional software via for example
If you don't want to install various Python packages with their dependencies separately, we recommend two widely used distrubutions which set up all relevant dependencies for Python, namely