5
$\begingroup$

I am trying to build and train a machine learning data science algorithm that correctly predicts what president won in what county. I have the following information for training data.

Total population Median age % BachelorsDeg or higher Unemployment rate Per capita income Total households Average household size % Owner occupied housing % Renter occupied housing % Vacant housing Median home value Population growth House hold growth Per capita income growth Winner

I am new to the field and this is my first time building an artificial neural network and I don't know what to do to start (so forgive me if my question is extremely broad). What I have done so far is read the wikipedia page for artificial neural networks. What I want to do next is implement supervised learning using the training data.

I would appreciate any help getting started. Please let me know if you have used any good tutorials or libraries to help build something similar. I was thinking of using the library Lasagne.

A few specific questions I have as I tried to use Lasagne - What is the error I am to calculate when building an algorithm using training data? How many layers do I need and what does each layer signify?

$\endgroup$
1
$\begingroup$

Note that I am cross-posting this answer because the question is cross-posted, and one of the questions will likely be deleted. If this is a breach of etiquette, please let me know. Cross-post is here.

This question has two parts, at least implicitly. The second part is, generally speaking, how to train and predict from neural networks (in Python). The first part is (implicitly) how do we build a model that predicts (correctly) which person won a presidency based on demographics.

The answer to the second question is quite easy to state, but harder to do. It boils down to the rather unhelpful statement: learn about neural networks, and use that knowledge. Google for tutorials on neural networks. I would make recommendations, but I don't know your mathematical, statistical, and computer science background, and thus cannot really make suggestions.

The first question, however, I can answer, although likely not in the way you'd like. Just using the data you've listed, it's highly unlikely you'll get any sort of accuracy out of your neural networks, or any other model you fit. Why? For several reasons.

The first is that unless you can always classify the president into one of two (or more) distinct groups, as you can in the US (Democrat, Republican), your data are changing all the time. You can't classify anything if it doesn't have a class, and that's difficult in some countries.

Secondly, even if there are distinct classes, demographic data is likely not a set of good predictors. Demographic data changes depending on how good the local governance is, as well as the overall governance. You might, might be able to code that in somehow. But demographic data also changes due to a lot of other things. When it comes down to voting, people choose to vote based on a bunch of things, and their demographic status is only one factor.

The third reason is more a caution than anything. Neural networks and all kinds of machine learning/statistical modelling methods can give good predictions with the right kind of data. Something like predicting a president is relatively difficult, especially in smaller countries. (Nate Silver did it well in the US, but there was a lot more data there.) And even if you've got great data and a great model, there's invariably something you miss. George Box said it right: "All models are wrong, but some are useful." When you mention predicting correctly, all sorts of alarm bells go off in my head. The problem with trying for "correct" prediction is that there are no guarantees your prediction will be correct, often even in simple cases. No model is perfect.

$\endgroup$
1
$\begingroup$

Please let me know if you have used any good tutorials or libraries to help build something similar.

I would highly recommend the online book of Michael Nielsen: Neural Networks and Deep Learning. Coming to the libraries suggestion, I found Keras extremely useful and easy when I was learning neural networks. However, Lasagna is also a nice choice.

You can learn about more libraries from this question.

What is the error I am to calculate when building an algorithm using training data?

The most commonly used error function is the squared error function, which is also used in the BackPropogation algorithm, which is used for optimizing the error function.

How many layers do I need and what does each layer signify?

Layers add sophistication, and help in finding subtle patterns in the data. However, you have to make sure that the network don't overfit. So, as long as the number of layers don't overfit the model, you are good to go. For ensuring that, you need to know what is cross-validation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.