Giter Site home page Giter Site logo

el-bahnasawi / analyzing-u.s.-crime-data Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 52.55 MB

Jupyter Notebook 97.60% Python 2.40%
gradient-boosting-classifier hypothesis-testing linear-regression pca-analysis plotly random-forest-classifier umap recursive-feature-elimination variance-inflation-factor feature-selection

analyzing-u.s.-crime-data's Introduction

Project Overview ๐Ÿ“

This repository contains two separate notebooks focusing on exploratory data analysis (EDA) and regression analysis using machine learning (ML) models.

Notebook 1: Exploratory Data Analysis (EDA) ๐Ÿ“Š

  • Addressing questions through visualizations and hypothesis testing.
  • File: Project.ipynb

Notebook 2: Regression Analysis and ML Models ๐Ÿง 

This notebook is divided into several key steps:

  1. Data Validation and Preparation ๐Ÿ“

    • Ensuring data availability.
    • Reading the dataset.
    • Handling NaN values by categorizing them into numerical and categorical features. Then using KNN imputer for numerical features, Simple Imputer with most frequent for categorical features.
  2. Feature Engineering ๐Ÿ”ง

    • Identifying categorical features and further categorizing them into boolean, nominal, and ordinal.
    • Encoding nominal features using OneHotEncoder and ordinal features using OrdinalEncoder.
  3. Regression Analysis ๐Ÿ“ˆ

    • Investigating feature correlations via heatmap.
    • Conducting linear regression, assessing the model's performance with R2 score, and visualizing coefficients.
  4. Machine Learning Models ๐Ÿค–

    • Checking dataset balance.
    • Establishing a baseline accuracy.
    • Implementing various ML models, evaluating them with training and testing accuracies, confusion matrices, precision, recall, and AUC-ROC score.

Enhanced Model Building Process ๐Ÿ› ๏ธ

Outlined in models.py, the following comprehensive approach is undertaken:

Model Categories:

  • Dimensionality Reduction Models: These models employ techniques to reduce feature dimensionality while retaining crucial information.
  • Feature Selection Models: Focused on selecting pertinent features while discarding redundant or correlated ones.
  1. Dimensionality Reduction plus Classifier:

    • Pipeline Setup: Begins with StandardScaler for feature normalization, ensuring uniformity across features.
    • Dimensionality Management: using PCA and UMAP to reduce dimensionality while keeping valuable information
    • Classifier Integration: Incorporating Random Forest and Gradient Boosting classifiers to leverage ensemble learning for robust predictions.
    • Hyperparameter Tuning: RandomizedSearchCV facilitates efficient hyperparameter optimization, complemented by cross-validation to improve model generalization.
  2. Feature Selection Methods plus Classifier:

    • Recursive Feature Elimination (RFE): Prioritizes feature selection based on importance to model performance, further refining the feature set.
    • Correlation-based Feature Elimination: Subsequent utilization of Variance Inflation Factor (VIF) identifies and eliminates correlated features, enhancing model stability and interpretability.
    • Efficiency and Simplicity: These models offer lower computational complexities compared to their dimensionality reduction counterparts, ensuring suitability for scenarios prioritizing interpretability and computational efficiency.

Models Comparison ๐Ÿ“Š

Model Technique features Estimators/Neighbors Min Samples Split Max Depth Training Accuracy Test Accuracy
Model 1 PCA with RF 20 100 5 30 99.96% 97.12%
Model 2 PCA with GB 20 5 - 20 98.51% 92.55%
Model 3 UMAP with RF 20 - 2 20 100% 93.28%
Model 4 RFE, VIF, RF 40 50 - 4 99.26% 99.45%
Model 5 RFE, VIF, XGB 40 12 - 1 100% 100%

analyzing-u.s.-crime-data's People

Contributors

el-bahnasawi 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.