Predicting IPL-2020 Winner
Tags: Data Science, Regression, Machine Learning

Classification and Regression are the two branches of Supervised Learning in the field of Machine Learning. These are the basic topics that one should learn when starting their journey with Machine Learning. Doing projects is the only way through which one can learn and master these topics.

In my previous blog, I did a classification project. Having learnt some of the concepts in Classification, the time has arrived for me to make my hands dirty with Regression.

You can find the link for my previous classification project here.

https://medium.com/analytics-vidhya/cricket-analysis-and-prediction-a7e9a7f3ebef

Now, without any delay, lets dive into Regression.

Regression: In simple terms, regression is a technique used to predict the unknown value of an object, using the characteristics of the object and by having some information about other similar objects for which we know the value.

Example: If we were to predict the price of a new car, we have to know the features of the car and the price of other similar cars. The features we can use are, mileage of the car, number of seats, horsepower of the car, boot space of the car, leg space of the car, kind of the fuel used etc….

Using this information, we can estimate the price of the new car. The difference between the actual price and our predicted price is the error in our prediction.

Goal: Our aim of this project is to Predict the Winner of IPL-2020.

Approach:

Given the player statistics to a machine learning model, the model outputs the rating points for that player based on his statistics.

Once the model has generated ratings for all the IPL players, we choose the best playing XI of a team by using an algorithm and sum all the points of the best XI players to get the total rating of the team.

This algorithm then outputs the winner of two teams using the team rating points that the machine learning algorithm had predicted.

We call this algorithm for all the matches in the league stage. Thus, after the league stage, the algorithm outputs the top four teams which goes into qualifiers.

In the qualifier stage, again the same algorithm is run between two teams and the top two teams will be selected for finals.

In the final stage, we are left with top two teams. We call the algorithm for one last time and it outputs the Final Winner

Dataset:

We have scraped the data from ICC’s T20 top 100 players and Cricbuzz websites using Beautiful Soup module and obtained the data for Batsmen, Bowler and All-Rounder separately.

Features used for Batsmen:

Innings

Runs Scored

Batting Average

Batting Strike Rate

Fifties

Fours

Sixes

Features used for Bowlers:

Innings

Wickets

Economy

Bowling Average

Bowling Strike Rate

Features used for All-Rounders:

Innings as Batsmen

Runs Scored

Batting Average

Batting Strike Rate

Fifties

Fours

Sixes

Innings as Bowler

Wickets

Economy

Bowling Average

Bowling Strike Rate

Now that we have our data, it is time for us to observe and understand the data.

Data Pre-Processing:

We have plotted the histogram of the data and observed that the data is highly right skewed. To overcome the skewness, we have log-transformed the data, so that the data is now approximately normal and our models work well.

Right Skewed Data

After applying log, approximately Normally distributed Data

We have observed that some records have 0 values for some of the features. We have dropped those records from our datasets. Most probably they are the players who played very less number of matches.

Model Building:

Now that we have processed and cleaned our data, we have to build the machine learning models on this cleaned data. We have implemented SGDRegressor, KNN-Regressor,Linear Regression using Least-Square Estimates, Weighted KNN-Regressor and compared our models with the Scikit learn’s model and we have achieved almost similar results to that of the Scikit Implementation.

SGD-Regressor:

We have provided the training data as the input to the models and found the best number of epoch using Cross Validation Data. AS we can see in the plots, the training error decreases as the epochs increases which means we are going towards convergence. We can increase the number of epochs to reduce the error furthermore, but we have stopped at 2000 epochs as the error fall rate is almost steady at this point.

We have got the best number of epochs using cross validation. Now, we can run the model with this best number of epochs on test data and we can obtain the predicted values. We can then compare our predicted values with the actual values to get the error.

After running our model on the test data, we get the below results.

We can see that Scikit implementation is almost similar to our results.

KNN-Regressor:

We have provided the training data as the input to the models and found the best number of neighbours using Cross Validation Data. As we can see from the plots, the training error increases as the value of K increases, which means that smaller values of K leads to overfitting and larger values of K leads to underfitting.

We have got the best number of neighbors using cross validation. Now, we can run the model with this best number of epochs on test data and we can obtain the predicted values. We can then compare our predicted values with the actual values to get the error.

After running our model on the test data, we get the below results.

We can see that Scikit implementation is almost similar to our results.

Output:

We have provided the player statistics to the above two machine learning models and applied the algorithm to predict the Winner of IPL 2020.

As we don’t know the schedule of the IPL-2020, we have randomly generated the matches. So, the order of the matches differ with both the machine learning algorithms. We also took home-advantage into consideration while building the algorithm.

Both the models predicted that Chennai Super Kings (CSK) will be the winner of IPL-2020.

Code:

All the code, analysis, graphs are available in GitHub.

Conclusions and Areas of Improvement: