{"id":16282869,"url":"https://github.com/asaficontact/project_floodlight","last_synced_at":"2025-06-18T21:32:27.267Z","repository":{"id":197723441,"uuid":"200716483","full_name":"asaficontact/project_floodlight","owner":"asaficontact","description":" Crisis incidents caused by rebel groups create a negative influence on the political and economic situation of a country. However, information about rebel group activities has always been limited. Sometimes these groups do not take responsibility for their actions, sometimes they falsely claim responsibility for other rebel group’s actions. This has made identifying the rebel group responsible for a crisis incident a significant challenge. Project Floodlight aims to utilize different machine learning techniques to understand and analyze activity patterns of 17 major rebel groups in Asia (including Taliban, Islamic State, and Al Qaeda). It uses classification algorithms such as Random Forest and XGBoost to predict the rebel group responsible for organizing a crisis event based on 14 different characteristics including number of fatalities, location, event type, and actor influenced. The dataset used comes from the Armed Conflict Location \u0026 Event Data Project (ACLED) which is a disaggregated data collection, analysis and crisis mapping project. The dataset contains information on more than 78000 incidents caused by rebel groups that took place in Asia from 2017 to 2019. Roughly 48000 of these observations were randomly selected and used to develop and train the model. The final model had an accuracy score of 84% and an F1 Score of 82% on testing dataset of about 30000 new observations that the algorithm had never seen. The project was programmed using Object Oriented Programming in Python in order to make it scalable. Project Floodlight can be further expended to understand other crisis events in Asia and Africa such as protests, riots, or violence against women.","archived":false,"fork":false,"pushed_at":"2022-12-05T17:42:05.000Z","size":9756,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T22:35:36.369Z","etag":null,"topics":["acled","asia","classification-model","crisis","grid-search","grid-search-hyperparameters","matplotlib","object-oriented-programming","pandas","python3","random-forest","sklearn","xgboost-model"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asaficontact.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-05T19:28:59.000Z","updated_at":"2025-02-25T04:58:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"e3669e83-4618-4928-80f2-8cc7d3ae010a","html_url":"https://github.com/asaficontact/project_floodlight","commit_stats":null,"previous_names":["asaficontact/project_floodlight"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asaficontact%2Fproject_floodlight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asaficontact%2Fproject_floodlight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asaficontact%2Fproject_floodlight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asaficontact%2Fproject_floodlight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asaficontact","download_url":"https://codeload.github.com/asaficontact/project_floodlight/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244041297,"owners_count":20388212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acled","asia","classification-model","crisis","grid-search","grid-search-hyperparameters","matplotlib","object-oriented-programming","pandas","python3","random-forest","sklearn","xgboost-model"],"created_at":"2024-10-10T19:11:53.205Z","updated_at":"2025-03-20T02:30:36.896Z","avatar_url":"https://github.com/asaficontact.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## NOTE\n#### Original files for the project exceed GitHub's maximum file size limit. Please contact me at asaficontact@gmail.com to access complete code and data files for the project.\n\n## Initial Setup\n\n\n```python\n#Do all necessary Pacakge Imports\nfrom imports import *\n```\n\n\n```python\n#Create a dataHandler class for our dataframe \ndata = dh()\n```\n\n\n```python\n#Get Data for crisis in asia and southern asia\nsouthern_asia_df = data.filter_data(region=['Southern Asia', 'South-Eastern Asia'])\nasia_df = data.filter_data(region=['Middle East', 'Southern Asia', 'South-Eastern Asia'])\n\n#Get Data for crisis in asia and southern asia caused by rebel groups\nasia_rebel_groups_df = data.filter_data(region=['Middle East', 'Southern Asia', 'South-Eastern Asia'], rebel_groups=True)\nsouthern_asia_rebel_groups_df = data.filter_data(region=['Southern Asia'], rebel_groups=True)\n```\n\n## Predictors of Interest\n\n#### 1: Fatalities\n#### 2: Event Type\n#### 3: Sub Event Type\n#### 4: Associate Actor 1 \n#### 5: Actor 2 \n#### 6: Inter 2\n#### 7: Interaction\n#### 8: Region\n#### 9: Admin 1\n#### 10: Admin 2\n#### 11: Admin 3\n#### 12: Location\n#### 13: Associate Actor 2\n#### 14: Country\n\nNOTE: To better understand the predictors look at documentation in Understanding_data folder.\n\n## Types of Actors involved in Crisis Dataset\n\n#### 1: State Forces\n#### 2: Rebel Groups\n#### 3: Political Militias\n#### 4: Identity Militias\n#### 5: Rioters\n#### 6: Protestors\n#### 7: Civilian\n#### 8: External/Other Forces\n\n## Crisis Data Initial Exploration for Asia\n\n##### Crisis to Fatalities per Country caused by All Actors[2017-2019]\n\n\n```python\ndata.crisis_to_fatalities_graph(asia_df, 'country_paired')\n```\n\n\n![png](README_files/main_13_0.png)\n\n\n##### Number of Crisis caused by all Actors per Country[2017-2019]\n\n\n```python\ndata.crisis_to_fatalities_graph(asia_df, type='crisis map')\n```\n\n\n![png](README_files/main_15_0.png)\n\n\n##### Crisis to Fatalities per Country caused by Rebel Groups[2017-2019]\n\n\n```python\ndata.crisis_to_fatalities_graph(asia_rebel_groups_df, 'country_paired')\n```\n\n\n![png](README_files/main_17_0.png)\n\n\n##### Number of Crisis caused by Rebel Groups per Country[2017-2019]\n\n\n```python\ndata.crisis_to_fatalities_graph(asia_rebel_groups_df, type='crisis map')\n```\n\n\n![png](README_files/main_19_0.png)\n\n\n##### Crisis to Fatalities per Event Type caused by All Actors[2017-2019]\n\n\n```python\ndata.crisis_to_fatalities_graph(asia_df, type='event_paired')\n```\n\n\n![png](README_files/main_21_0.png)\n\n\n##### Crisis to Fatalities per Country caused by Rebel Groups[2017-2019]\n\n\n```python\ndata.crisis_to_fatalities_graph(asia_rebel_groups_df, type='event_paired')\n```\n\n\n![png](README_files/main_23_0.png)\n\n\n## Random Forest Model for Classifying Rebel Groups in Afghanistan\n\n##### Creating best random forest for Afghanistan by Grid Search\n\n\n```python\n#Get Data for crisis in Afghanistan caused by rebel groups\nafg_rebel_groups_df = data.filter_data(country=['Afghanistan'], rebel_groups=True)\n#Get Random Forest [the best parameters have been found using grid search]\nafg_rebel_groups_rf = data.random_forest(afg_rebel_groups_df, max_depth= 30, min_samples_leaf=1, min_samples_split = 10, n_estimators=500, model_name = 'afghanistan')\n```\n\n##### Load best Random Forest model based of grid search for Afghanistan\n\n\n```python\nasia_rebel_groups_rf = data.load_model('Afghanistan')\n```\n\n##### Confusion Matrix for Training Data [Normalized]\n\n\n\n```python\ndata.plot_confusion_matrix(afg_rebel_groups_df, afg_rebel_groups_rf, dataset_type = 'train', normalize = True)\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x7fab923ebe48\u003e\n\n\n\n\n![png](README_files/main_30_1.png)\n\n\n##### Confusion Matrix for Testing Data [Normalized]\n\n\n```python\ndata.plot_confusion_matrix(afg_rebel_groups_df, afg_rebel_groups_rf, dataset_type = 'test', normalize = True)\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x7fab444f72b0\u003e\n\n\n\n\n![png](README_files/main_32_1.png)\n\n\n##### Tests to check accuracy of the model\n\n\n```python\ndata.classifier_accuracy(afg_rebel_groups_df, afg_rebel_groups_rf)\n```\n\n\n\n\n    {'training_accuracy': 0.8340914013428633,\n     'testing_accuracy': 0.8232618583495777,\n     'training_F1_weighted': 0.7805860368800424,\n     'testing_F1_weighted': 0.7674833570687929,\n     'training_precision_weighted': 0.8515754941098571,\n     'testing_precision_weighted': 0.8386940263095153,\n     'training_recall_weighted': 0.8340914013428633,\n     'testing_recall_weighted': 0.8232618583495777}\n\n\n\n## Random Forest Model for Classifying Rebel Groups in Southern Asia\n\n##### Load best Random Forest model based of grid search for Southern Asia\n\n\n```python\nsouthern_asia_rebel_groups_rf = data.load_model('southern_asia')\n```\n\n##### Confusion Matrix for Training Data [Normalized]\n\n\n```python\ndata.plot_confusion_matrix(southern_asia_rebel_groups_df, southern_asia_rebel_groups_rf, dataset_type = 'train', normalize = True)\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x7fc528549f28\u003e\n\n\n\n\n![png](README_files/main_39_1.png)\n\n\n##### Confusion Matrix for Testing Data [Normalized]\n\n\n```python\ndata.plot_confusion_matrix(southern_asia_rebel_groups_df, southern_asia_rebel_groups_rf, dataset_type = 'test', normalize = True)\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x7fc528549ac8\u003e\n\n\n\n\n![png](README_files/main_41_1.png)\n\n\n##### Tests to check accuracy of the model\n\n\n```python\ndata.classifier_accuracy(southern_asia_rebel_groups_df, southern_asia_rebel_groups_rf)\n```\n\n\n\n\n    {'training_accuracy': 0.8423524022218405,\n     'testing_accuracy': 0.8268338773406632,\n     'training_F1_weighted': 0.7898185645638188,\n     'testing_F1_weighted': 0.7707830293459663,\n     'training_precision_weighted': 0.8712670574510711,\n     'testing_precision_weighted': 0.8306234964296919,\n     'training_recall_weighted': 0.8423524022218405,\n     'testing_recall_weighted': 0.8268338773406632}\n\n\n\n## Random Forest Model for Classifying Rebel Groups in Asia\n\n##### Load best Random Forest model based of grid search for Asia\n\n\n```python\nasia_rebel_groups_rf = data.load_model('asia')\n```\n\n##### Confusion Matrix for Training Data [Normalized]\n\n\n\n```python\ndata.plot_confusion_matrix(asia_rebel_groups_df, asia_rebel_groups_rf, dataset_type = 'train', normalize = True)\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x7fc539b6a5c0\u003e\n\n\n\n\n![png](README_files/main_48_1.png)\n\n\n##### Confusion Matrix for Testing Data [Normalized]\n\n\n```python\ndata.plot_confusion_matrix(asia_rebel_groups_df, asia_rebel_groups_rf, dataset_type = 'test', normalize = True)\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x7fc549f98b00\u003e\n\n\n\n\n![png](README_files/main_50_1.png)\n\n\n##### Tests to check accuracy of the model\n\n\n```python\ndata.classifier_accuracy(asia_rebel_groups_df, asia_rebel_groups_rf)\n```\n\n\n\n\n    {'training_accuracy': 0.853942423468457,\n     'testing_accuracy': 0.84090411558669,\n     'training_F1_weighted': 0.8372359852046187,\n     'testing_F1_weighted': 0.8226387702490333,\n     'training_precision_weighted': 0.8441646669875207,\n     'testing_precision_weighted': 0.8279729962978163,\n     'training_recall_weighted': 0.853942423468457,\n     'testing_recall_weighted': 0.84090411558669}\n\n\n\n## Random Forest Model for Classifying Islamic State (Type of Rebel Group) in Asia\n\nCreate Dataset for Islamic State classification\n\n\n```python\nisis_df = data.filter_data(region = ['Southern Asia', 'Middle East', 'South-Eastern Asia'], rebel_groups= True, actor_name= 'islamic state')\n```\n\n##### Load best Random Forest model based of grid search for ISIS activity in Asia\n\n\n```python\nisis_rf = data.load_model('isis')\n```\n\n##### Confusion Matrix for Training Data [Normalized]\n\n\n\n```python\ndata.plot_confusion_matrix(isis_df, isis_rf, dataset_type = 'train', normalize = True)\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x7fe8183ffe48\u003e\n\n\n\n\n![png](README_files/main_59_1.png)\n\n\n##### Confusion Matrix for Testing Data [Normalized]\n\n\n```python\ndata.plot_confusion_matrix(isis_df, isis_rf, dataset_type = 'test', normalize = True)\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x7fe85d373588\u003e\n\n\n\n\n![png](README_files/main_61_1.png)\n\n\n##### Tests to check accuracy of the model\n\n\n```python\ndata.classifier_accuracy(isis_df, isis_rf)\n```\n\n\n\n\n    {'training_accuracy': 0.925958500276882,\n     'testing_accuracy': 0.9200664484291787,\n     'training_F1_weighted': 0.9238511827444541,\n     'testing_F1_weighted': 0.9177113406155695,\n     'training_precision_weighted': 0.9330340541392627,\n     'testing_precision_weighted': 0.9277676133005858,\n     'training_recall_weighted': 0.925958500276882,\n     'testing_recall_weighted': 0.9200664484291787}\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasaficontact%2Fproject_floodlight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasaficontact%2Fproject_floodlight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasaficontact%2Fproject_floodlight/lists"}