diff --git "a/IS424_Data_Mining/code/Classification/Classification models on incident category.ipynb" "b/IS424_Data_Mining/code/Classification/Classification models on incident category.ipynb" new file mode 100644--- /dev/null +++ "b/IS424_Data_Mining/code/Classification/Classification models on incident category.ipynb" @@ -0,0 +1,2908 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "3a7dd7d8", + "metadata": {}, + "source": [ + "## Import Statement" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "86fc25e6", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd" + ] + }, + { + "cell_type": "markdown", + "id": "fac53e88", + "metadata": {}, + "source": [ + "### read the data" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "dc33b13b", + "metadata": {}, + "outputs": [], + "source": [ + "df = pd.read_csv(\"../all_port_labelled.csv\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "31f58fd1", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + " | Unnamed: 0 | \n", + "Index | \n", + "Unnamed: 0.1 | \n", + "Headline | \n", + "Details | \n", + "Severity | \n", + "Category | \n", + "Region | \n", + "Datetime | \n", + "Year | \n", + "... | \n", + "IT | \n", + "EP | \n", + "NEW | \n", + "CSD | \n", + "RPE | \n", + "MN | \n", + "NM | \n", + "if_labeled | \n", + "Month | \n", + "Week | \n", + "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", + "0.0 | \n", + "8.0 | \n", + "34.0 | \n", + "Grasberg Mine- Grasberg mine workers extend st... | \n", + "Media sources indicate that workers at the Gra... | \n", + "Moderate | \n", + "Mine Workers Strike | \n", + "Indonesia | \n", + "28/5/17 17:08 | \n", + "2017.0 | \n", + "... | \n", + "0.0 | \n", + "0.0 | \n", + "0.0 | \n", + "0.0 | \n", + "0.0 | \n", + "0.0 | \n", + "1.0 | \n", + "False | \n", + "5.0 | \n", + "21.0 | \n", + "
1 | \n", + "1.0 | \n", + "10.0 | \n", + "63.0 | \n", + "Indonesia: Undersea internet cables damaged by... | \n", + "News sources are stating that recent typhoons ... | \n", + "Minor | \n", + "Travel Warning | \n", + "Indonesia | \n", + "4/9/17 14:30 | \n", + "2017.0 | \n", + "... | \n", + "0.0 | \n", + "0.0 | \n", + "0.0 | \n", + "0.0 | \n", + "0.0 | \n", + "1.0 | \n", + "0.0 | \n", + "False | \n", + "4.0 | \n", + "14.0 | \n", + "
2 rows × 46 columns
\n", + "\n", + " | Details | \n", + "Category | \n", + "Details_cleaned | \n", + "Category_cleaned | \n", + "
---|---|---|---|---|
0 | \n", + "Media sources indicate that workers at the Gra... | \n", + "Mine Workers Strike | \n", + "medium source indicate worker grasberg mine ex... | \n", + "Mine Workers Strike | \n", + "
1 | \n", + "News sources are stating that recent typhoons ... | \n", + "Travel Warning | \n", + "news source stating recent typhoon impact hong... | \n", + "Travel Warning | \n", + "
2 | \n", + "The persisting port congestion at Shanghai’s Y... | \n", + "Port Congestion | \n", + "persisting port congestion shanghai ’ yangshan... | \n", + "Port Congestion | \n", + "
3 | \n", + "Updated local media sources from Jakarta indic... | \n", + "Bombing, Police Operations | \n", + "updated local medium source jakarta indicate e... | \n", + "Bombing, Police Operations | \n", + "
4 | \n", + "According to local police in Jakarta, two expl... | \n", + "Bombing, Police Operations | \n", + "according local police jakarta two explosion c... | \n", + "Bombing, Police Operations | \n", + "
5 | \n", + "Severe winds have downed billboards and trees ... | \n", + "Roadway Closure / Disruption, Flooding, Severe... | \n", + "severe wind downed billboard tree bandung wedn... | \n", + "Roadway Closure / Disruption, Flooding, Severe... | \n", + "
6 | \n", + "Local media sources indicated on October 29 th... | \n", + "Cargo/Warehouse Theft | \n", + "local medium source indicated october 29 wareh... | \n", + "Cargo/Warehouse Theft | \n", + "
7 | \n", + "Tropical Storm Rumbia had dissipated after tra... | \n", + "Tropical Cyclone / Storm | \n", + "tropical storm rumbia dissipated travelling ar... | \n", + "Tropical Cyclone / Storm | \n", + "
8 | \n", + "Tropical Depression Yutu, also referred to as ... | \n", + "Storm | \n", + "tropical depression yutu also referred `` '' r... | \n", + "Storm | \n", + "
9 | \n", + "A magnitude 4.5 earthquake was detected 14 mil... | \n", + "Earthquake | \n", + "magnitude 4.5 earthquake detected 14 mile nort... | \n", + "Earthquake | \n", + "
\n", + " | Details | \n", + "Category | \n", + "Details_cleaned | \n", + "Category_cleaned | \n", + "Category_single | \n", + "
---|---|---|---|---|---|
0 | \n", + "Media sources indicate that workers at the Gra... | \n", + "Mine Workers Strike | \n", + "medium source indicate worker grasberg mine ex... | \n", + "Mine Workers Strike | \n", + "Mine Workers Strike | \n", + "
1 | \n", + "News sources are stating that recent typhoons ... | \n", + "Travel Warning | \n", + "news source stating recent typhoon impact hong... | \n", + "Travel Warning | \n", + "Travel Warning | \n", + "
2 | \n", + "The persisting port congestion at Shanghai’s Y... | \n", + "Port Congestion | \n", + "persisting port congestion shanghai ’ yangshan... | \n", + "Port Congestion | \n", + "Port Congestion | \n", + "
3 | \n", + "Updated local media sources from Jakarta indic... | \n", + "Bombing, Police Operations | \n", + "updated local medium source jakarta indicate e... | \n", + "Bombing, Police Operations | \n", + "Bombing | \n", + "
4 | \n", + "According to local police in Jakarta, two expl... | \n", + "Bombing, Police Operations | \n", + "according local police jakarta two explosion c... | \n", + "Bombing, Police Operations | \n", + "Bombing | \n", + "
5 | \n", + "Severe winds have downed billboards and trees ... | \n", + "Roadway Closure / Disruption, Flooding, Severe... | \n", + "severe wind downed billboard tree bandung wedn... | \n", + "Roadway Closure / Disruption, Flooding, Severe... | \n", + "Roadway Closure | \n", + "
6 | \n", + "Local media sources indicated on October 29 th... | \n", + "Cargo/Warehouse Theft | \n", + "local medium source indicated october 29 wareh... | \n", + "Cargo/Warehouse Theft | \n", + "Cargo | \n", + "
7 | \n", + "Tropical Storm Rumbia had dissipated after tra... | \n", + "Tropical Cyclone / Storm | \n", + "tropical storm rumbia dissipated travelling ar... | \n", + "Tropical Cyclone / Storm | \n", + "Tropical Cyclone | \n", + "
8 | \n", + "Tropical Depression Yutu, also referred to as ... | \n", + "Storm | \n", + "tropical depression yutu also referred `` '' r... | \n", + "Storm | \n", + "Storm | \n", + "
9 | \n", + "A magnitude 4.5 earthquake was detected 14 mil... | \n", + "Earthquake | \n", + "magnitude 4.5 earthquake detected 14 mile nort... | \n", + "Earthquake | \n", + "Earthquake | \n", + "
10 | \n", + "Multiple sources report that a magnitude 5.5 e... | \n", + "Earthquake | \n", + "multiple source report magnitude 5.5 earthquak... | \n", + "Earthquake | \n", + "Earthquake | \n", + "
11 | \n", + "Post-Tropical Cyclone Michael is approximately... | \n", + "Tropical Cyclone / Storm | \n", + "post-tropical cyclone michael approximately 18... | \n", + "Tropical Cyclone / Storm | \n", + "Tropical Cyclone | \n", + "
12 | \n", + "Industry sources indicate on September 11 that... | \n", + "Workplace Accident | \n", + "industry source indicate september 11 2 worker... | \n", + "Workplace Accident | \n", + "Workplace Accident | \n", + "
13 | \n", + "Government sources are reporting a tornado has... | \n", + "Tornado | \n", + "government source reporting tornado touched tw... | \n", + "Tornado | \n", + "Tornado | \n", + "
14 | \n", + "Media sources are informing on September 24 th... | \n", + "Industrial Action | \n", + "medium source informing september 24 oil worke... | \n", + "Industrial Action | \n", + "Industrial Action | \n", + "
15 | \n", + "A magnitude 4.5 earthquake was detected in cen... | \n", + "Earthquake | \n", + "magnitude 4.5 earthquake detected central taiw... | \n", + "Earthquake | \n", + "Earthquake | \n", + "
16 | \n", + "Industry sources indicate on August 31 that th... | \n", + "Port Congestion | \n", + "industry source indicate august 31 port durban... | \n", + "Port Congestion | \n", + "Port Congestion | \n", + "
17 | \n", + "Tropical Depression Gordon continues to weaken... | \n", + "Storm | \n", + "tropical depression gordon continues weaken mo... | \n", + "Storm | \n", + "Storm | \n", + "
18 | \n", + "Local media sources indicated on November 8 th... | \n", + "Public Safety / Security | \n", + "local medium source indicated november 8 270 k... | \n", + "Public Safety / Security | \n", + "Public Safety | \n", + "
19 | \n", + "The European-Mediterranean Seismological Centr... | \n", + "Earthquake | \n", + "european-mediterranean seismological centre re... | \n", + "Earthquake | \n", + "Earthquake | \n", + "
\n", + " | Weather | \n", + "Worker Strike | \n", + "Administrative Issue | \n", + "Human Error | \n", + "Cyber Attack | \n", + "Terrorism | \n", + "Accident | \n", + "Others | \n", + "
---|---|---|---|---|---|---|---|---|
0 | \n", + "Flooding | \n", + "Mine Workers Strike | \n", + "Port Congestion | \n", + "Workplace Accident | \n", + "Network Disruption | \n", + "Bombing | \n", + "Maritime Accident | \n", + "Miscellaneous Events | \n", + "
1 | \n", + "Severe Winds | \n", + "Production Halt | \n", + "Police Operations | \n", + "Individuals in Focus | \n", + "Ransomware | \n", + "Warehouse Theft | \n", + "Vehicle Accident | \n", + "Miscellaneous Strikes | \n", + "
2 | \n", + "Weather Advisory | \n", + "Protest | \n", + "Roadway Closure | \n", + "Military Operations | \n", + "Data breach | \n", + "Public Safety | \n", + "Death | \n", + "Outbreak of disease | \n", + "
3 | \n", + "Tropical Cyclone | \n", + "Riot | \n", + "Disruption | \n", + "Flight Delays | \n", + "Phishing | \n", + "Security | \n", + "Injury | \n", + "NaN | \n", + "
4 | \n", + "Storm | \n", + "Port Strike | \n", + "Cargo | \n", + "Cancellations | \n", + "NaN | \n", + "Organized Crime | \n", + "Non-industrial Fire | \n", + "NaN | \n", + "
\n", + " | Details | \n", + "Category | \n", + "Details_cleaned | \n", + "Category_cleaned | \n", + "Category_single | \n", + "Summarized_label | \n", + "
---|---|---|---|---|---|---|
0 | \n", + "Media sources indicate that workers at the Gra... | \n", + "Mine Workers Strike | \n", + "medium source indicate worker grasberg mine ex... | \n", + "Mine Workers Strike | \n", + "Mine Workers Strike | \n", + "Worker Strike | \n", + "
1 | \n", + "News sources are stating that recent typhoons ... | \n", + "Travel Warning | \n", + "news source stating recent typhoon impact hong... | \n", + "Travel Warning | \n", + "Travel Warning | \n", + "Administrative Issue | \n", + "
2 | \n", + "The persisting port congestion at Shanghai’s Y... | \n", + "Port Congestion | \n", + "persisting port congestion shanghai ’ yangshan... | \n", + "Port Congestion | \n", + "Port Congestion | \n", + "Administrative Issue | \n", + "
3 | \n", + "Updated local media sources from Jakarta indic... | \n", + "Bombing, Police Operations | \n", + "updated local medium source jakarta indicate e... | \n", + "Bombing, Police Operations | \n", + "Bombing | \n", + "Terrorism | \n", + "
4 | \n", + "According to local police in Jakarta, two expl... | \n", + "Bombing, Police Operations | \n", + "according local police jakarta two explosion c... | \n", + "Bombing, Police Operations | \n", + "Bombing | \n", + "Terrorism | \n", + "
... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "... | \n", + "
5777 | \n", + "Intelligence received by Everstream Analytics ... | \n", + "Ice Storm | \n", + "intelligence received everstream analytics ind... | \n", + "Ice Storm | \n", + "Ice Storm | \n", + "Administrative Issue | \n", + "
5778 | \n", + "Meteorological sources indicate that a series ... | \n", + "Roadway Closure / Disruption, Ground Transport... | \n", + "meteorological source indicate series winter s... | \n", + "Roadway Closure / Disruption, Ground Transport... | \n", + "Roadway Closure | \n", + "Administrative Issue | \n", + "
5779 | \n", + "Industry sources report on December 7 that Svi... | \n", + "Industrial Action | \n", + "industry source report december 7 svitzer aust... | \n", + "Industrial Action | \n", + "Industrial Action | \n", + "Administrative Issue | \n", + "
5780 | \n", + "Industry sources indicate on December 14 that ... | \n", + "Port Strike | \n", + "industry source indicate december 14 worker dp... | \n", + "Port Strike | \n", + "Port Strike | \n", + "Worker Strike | \n", + "
5781 | \n", + "On November 17, Dutch media sources reported t... | \n", + "Port Strike | \n", + "november 17 dutch medium source reported worke... | \n", + "Port Strike | \n", + "Port Strike | \n", + "Worker Strike | \n", + "
5780 rows × 6 columns
\n", + "MultinomialNB()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
MultinomialNB()
MultinomialNB(alpha=0.1)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
MultinomialNB(alpha=0.1)
LogisticRegression()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
LogisticRegression()
SVC(kernel='linear')In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
SVC(kernel='linear')
RandomForestClassifier(random_state=42)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
RandomForestClassifier(random_state=42)