How do I calculate random baseline? I am a bit confused as to how to calculate random baseline. If I understand correctly the random baseline is calculated by adding up the squared probabilities of all the classes. The random baseline classifier thus picks a class at random, instead of choosing the most frequent one.
I have 7 classes, each with # of items and a total of X. How do I find the probabilities? 
 A: The formula that you refer to can be used when the distribution of classes is the same in the training and test set (which is commonly assumed with machine learning).
Take 7 classes: A, B, C, D, E, F, G. There will be #A instances with label A in your data set. And of course, #A + #B + #C + #D + #E + #F + #G = X
The chance of encountering an instance with label A, i.e. the probability of class A, pA, equals #A/X.
Now, if you consider a random baseline system, this system will assign labels to instances according to these probabilities. Because labels are assigned according to probabilities, each time you let the system label the instances a different result will be produced. A majority system or your SVM-based system will produce the same result, no matter how often they are applied. With an infinite number of runs of the random baseline system, on average, the following will happen:
Given an instance with gold label A, this instance will be labelled pA times as A, pB times as B, etc. This means that we have a (fractional) true positive count equal to the probability pA. There are #A instances with gold label A, the total true positive count for label A becomes #A*pA. This can be done for each label. The total number of true positives, TP, becomes:
TP = #A*pA + #B*pB + #C*pC + #D*pD + #E*pE + #F*pF + #G*pG
And the average accuracy of this baseline system becomes acc = TP/X
acc = 1/X * (#A*pA + #B*pB + #C*pC + #D*pD + #E*pE + #F*pF + #G*pG)
If the X is distributed over the different terms, and using the definition of the probabilities, this becomes:
acc = pA*pA + pB*pB + pC*pC + pD*pD + pE*pE + pF*pF + pG*pG
which is the formula that you refer to.

As noted before, for an SVM-based system or a majority system, the average accuracy is equal to the accuracy of a single run. Meaning that the accuracies of a single run can be compared with the outcome of the random baseline formula.
If your machine learner produces slightly different results with each run (because it contains an element of randomness), you should compute the average accuracy for an infinite number of runs. But this is the ideal situation, and it may be impossible to compute. In practice, differences will be probably very small and most people stick to comparing using the outcome of a single run.  
