Predicting Instagram Pictures Likes and Comments with .NET Core and ML.NET

For a new fun Project, I wanted to create an Artificial Intelligence model that will allow me to predict the comments and likes of new pictures that a user can post on Instagram based on their own…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Forcing neural networks to make a new political compass

Despite all the annoying memes there is value in plotting political standpoints on an easy to comprehend graph. The difficult part is finding axes that make sense and putting political parties and individuals on a sensible place on those axes.

In The Netherlands the most common axes are ‘economic left-right’ as X-axis and ‘conservative-progressive’ as Y-axis. This is broadly sensible but if you look at the Dutch political compass the political parties are all on the same line: from progressive-left to conservative-right. This is boring and could just as well be plotted on a one dimensional graph.

In America or, on english language internet the most common choice for axes is: ‘economic left-right’ as X-axis and ‘libertarian-authoritarian’ as Y-axis. Again broadly sensible, and allows for plotting Stalin and Hitler on a sensible place. Yet in a healthy political environment this should not be necessary, and as a Dutchy it’s hard to imagine anyone voting for a party that self identifies as authoritarian.

Clearly there is a lot of demand for a new political compass that solves all these problems. Or better said I was bored and wanted to play with neural networks.

To train neural networks you need data, luckily there is a lot of public data on Dutch parties and election results, so here are the four data sets I used.

In a nutshell neural networks can be trained to take a set of input data to generate a certain output. For example take a picture as input data and generate a label of what animal is pictured as output data. The network is trained by having a big set of pictures and corresponding labels, then comparing the output of the network with the correct label to calculate an error, this error can be used to update the weights of the network to make this error smaller (back propagation). Doing this with big data sets and sufficiently big neural networks can have surprisingly effective results.

To generate a political compass I will train a network that, given a political party and a municipality, will predict if that party got more than 10% of the votes or not. Neural networks can only work with numbers, it will not be able to make sense of ‘Groen-Links, Goeree-Overflakkee’. So the political party and municipality need to be represented as numbers, this is where the data comes in handy.

The municipality will be represented by a set of relevant data, namely: population size, population density, voter turnout, ratio men-woman, and age ratio.

The political party will be represented by what issues their voters prioritise, this is a list of 23 numbers from 0 to 100. But instead of using this data directly, I will chain another neural network in front of the main one that takes the 23 voter issues and returns two numbers which the main network then has to use to make its prediction (see Rough Setup). By training these two networks as one, you force the network to reduce all data of the political party to just two numbers, and then use these two numbers to make a correct prediction.

Network Setup

Here you see the network (in reality there are many more hidden and input nodes). The green nodes (I0-I3) are the voter issues, the blue nodes (I4, I5) are the municipality data, the orange node (R) is the result node, the purple nodes (H) are the hidden layer nodes, and finally the red X and Y are the reduced political party information (representing the x and y axis of the new political compass). Here you can also see that what is happening is that a big multi dimensional set of data (voter issues) is educed to just two dimensions, this is a common practice in data science:

What is different in this case is that I make the neural network figure out what method of dimensionality reduction is the most effective for this specific goal. It might be interesting to see how the methods listed in the wikipedia article compare to the neural network.

After a bit of tweaking I got the network to predict election results per municipality with 80–85% accuracy, the next step was to extract the values of the X and Y nodes per party and then plot them on a graph. After running the training process many times with randomised setup, the network seemed to prefer two different compasses. But before we see the results it might be handy to know what the different Dutch political parties are so here is a rough list:
PVV: right / populist
SGP: right / christian
VVD: centre right / liberal
CDA: centre right / christian
D66: centre / libiral
PvdA: centre left / labour
CU: centre left / christian
GL: left / green
PvdD: left / animal rights
SP: left / socialist

As stated above it’s hard to — one choose axes and — two determine where on those axes political entities should be placed. The second problem is clearly solved, parties have been placed on a grid, but figuring out what the axes mean is not trivial. The Y-axis seems to me to be close to the before mentioned progressive-left conservative-right axis, the X-axis is harder to place. One metric that seems to fit quite well is willingness to take part in government (maybe related to trust in politics, or general unhappiness at the state of politics).

On first glance Compass Two seems to be difference than the first one, although the Y-axis seems similar to the X-axis of the first compass. The X-axis looks like a confused left right axis, in the bottom it makes no sense, PVV and PvdD are on complete opposite ends of that spectrum yet on this compass they are placed next to each other, while on top left-right seems to hold (al be it the wrong way around). One thing that is clear, is that there are three brought groups, centre right in the left top corner (confusing), left progressive in the right top corner, and low political trust in the right bottom corner. If we go back to the first compass we can see those same groups again, only less distinct. This suggests these graphs are more similar than first expected, there might be hope in finding a way to combine them.

As you can see both compasses have one axis that strongly correlates to institutional trust, but only compass-one has an axis that strongly correlates to the classic political compass. The discrepancy in compass-two could be explained — like hypothesised before — by the idea that the classic political compass only makes sense when political trust is high. When we only check for correlation between the Y axis and the classical compass for parties that have high institutional trust you get a p value of 0.034. Now that we have statistical grounding for the axes we can try to combine the two compasses.

In both graphs there is a left right axis and a trust no-trust axis, and in both graphs the less trust in politics the less the left-right axis matters. One way to combine these two compasses is to move away from a square and instead use a triangle (as shown above). On top we have a brought left-right axis where political trust is highest, and below the left-right axis is reduced to just one point where political trust is lowest.

In the end this chained neural network approach, that uses one neural network to generate data that another neural network has to use to make a prediction, created a consistent, interesting and surprisingly opinionated political compass that has statistical grounding in existing political analysis. In future it might be interesting to see to what extend this Triangle Model translates to other political analysis (do voters identify with their place in the triangle, and does it work in other countries). If the Triangle shows to have merit it might be interesting to see if it is a product of this time of political turmoil or if it has predicting power in any time period. And finally (again if the Triangle Model has merit) it might be interesting to see if more deterministic and objective measures exist to place people and political parties on the Triangle.

Thanks for reading :)

Add a comment

Related posts:

The Crime of being Ordinary

Many like myself are very familiar with how it feels to be an outcast. The feeling of being the one person who does not quite fit in and having to endure many awkward encounters. Interestingly many…

The writing for the postgraduate examination

It is vividly illustrated in the drawing that the drastically dynamic development of fishing. While there is just one fish left, with an abundant amount of boat preying in 1996, there used to have…

COMM 206 Writing Portfolio

All my life I have wanted to connect with people through writing. When I was a kid, my dream for “when I grew up” was to write children's books. Now I often consider going into news broadcast…