Using Machine Learning techniques for text-analysis I am analysing a bunch of tweets and I want to understand which political party the authors support.

I am using Mathematica but I am thinking to re-write my code in Python. If you have any suggestion, do not esitate.

Let say, for example that I have five parties labelled by a number: Party1, Party2,...,Party5 and I provide a list of tweets which are for sure associated to the parties. This list is roughly trainingList = {tweet1-&gt; "Party1",tweet2-&gt;"Party2",...,tweet5-&gt;"Party5",tweetK-&gt;"Neutral"}. Moreover, I added a class "Neutral" because some tweets are not classifiable. Actually, I provide more than one tweet par party. In fact, the trainingList is much longer.

Notice that I remove stop-words from the tweets and I apply a stemming-words algorithm to simplify the expressions. Then, every tweets is a list of potentially-significant words.

I create the classifier function, providing a prior (the explicit for of the prior is not important)

c = Classify[trainingList, ClassPriors-&gt; prior]


Then, I want to do some checks. I take a bunch of tweets belonging to other party-supporters and try 

c[{word1,word2,word3,word4,word5,word7},"Probabilities"]


which gives me a list of probabilities $p_i$. For example, 

&lt;| 'Party1' -&gt; p1, 'Party2' -&gt; p2, 'Party3' -&gt; p3, 'Party4' -&gt; p4, 'Party5' -&gt; p5, 'Neutral' -&gt; p6 |&gt;


Question1 Is there a way to understand how the algorithm associate these probabilites? More specifically, how each word is associated to a party

Question2 Is there a way to see which are the most frequent n-grams of words associated to a given party (class)?
Take a few words you know are linked with e.g republicans and with democrats. 
Extract their word embedding. That is the vector representation of the word which will be high dimensional.
This will assume you have trained word embedding, either pretrained, or even better trained them yourself on your data. The word embeddings could have been trained/extracted through e.g LSTM training or matrix factorisations. 

On the word embeddings, do dimension reduction(PCA as an example) to 2d. Plot! Those who are close together will be "similar" for the objective they are trained for.

Pretrained word embeddings exist to download. However, they might not be the optimal embeddings for your objective, but better than nothing still.