Classification and Regression, from linear and logistic regression to neural networks
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 also include logistic regression for classification problems and write our own FFNN code 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 MNIST data set of images representing hand-written numbers from zero to nine. These are discussed intensively in the lecture notes on neural networks, see for example the slides from week 41
However, if you would like to study other data sets, feel free to propose other sets. What we listed here are mere suggestions from our side. If you opt for another data set, consider using a set which has been studied in the scientific literature. This makes it easier for you to compare and analyze your results. Comparing with existing results from the scientific literature is also an essential element of the scientific discussion. In particular, when developing your own Neural Network and Logistic Regression codes for classification problems, the so-called Wisconsin Cancer data (which is a binary problem, benign or malignant tumors) may be studied. You can find more information about this at the Scikit-Learn site or at the University of California at Irvine. We will start with a regression problem and we will reuse our codes from project 1 starting with writing our own Stochastic Gradient Descent (SGD) code. In order to get started, we will now replace in our standard ordinary least squares (OLS) and Ridge regression codes (from project 1) the matrix inversion algorithm with our own SGD code. You can choose whether you want to add the momentum SGD optionality or other SGD variants such as RMSprop or ADAgrad. The lecture notes from week 40 contain more details Perform an analysis of the results for OLS and Ridge regression as function of the chosen learning rates, the number of mini-batches and epochs as well as algorithm for scaling the learning rate. You can also compare your own results with those that can be obtained using for example Scikit-Learns various SGD options. Discuss your results. For Ridge regression you need now to study the results as functions of the hyper-parameter You will need your SGD code for the setup of the Neural Network and Logistic Regression codes. Your aim now, and this is the central part of this project, is to write your own Feed Forward Neural Network code implementing the back propagation algorithm discussed in the lecture slides from week 41. We will focus on a regression problem first and study either the Franke function or terrain data (or both or other data sets) from project 1. Discuss again your choice of cost function. Write an FFNN code for regression with a flexible number of hidden layers and nodes using the Sigmoid function as activation function for the hidden layers. Initialize the weights using a normal distribution. How would you initialize the biases? And which activation function would you select for the final output layer? Train your network and compare the results with those from your OLS and Ridge Regression codes from project 1. You should test your results against a similar code using Scikit-Learn (see the examples in the above lecture notes from week 41) or tensorflow/keras. Comment your results and give a critical discussion of the results obtained with the Linear Regression code and your own Neural Network code. Compare the results with those from project 1. Make an analysis of the regularization parameters and the learning rates employed to find the optimal MSE and Nielsens book. It is an excellent read. You should now also test different activation functions for the hidden layers. Try out the Sigmoid, the RELU and the Leaky RELU functions and discuss your results. You may also study the way you initialize your weights and biases. With a well-written code it should now be easy to change the activation function for the output layer. Here we will change the cost function for our neural network code developed in parts b) and c) in order to perform a classification analysis. We will here study the MNIST data set of hand-written numbers as discussed in the lecture notes from week 41. Use the Softmax function as activation function. Your code should however also be able to use a binary activation function as well. 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 where Discuss your results and give a critical analysis of the various parameters, including hyper-parameters like the learning rates and the regularization parameter Scikit-Learn site or at the University of California at Irvine. Again, we strongly recommend that you compare your own neural Network code for classification and pertinent results against a similar code using Scikit-Learn or tensorflow/keras or pytorch. Finally, we want to compare the FFNN code we have developed with Logistic regression, that is we wish to compare our neural network classification results with the results we can obtain with another method. Define your cost function and the design matrix before you start writing your code. Write thereafter a Logistic regression code using your SGD algorithm. Study the results as functions of the chosen learning rates. Add also an The weblink here https://medium.com/ai-in-plain-english/comparison-between-logistic-regression-and-neural-networks-in-classifying-digits-dc5e85cd93c3compares logistic regression and FFNN using the MNIST data set. You may find several useful hints and ideas from this article. 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: Finally, we encourage you to collaborate. Optimal working groups consist of 2-3 students. You can then hand in a common 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 For Python3, replace pip with pip3. 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 For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution you can use pip as well and simply install Python as etc etc. If you dont 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 Popular software packages written in Python for ML are These are all freely available at their respective GitHub sites. They encompass communities of developers in the thousands or more. And the number of code developers and contributors keeps increasing. 1999-2020, Data Analysis and Machine Learning FYS-STK3155/FYS4155:http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html. Released under CC Attribution-NonCommercial 4.0 licensePart a): Write your own Stochastic Gradient Descent code, first step
Part b): Writing your own Neural Network code
Part c): Testing different activation functions
Part d): Classification analysis using neural networks
Part e): Write your Logistic Regression code, final step
Part f) Critical evaluation of the various algorithms
Background literature
Introduction to numerical projects
Format for electronic delivery of report and programs
Software and needed installations
Reviews
There are no reviews yet.