Analyzing South African Crime data using ChatGPT

A few years ago I published a blog post analyzing Crime data from the South African Police Service (SAPS) in a blog post. You can read it here. I thought it might be interesting to run the data from Open AI’s ChatGPT and see what it analysis it produces.

But first, the Looker Studio Visualization!

Here’s the South African crime data in a Looker Studio visualization.

The SAPS Crime Data

Here’s the SAPS crime data from 2010 to 2019. I compiled it myself from public data on the SAPS website. If you’d like to use this data for your own research, feel free to email me (michaelhoweely [at] and I’d be happy to send it to you.

Here’s a sample of what it looks like:

ChatGPT analysis of the Data

I uploaded the file which consists of 345,301 rows of data and asked it to analyse it. Below are some questions and answers.

ChatGPT: Can you analyze this data and produce some comments on it?

The dataset titled “Crime Stats for South Africa – all dates – 2020-07-19” contains detailed records of various crimes reported across different police stations in South Africa. Each record includes the type of crime, the number of incidents (labeled as “Crimes”), the police station where the crime was reported, the province, the crime category, geographical coordinates (latitude and longitude), and the year of the report. The first few rows indicate crimes such as murder, attempted murder, assault with the intent to inflict grievous bodily harm, common assault, and common robbery, all reported at the Aberdeen police station in the Eastern Cape province for the year 2010.

To provide an accurate analysis, I will examine the following aspects of the data:

  • The total number of crimes reported over the years covered in the dataset.
  • A breakdown of crimes by category and province.
  • Trends in specific types of crimes over the years.
  • Geographic distribution of crime reports.

Let’s proceed with this analysis.

Based on the analysis of the “Crime Stats for South Africa” dataset, here are some key findings:

Total Number of Crimes Reported:
Over the period covered by the dataset, there were a total of 18,250,958 crimes reported across South Africa.

Crimes Reported by Year:
The annual number of reported crimes has fluctuated over the years, starting at 1,812,190 in 2010 and experiencing slight variations, with a peak in 2017 at 1,863,526 crimes. By 2019, the total reported crimes slightly decreased to 1,843,022.

Crimes by Category:

  • Contact Crimes: The most reported crimes fall under this category, with a total of 5,330,438 incidents. These include crimes such as murder, attempted murder, and assault.
  • Property-Related Crimes: The second most reported category, with 4,788,733 incidents, includes theft, burglary, and robbery.
  • Crime detected as a result of Police Action: This category includes proactive efforts by the police to combat crime, totaling 2,480,435 incidents.
  • Other Serious Crimes and Contact-Related Crimes also show significant numbers, indicating a broad spectrum of criminal activities across the country.

    Crimes by Province:
  • Gauteng: This province reports the highest number of crimes, with a total of 5,027,487 incidents.
  • Western Cape: Follows with 3,375,569 reported crimes.
  • KwaZulu-Natal: With 3,069,980 incidents, is also significantly affected.
  • The Eastern Cape and Free State also report high numbers, indicating widespread issues across various regions.

The data reveals significant challenges in addressing crime across South Africa, with notable variances by type and region. Contact crimes, property-related crimes, and incidents detected through police action dominate the crime landscape, highlighting areas where law enforcement and community safety initiatives could be focused. The geographical distribution suggests that Gauteng, Western Cape, and KwaZulu-Natal, in particular, face substantial crime rates, necessitating targeted interventions to enhance public safety and security in these provinces.

ChatGPT: Can you provide some comments on interesting outliers in the data?

Upon examining the dataset for outliers, instances where the reported number of crimes is significantly higher than the typical range were identified, suggesting notable spikes in crime reports at certain locations and times. Here are some of the most interesting outliers:

  1. Common Assault in Alexandra, Gauteng (2018): 999 reported incidents. This exceptionally high number of common assault cases in a single year at Alexandra police station is a significant outlier, indicating either a surge in violent incidents or potentially a reporting anomaly.
  2. Drug-Related Crime in Orlando, Gauteng (2017): 999 reported incidents. Similarly, this spike in drug-related crimes at the Orlando police station highlights a major concern regarding drug abuse or trafficking in the area during that year.
  3. Theft Out of or From Motor Vehicle in Lyttelton, Gauteng (2012): 999 reported incidents. The high number of thefts from motor vehicles in Lyttelton points to a specific issue with vehicle security and theft in the region.
  4. All Theft Not Mentioned Elsewhere in Tembisa and Temba, Gauteng (2019): Both locations reported 998 incidents each. These figures suggest a widespread issue with various forms of theft not categorized under more specific crimes, indicating a general security challenge in these areas.

These outliers, particularly with the recurring appearance of the number 999 or 998, may also raise questions about the data collection or reporting process, such as potential data capping or entry errors. Nonetheless, these figures draw attention to areas with significant crime rates, especially in Gauteng Province, suggesting regions where law enforcement and community interventions may need to be intensified. It’s crucial for stakeholders to investigate these outliers further to understand the underlying causes and to develop effective strategies to address these high crime rates.

ChatGPT: Can you provide a list of the provinces and comment on which crimes are more prevalent in each province?

The analysis of the most prevalent crimes in each province of South Africa reveals distinct patterns, indicating varying crime challenges across the country. Here’s a summary of the top reported crime in each province based on the total number of incidents:

  • Eastern Cape: Assault with the intent to inflict grievous bodily harm is the most prevalent crime, with 266,091 reported incidents. This suggests a significant issue with violent personal assaults in the province.
  • Free State: Common assault leads the crime statistics with 156,105 incidents, pointing towards a high rate of physical violence encounters among individuals.
  • Gauteng: Burglary at residential premises is the most reported crime, with 546,596 incidents. This highlights a major concern for residential security and property crimes in South Africa’s economic hub.
  • KwaZulu-Natal: Similar to Gauteng, burglary at residential premises is also the top crime, with 371,891 reported incidents, indicating significant challenges in protecting homes against unauthorized entry and theft.
  • Limpopo: All theft not mentioned elsewhere, with 155,561 incidents, is the most prevalent crime, suggesting a wide range of theft-related issues that do not fall into more specific categories.
  • Mpumalanga: Here again, burglary at residential premises is the most reported crime, with 156,314 incidents, reflecting a common theme of property-related crimes in several provinces.
  • North West: Burglary at residential premises, with 140,012 reported incidents, also tops the list, further emphasizing the nationwide concern over residential burglaries.
  • Northern Cape: Assault with the intent to inflict grievous bodily harm, with 84,671 incidents, is the leading crime, indicating a significant issue with violent assaults in the province.
  • Western Cape: Drug-related crime, with 410,962 incidents, stands out as the most prevalent crime, highlighting a major concern over drug abuse and trafficking in the province.

These findings reveal a mix of violent and property-related crimes as predominant issues across different provinces, with burglary at residential premises being a particularly common challenge in many areas. In contrast, the Western Cape faces a distinct challenge with drug-related crimes, and violent assaults are more prevalent in the Eastern Cape and Northern Cape. These insights suggest the need for targeted interventions to address the specific crime patterns and challenges in each province.

ChatGPT: Can you bring in external population data for each province, and then determine which province had the highest number of crimes per capita?

To determine the province with the highest number of crimes per capita in South Africa based on the available crime data, we’ll need to incorporate external population data for each province. I’ll use approximate population figures for each province as of a recent year close to the dataset’s timeframe. After obtaining these figures, we’ll calculate the crime per capita for each province by dividing the total number of reported crimes by the population of the province.

Let’s proceed with estimated population figures for each province (these figures are approximations and may not reflect the exact population at the time of the dataset):

  • Eastern Cape: 6.5 million
  • Free State: 2.9 million
  • Gauteng: 15.5 million
  • KwaZulu-Natal: 11.5 million
  • Limpopo: 5.8 million
  • Mpumalanga: 4.7 million
  • North West: 4.0 million
  • Northern Cape: 1.3 million
  • Western Cape: 7.0 million

Now, let’s calculate the crime per capita for each province.

Here are the provinces of South Africa ranked from highest to lowest in terms of crimes per capita, based on the combined crime data and population estimates:

  1. Western Cape: 0.482 crimes per capita
  2. Free State: 0.385 crimes per capita
  3. Northern Cape: 0.359 crimes per capita
  4. Gauteng: 0.324 crimes per capita
  5. Eastern Cape: 0.304 crimes per capita
  6. KwaZulu-Natal: 0.267 crimes per capita
  7. North West: 0.264 crimes per capita
  8. Mpumalanga: 0.220 crimes per capita
  9. Limpopo: 0.195 crimes per capita

Based on the analysis incorporating external population data, the Western Cape province has the highest number of crimes per capita among all provinces in South Africa. With a crimes per capita rate of approximately 0.482, this indicates that for every person in the Western Cape, there were nearly half a crime reported, reflecting a significant crime rate relative to the population size of the province.

The visualization above illustrates the crime rate per capita by province in South Africa. It clearly shows the relative differences in crime rates across the provinces, with the Western Cape having the highest crime rate per capita, followed by Gauteng and other provinces in descending order.

ChatGPT: Can you visualize trends in murder rate over time by province?

The line graph above visualizes the trends in murder rates over time by province in South Africa. Each line represents a different province, illustrating how the number of murders has changed annually within the dataset’s timeframe.

From the graph, it is evident that some provinces have experienced fluctuations in murder rates over the years, while others have shown more consistent trends. The visualization provides a clear comparison across provinces, highlighting those with higher murder rates and those where murder rates have increased or decreased significantly over time.

This analysis can offer insights into the effectiveness of crime prevention strategies, the impact of socio-economic factors, and the need for targeted interventions in provinces with rising murder rates. It also underscores the importance of continuous monitoring and response to trends in violent crimes such as murder.


What did you think of ChatGPT’s efforts? Let me know in the comments.

My Other Blog Posts

Comparing DALL-E and Midjourney AI Images in 2024
Four in One Analytics Looker Studio Dashboard Template
Visualizing a young Africa and an aging World
Visualizing Fertility Rates across the World
GDP per Capita within African Regions