# Linear Model to generate probability of each possible output

This is related to Sports prediction (Cricket). I am new to Machine Learning and learning it through TensorFlow.

I am focusing only on one topic which is "How many runs Player A will score in today's match?"

My raw data includes all cricket player's score in all matches. It also includes more finer details like the ground the match happened, day/night match, opposition team etc., I need to use this data and predict four possible ranges for a player's score with all 4 range having equal probability.

I am planning to keep 4 simple FeatureColumn to start with:

• Average of runs of the given player in the past 10 matches (relative to the match that is being trained)
• Batting order (1 to 10) (in the match being trained)
• Average of runs since debut (relative to the match that is being trained)
• Average no. of balls faced in the past 10 matches (relative to the match that is being trained)

My actual output will be the runs scored by that player in the match being trained.

I can consider 100 recent matches of a player for this training.

This tutorial https://www.tensorflow.org/tutorials/wide from TensorFlow seems to match with what I am approaching. But the final output is a binary value (whether salary is >50K or not). But I need to generate output with probability of a given player getting a run. For eg.

Run     | Probability of getting this run
-----------------------------------------
0 runs  :  0.01
1 run   :  0.01
2 runs  :  0.02
....
13 runs :  0.5
14 runs :  0.04
....
56 runs :  0.08
57 runs :  0.03
....


Sum of Probability should add up to 1. I'll then group all these values into 4 ranges with each range having an equal probability (0.25 for each range) like this:

Which approach can I use for solving this problem? I read about Linear regression and that seems to be the best fit for me, but I am not clear on how to generate probability of all possible outcomes.

• When you say "I need to use this data and predict four possible ranges for a player's score with all 4 range having equal probability." could you explain why you have this specific need, because that is an unusual requirement? Neither regression nor classifier models are a direct fit for this problem (regression will not give you any estimated density function, classifier will not consider values as a range, and may need immense amount of training data). So if this is a strict requirement, being new to machine learning is going to make solving this problem hard for you. May 23, 2017 at 17:37
• Hi @NeilSlater, Thanks for your reply. Building those 4 ranges from the table (Run & Probability of getting that run) would be a stats/math problem. I'll group all values into 4 buckets that would sum up to 0.25 or closer. I would not use ML for that. But I need help in finding the right approach to build that table using my raw data. Can ML be used till that part?
– Raj
May 24, 2017 at 0:42
• That confirms my understanding. Neither standard regression nor classification using supervised learning methods are a good match to build your table of score probabilities. Maybe what you want is en.wikipedia.org/wiki/Quantile_regression - note that does not build your table of probabilities, but instead you can use it to directly estimate 25th centile, median and 75th centile points for a given set of features. May 24, 2017 at 8:51

From what I understood -

Train a classifier with the features as you mentioned and the output probabilities like you have shown -

• So, for Player A, you can use all the features (average runs scored overall, average score in past 10 innings etc.)
• Treat the runs scored as a categorical variable and try to learn a classifier

• Put it through the network with a softmax layer at the end - that will give you Sum of Probability should add up to 1

My recommendation

• Each player will have scored different runs so you will not get enough data points in a particular category (so no. of people who score 83 will be really less for example)

• Pre-group the ranges in your training data and then do the classifier.

• Having a softmax layer at then end won't give you the "linear model" you want, but would definitely solve the problem with a lot more clarity.

My reccomendation would to be to use Poisson Regression.

One of the outcomes of a Poisson Regression is the $$\lambda(\overline{X})$$ which is the lambda of the poisson distribution dependent on the covariates.

When you have this $$\lambda$$, you could put this in the equation $$P(X=x)=\frac{\lambda^ke^{-\lambda{}}}{k!}$$, which you will read as:

Probability of 0 runs is: $$P(X=0)=\frac{\lambda^0e^{-\lambda{}}}{0!} = e^{-\lambda}$$

Probability of 1 run is: $$P(X=1)=\frac{\lambda^1e^{-\lambda{}}}{1!} = \lambda{}e^{-\lambda}$$

... and so on...