Cricket Match Winner Prediction with Amazon Bedrock's Anthropic Claude 3 Sonnet

Utilizing Amazon Bedrock's new Claude 3.0 Sonnet Model, predict cricket match winners by extracting data from match statistics images for predictive insights.

Published Mar 11, 2024
Last Modified Mar 12, 2024

Context:

Five Test match, as part of the England tour of India, stands as a testament to the intensity and excitement that cricket brings.
In this blog/notebook I am using AWS Bedrock New announcements Amazon Claude 3.0 Sonnet Model to analyze match statistics image and even predict who will be winner.
Source: https://www.espncricinfo.com/series/england-in-india-2023-24-1389386/india-vs-england-5th-test-1389403/match-statistics
Key Features I noticed during this Exercise:
Image Recognition: The model employs state-of-the-art image recognition algorithms to accurately identify and extract relevant cricket match statistics from image files.
Statistical Analysis: With a deep understanding of cricketing metrics and game dynamics, the model analyzes extracted data to discern patterns, trends, and performance indicators.
Predictive Analytics: By synthesizing extracted statistics and historical trends, the model generates predictive insights to forecast the likely outcome of the cricket match
Data Extraction: The Amazon Claude Sonnet Model ingests image files containing cricket match statistics, leveraging its image recognition capabilities to extract relevant.

Github Link - Notebook

Environment Setup

I am using vscode local environment with AWS Credential configured.

Install Latest Python

Upgrade pip

Install latest boto3,awscli, boto3-core

Load the Library

Anthropic Claude Model

Anthropic is the AI safety and research company behind Claude - the frontier model used by millions of businesses and consumers for its emphasis on safety and performance.
You can read highlevel about more on Claude 3 Sonnet - https://www.dataopslabs.com/claude-3-sonnet-and-aws-bedrock-integration
Prompt - For Usecase 1 and 2 - Process the Stats in Image
Your task is to create a comprehensive Cricket Match Stats Analysis & Outcome Prediction, Extract stats from uploaded images, including player performances and match conditions. Use predictive modeling to forecast match outcomes based on provide data

Set the Prompt

Configure Model Configuration: Specify the model ID, Anthropic version, and maximum tokens for text completion

Read the Image

batting

Parse the Image: Read the image file and encode it into base64 format

Construct the API request body including the image data and prompt text

Create a Function to Invoke

Invoke the Function

Text completion:
The image shows detailed batting stats for two cricket players - Shubman Gill and RG Sharma - in what appears to be an innings from a cricket match. The stats are presented in circular charts that break down the runs scored through various shot types and scoring regions.\n\nFor Shubman Gill, the key stats shown are:\n- Total runs scored: 110 (off 150 balls)\n- Fours hit: 12\n- Sixes hit: 5\n- His most productive shot was the cut shot, scoring 23 runs including 4 fours

Usecase2 - Process Both Bowling and Batting Stats

batting_and_bowling

Parse the Image: Read the image file and encode it into base64 format

Construct the API request body including the image data and prompt text

Create a Function to Invoke

Invoke the Function

Text completion:
Based on the image, cricket match statistics can be analyzed to provide insights as follows:
Batting Analysis:
  • Shubman Gill (IND) scored 110 runs off 150 deliveries, including 12 fours and 5 sixes. His most productive shot was the cut shot (23 runs, 4 fours).
  • RG Sharma (IND) scored 103 runs off 162 deliveries, with 13 fours and 3 sixes. His most productive shot was the flick shot (22 runs, 3 fours).
Bowling Analysis:
  • Shoaib Bashir (ENG) bowled 5 overs, conceding 46 runs while taking 5 wickets at an economy rate of 3.74. His lengths were mostly good length and full length deliveries.
  • Kuldeep Yadav (IND) bowled 1 over, conceding 15 runs while taking 1 wicket at an economy rate of 4.8. His lengths were mostly short of good length and short length deliveries.

Usecase 3 - Predict Series Outcome based on Stats

Prompt - For Usecase 3
Your task is to create a comprehensive Cricket Match Stats Analysis and Outcome Prediction based on the image provided, The match is between India vs England 5 Match Test series. Provide player name, country with statistics. Use predictive modeling to forecast match outcomes based on date from only uploaded image. Need the prediction of Match with team or country name on who will win the match based on the data. Give me the output in bullet points. I am giving some stats for this series

Set the Prompt

Configure the Model

Process the Image

series performance

Parse the Image: Read the image file and encode it into base64 format

Construct the API request body including the image data and prompt text

Create a Function to Invoke

Invoke the Function

Text completion in Responsible Manner:
Based on the provided stats for the India vs England 5-match Test series, here is a comprehensive analysis and match outcome prediction:
• Top run-scorers:
- Yashasvi Jaiswal (IND) - 712 runs at 89.00 average
- Shubman Gill (IND) - 452 runs at 56.50 average
- Zak Crawley (ENG) - 407 runs at 40.70 average
• Top wicket-takers:
- Ravichandran Ashwin (IND) - 26 wickets at 24.80 average
- Tom Hartley (ENG) - 22 wickets at 36.13 average
- Jasprit Bumrah (IND) - 19 wickets at 16.89 average
• Best batting strike rates:
- Mark Wood (ENG) - 90.56
- Ben Duckett (ENG) - 85.75
- Jonny Bairstow (ENG) - 82.06
• Best bowling economy rates:
- Jack Leach (ENG) - 2.67
- James Anderson (ENG) - 3.05
- Jasprit Bumrah (IND) - 3.09
• India has the top run-scorer in Jaiswal and one of the best bowlers in Bumrah
• England has a solid batting lineup with good strike rates
• Both teams have quality bowlers, but India's attack looks slightly better
• Based on the provided stats and predictive modeling, India appears to have a slight edge over England in this 5-match Test series
• However, Test cricket is known for its unpredictability, and the actual outcome may vary depending on various factors beyond these stats
 

Comments