Giter VIP home page Giter VIP logo

compiler0110 / analyzing_crime_data_in_los_angeles Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 680 KB

The Los Angeles Crime Data Analysis and Time Series Forecasting code provides insights into crime patterns and victim characteristics in Los Angeles. The code covers various aspects of data analysis, visualization, and forecasting using crime data.

License: MIT License

Jupyter Notebook 100.00%

analyzing_crime_data_in_los_angeles's Introduction

Los Angeles Crime Data Analysis and Time Series Forecasting

#Introduction

The Los Angeles Crime Data Analysis and Time Series Forecasting code provides insights into crime patterns and victim characteristics in Los Angeles. The code covers various aspects of data analysis, visualization, and forecasting using crime data.

Code Sections

The code is divided into several sections, each serving a specific purpose.

Data Preprocessing and Exploratory Data Analysis

In this section, the code prepares the data for analysis and explores various aspects of crime data:

  1. Filtering Male and Female Victims:

    • The code separates crime records based on the gender of victims (Male and Female).
    • It calculates and displays the number of male and female victims.
  2. Visualizing Crime Trends Over Time:

    • It visualizes the temporal distribution of crimes in Los Angeles, showing how the number of crimes changes over time.
    • Data is aggregated by month, and a line plot is generated to illustrate the trends.
  3. Analyzing Crime by Area:

    • The code calculates the number of crimes in each geographical area.
    • A bar chart is created to show the areas with the highest crime rates.
  4. Identifying Common Crime Types:

    • The code identifies the most common types of crimes.
    • It generates a bar chart displaying the top 10 crime types.
  5. Exploring the Distribution of Victim Ages:

    • Victim ages are visualized using a histogram.
    • The distribution of victim ages is displayed.
  6. Analyzing the Distribution of Victim Sex:

    • The code calculates the distribution of victim genders.
    • A pie chart is created to visualize the proportions.
  7. Analyzing Victim Descent Categories:

    • The code identifies the top 10 victim descent categories.
    • A bar chart is generated to show the distribution of victim descents.
  8. Analyzing Weapons Used in Crimes:

    • The code calculates the frequency of weapon usage in crimes.
    • A bar chart displays the most frequently used weapons.

Creating a Subset and Displaying on a Map

The code selects a random subset of crime data and displays it on a map using the Folium library.

Analyzing Victim Characteristics

This section focuses on analyzing victim characteristics, including age, sex, and descent.

Time Series Forecasting Using ARIMA

In this section, time series forecasting is performed using the ARIMA (AutoRegressive Integrated Moving Average) model:

  1. Data Preprocessing:

    • 'DATE OCC' column is converted to datetime and set as the index.
    • Data is aggregated by day.
  2. Stationarity Check:

    • The Augmented Dickey-Fuller test is used to check for stationarity in the time series data.
  3. Differencing:

    • If the time series is not stationary, differencing is applied.
  4. Building the ARIMA Model:

    • ARIMA model with hyperparameters (p, d, q) is created.
  5. Making Predictions:

    • Future crime counts are forecasted.
  6. Plotting the Forecast:

    • The forecasted crime counts are plotted along with historical data.

Conclusion

My code provides a comprehensive analysis of Los Angeles crime data, offering insights into crime patterns and victim characteristics. Additionally, it performs time series forecasting to predict future crime counts. This code can serve as a valuable resource for understanding and analyzing crime trends in Los Angeles.

analyzing_crime_data_in_los_angeles's People

Contributors

compiler0110 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.