File size: 116,031 Bytes
76cd8d0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 |
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "4pXaxnMWrteH"
},
"source": [
"# Aim: To calculate respective element-wise Cohen Kappa Scores for our custom inter-annotator datasets.\n",
"\n",
"- Tweet Dataset\n",
"- Fake News Dataset"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-12-06T20:07:39.375584Z",
"iopub.status.busy": "2022-12-06T20:07:39.374981Z",
"iopub.status.idle": "2022-12-06T20:07:39.382165Z",
"shell.execute_reply": "2022-12-06T20:07:39.380382Z",
"shell.execute_reply.started": "2022-12-06T20:07:39.375550Z"
},
"id": "K9lHkfzZUPyu",
"trusted": true
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "gPGOd15ndFk2"
},
"source": [
"# Overlapping Twitter News"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "20ml5y3yigqj"
},
"outputs": [],
"source": [
"df = pd.read_csv(\"<link to overlapping data twitter news dataset .csv>\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 791
},
"id": "gdgHmS61ignW",
"outputId": "99d7fe5a-8ed4-46bc-a8a2-1e793a051b6e"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <div id=\"df-a457372f-8c71-4f53-876a-2fedd290da21\">\n",
" <div class=\"colab-df-container\">\n",
" <div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>S_1</th>\n",
" <th>Ann_1.1</th>\n",
" <th>Ann_1.2</th>\n",
" <th>Ann_1.3</th>\n",
" <th>Ann_1.4</th>\n",
" <th>Ann_1.5</th>\n",
" <th>Ann_1.6</th>\n",
" <th>Ann_1.7</th>\n",
" <th>S_2</th>\n",
" <th>Ann_2.1</th>\n",
" <th>Ann_2.2</th>\n",
" <th>Ann_2.3</th>\n",
" <th>Ann_2.4</th>\n",
" <th>Ann_2.5</th>\n",
" <th>Ann_2.6</th>\n",
" <th>Ann_2.7</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Is that a cave painting site? Exciting prizes ...</td>\n",
" <td>Speculation</td>\n",
" <td>The sentence does not provide sound logic to s...</td>\n",
" <td>When,Where,Why</td>\n",
" <td>Grey</td>\n",
" <td>the statement don’t have any positive and nega...</td>\n",
" <td>Gaining Advantage</td>\n",
" <td>Educational</td>\n",
" <td>Is that a cave painting site? Exciting prizes ...</td>\n",
" <td>Speculation</td>\n",
" <td>No Proof</td>\n",
" <td>When,Where,Why</td>\n",
" <td>Grey</td>\n",
" <td>told to hype it</td>\n",
" <td>Gaining Advantage</td>\n",
" <td>Educational</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Sonia Gandhi to travel abroad for medical chec...</td>\n",
" <td>Speculation</td>\n",
" <td>The sentence does not provide sound logic to s...</td>\n",
" <td>When,Where</td>\n",
" <td>Grey</td>\n",
" <td>the statement don’t have any positive and nega...</td>\n",
" <td>Gaining Esteem</td>\n",
" <td>Political</td>\n",
" <td>Sonia Gandhi to travel abroad for medical chec...</td>\n",
" <td>Speculation</td>\n",
" <td>No Proof</td>\n",
" <td>When,Where</td>\n",
" <td>Grey</td>\n",
" <td>NaN</td>\n",
" <td>Gaining Esteem</td>\n",
" <td>Political</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>S&T dept to set up 75 science hubs exclusively...</td>\n",
" <td>Speculation</td>\n",
" <td>The sentence does not provide sound logic to s...</td>\n",
" <td>When</td>\n",
" <td>Grey</td>\n",
" <td>the statement don’t have any positive and nega...</td>\n",
" <td>Gaining Advantage</td>\n",
" <td>Political</td>\n",
" <td>S&T dept to set up 75 science hubs exclusively...</td>\n",
" <td>Speculation</td>\n",
" <td>No Proof</td>\n",
" <td>When,Where,Why</td>\n",
" <td>Grey</td>\n",
" <td>told to show that they care for them</td>\n",
" <td>Gaining Advantage</td>\n",
" <td>Political</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>PM Modi’s nuclear power push gains traction wi...</td>\n",
" <td>Speculation</td>\n",
" <td>The sentence does not provide sound logic to s...</td>\n",
" <td>When,Where,Why</td>\n",
" <td>Grey</td>\n",
" <td>the statement don’t have any positive and nega...</td>\n",
" <td>Gaining Advantage</td>\n",
" <td>Political</td>\n",
" <td>PM Modi’s nuclear power push gains traction wi...</td>\n",
" <td>Speculation</td>\n",
" <td>Gains traction' without any proof,Inclined tow...</td>\n",
" <td>When,Where,Why</td>\n",
" <td>Black</td>\n",
" <td>Inclined towards one side</td>\n",
" <td>Gaining Esteem</td>\n",
" <td>Political</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>India to showcase environmental conscious life...</td>\n",
" <td>Opinion</td>\n",
" <td>person showing his thoughts for the enviornment</td>\n",
" <td>When,Where,Why</td>\n",
" <td>Grey</td>\n",
" <td>the statement don’t have any positive and nega...</td>\n",
" <td>Gaining Esteem</td>\n",
" <td>Political</td>\n",
" <td>India to showcase environmental conscious life...</td>\n",
" <td>Distortion</td>\n",
" <td>No proof , evidence to support the statement</td>\n",
" <td>NaN</td>\n",
" <td>Black</td>\n",
" <td>Inclined towards one side</td>\n",
" <td>Defaming Esteem</td>\n",
" <td>Political</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>\n",
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-a457372f-8c71-4f53-876a-2fedd290da21')\"\n",
" title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
" width=\"24px\">\n",
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
" </svg>\n",
" </button>\n",
" \n",
" <style>\n",
" .colab-df-container {\n",
" display:flex;\n",
" flex-wrap:wrap;\n",
" gap: 12px;\n",
" }\n",
"\n",
" .colab-df-convert {\n",
" background-color: #E8F0FE;\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: #1967D2;\n",
" height: 32px;\n",
" padding: 0 0 0 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-convert:hover {\n",
" background-color: #E2EBFA;\n",
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: #174EA6;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert {\n",
" background-color: #3B4455;\n",
" fill: #D2E3FC;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert:hover {\n",
" background-color: #434B5C;\n",
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
" fill: #FFFFFF;\n",
" }\n",
" </style>\n",
"\n",
" <script>\n",
" const buttonEl =\n",
" document.querySelector('#df-a457372f-8c71-4f53-876a-2fedd290da21 button.colab-df-convert');\n",
" buttonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
"\n",
" async function convertToInteractive(key) {\n",
" const element = document.querySelector('#df-a457372f-8c71-4f53-876a-2fedd290da21');\n",
" const dataTable =\n",
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
" [key], {});\n",
" if (!dataTable) return;\n",
"\n",
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
" + ' to learn more about interactive tables.';\n",
" element.innerHTML = '';\n",
" dataTable['output_type'] = 'display_data';\n",
" await google.colab.output.renderOutput(dataTable, element);\n",
" const docLink = document.createElement('div');\n",
" docLink.innerHTML = docLinkHtml;\n",
" element.appendChild(docLink);\n",
" }\n",
" </script>\n",
" </div>\n",
" </div>\n",
" "
],
"text/plain": [
" S_1 Ann_1.1 \\\n",
"0 Is that a cave painting site? Exciting prizes ... Speculation \n",
"1 Sonia Gandhi to travel abroad for medical chec... Speculation \n",
"2 S&T dept to set up 75 science hubs exclusively... Speculation \n",
"3 PM Modi’s nuclear power push gains traction wi... Speculation \n",
"4 India to showcase environmental conscious life... Opinion \n",
"\n",
" Ann_1.2 Ann_1.3 Ann_1.4 \\\n",
"0 The sentence does not provide sound logic to s... When,Where,Why Grey \n",
"1 The sentence does not provide sound logic to s... When,Where Grey \n",
"2 The sentence does not provide sound logic to s... When Grey \n",
"3 The sentence does not provide sound logic to s... When,Where,Why Grey \n",
"4 person showing his thoughts for the enviornment When,Where,Why Grey \n",
"\n",
" Ann_1.5 Ann_1.6 \\\n",
"0 the statement don’t have any positive and nega... Gaining Advantage \n",
"1 the statement don’t have any positive and nega... Gaining Esteem \n",
"2 the statement don’t have any positive and nega... Gaining Advantage \n",
"3 the statement don’t have any positive and nega... Gaining Advantage \n",
"4 the statement don’t have any positive and nega... Gaining Esteem \n",
"\n",
" Ann_1.7 S_2 \\\n",
"0 Educational Is that a cave painting site? Exciting prizes ... \n",
"1 Political Sonia Gandhi to travel abroad for medical chec... \n",
"2 Political S&T dept to set up 75 science hubs exclusively... \n",
"3 Political PM Modi’s nuclear power push gains traction wi... \n",
"4 Political India to showcase environmental conscious life... \n",
"\n",
" Ann_2.1 Ann_2.2 \\\n",
"0 Speculation No Proof \n",
"1 Speculation No Proof \n",
"2 Speculation No Proof \n",
"3 Speculation Gains traction' without any proof,Inclined tow... \n",
"4 Distortion No proof , evidence to support the statement \n",
"\n",
" Ann_2.3 Ann_2.4 Ann_2.5 \\\n",
"0 When,Where,Why Grey told to hype it \n",
"1 When,Where Grey NaN \n",
"2 When,Where,Why Grey told to show that they care for them \n",
"3 When,Where,Why Black Inclined towards one side \n",
"4 NaN Black Inclined towards one side \n",
"\n",
" Ann_2.6 Ann_2.7 \n",
"0 Gaining Advantage Educational \n",
"1 Gaining Esteem Political \n",
"2 Gaining Advantage Political \n",
"3 Gaining Esteem Political \n",
"4 Defaming Esteem Political "
]
},
"execution_count": 603,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Ew9vqgHyigkn"
},
"outputs": [],
"source": [
"#convert ann_1 and ann_2 into small letter\n",
"df2 = df.apply(lambda x: x.astype(str).str.lower())"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Gnb5gexkqOJT"
},
"source": [
"## Cohen-Kappa Score implementation: (Manual)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Mt05V5Juigf9"
},
"outputs": [],
"source": [
"def cohen_kappa(ann1, ann2):\n",
" \"\"\"Computes Cohen kappa for pair-wise annotators.\n",
" :param ann1: annotations provided by first annotator\n",
" :type ann1: list\n",
" :param ann2: annotations provided by second annotator\n",
" :type ann2: list\n",
" :rtype: float\n",
" :return: Cohen kappa statistic\n",
" \"\"\"\n",
" count = 0\n",
" for an1, an2 in zip(ann1, ann2):\n",
" if an1 == an2:\n",
" count += 1\n",
" # print(count, len(ann1))\n",
" A = count / len(ann1) # observed agreement A (Po)\n",
"\n",
" uniq = set(ann1 + ann2)\n",
" # print(uniq)\n",
" E = 0 # expected agreement E (Pe)\n",
" for item in uniq:\n",
" cnt1 = ann1.count(item)\n",
" cnt2 = ann2.count(item)\n",
" count = ((cnt1 / len(ann1)) * (cnt2 / len(ann2)))\n",
" E += count\n",
" # print(A, E)\n",
" return round((A - E) / (1 - E), 4)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "HIliUydFqUi_"
},
"source": [
"## For SBDO Column:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "K79_jFVYigb1",
"outputId": "0d093681-2794-434d-cbf8-b25c167f1aa8"
},
"outputs": [
{
"data": {
"text/plain": [
"speculation 154\n",
"sounds factual 130\n",
"opinion 105\n",
"distortion 81\n",
"bias 22\n",
"speculation,bias 1\n",
"Name: Ann_1.1, dtype: int64"
]
},
"execution_count": 607,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_1.1'].str.strip().value_counts()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "lDQQGv3HigZJ",
"outputId": "c02e7fa4-4305-47d4-c786-41e4a69ca1a2"
},
"outputs": [
{
"data": {
"text/plain": [
"speculation 204\n",
"sounds factual 122\n",
"opinion 92\n",
"distortion 40\n",
"bias 32\n",
"speculation,bias 2\n",
"speculation,sounds factual 1\n",
"Name: Ann_2.1, dtype: int64"
]
},
"execution_count": 608,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_2.1'].str.strip().value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "xBbHJ7ZXqWS4"
},
"source": [
"### Overall Kappa Score\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "GHZQOWMmiwiT",
"outputId": "4d3d2b32-d559-4a4c-c5c7-7bd94477033f"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cohen kappa score for SBDOSF column: 0.4019\n"
]
}
],
"source": [
"# Overall all kappa scores\n",
"ann1 = df2['Ann_1.1'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.1'].str.strip().to_list()\n",
"print(f'Cohen kappa score for SBDOSF column: {cohen_kappa(ann1, ann2)}')"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "tAtoh0WhqaNA"
},
"source": [
"### Element-wise Kappa Score"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "sSTEJP1fP35A",
"outputId": "d192a2b8-b648-48ce-c201-d62f9a15d584"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cohen_kappa score for speculation : 0.4651 and total when's according to ann_1 & ann_2 are 155 & 207 respectively!\n",
"cohen_kappa score for sounds factual : 0.5376 and total sounds factual's according to ann_1 & ann_2 are 130 & 123 respectively!\n",
"cohen_kappa score for opinion : 0.398 and total opinion's according to ann_1 & ann_2 are 105 & 92 respectively!\n",
"cohen_kappa score for distortion : 0.1748 and total distortion's according to ann_1 & ann_2 are 81 & 40 respectively!\n",
"cohen_kappa score for bias : 0.0525 and total bias's according to ann_1 & ann_2 are 23 & 34 respectively!\n"
]
}
],
"source": [
"ann1 = df2['Ann_1.1'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.1'].str.strip().to_list()\n",
"\n",
"# for speculation\n",
"speculation_1 = [1 if when.find('speculation')>-1 else 0 for when in ann1]\n",
"speculation_2 = [1 if when.find('speculation')>-1 else 0 for when in ann2]\n",
"count_speculation_1, count_speculation_2 = sum(speculation_1), sum(speculation_2)\n",
"print(f'cohen_kappa score for speculation : {cohen_kappa(speculation_1, speculation_2)} and total when\\'s according to ann_1 & ann_2 are {count_speculation_1} & {count_speculation_2} respectively!')\n",
"\n",
"# For sounds factual\n",
"sounds_factual_1 = [1 if why.find('sounds factual')>-1 else 0 for why in ann1]\n",
"sounds_factual_2 = [1 if why.find('sounds factual')>-1 else 0 for why in ann2]\n",
"count_sounds_factual_1, count_sounds_factual_2 = sum(sounds_factual_1), sum(sounds_factual_2)\n",
"\n",
"print(f'cohen_kappa score for sounds factual : {cohen_kappa(sounds_factual_1, sounds_factual_2)} and total sounds factual\\'s according to ann_1 & ann_2 are {count_sounds_factual_1} & {count_sounds_factual_2} respectively!')\n",
"\n",
"\n",
"# For opinion\n",
"opinion_1 = [1 if who.find('opinion')>-1 else 0 for who in ann1]\n",
"opinion_2 = [1 if who.find('opinion')>-1 else 0 for who in ann2]\n",
"count_opinion_1, count_opinion_2 = sum(opinion_1), sum(opinion_2)\n",
"\n",
"print(f'cohen_kappa score for opinion : {cohen_kappa(opinion_1, opinion_2)} and total opinion\\'s according to ann_1 & ann_2 are {count_opinion_1} & {count_opinion_2} respectively!')\n",
"\n",
"\n",
"# For distortion\n",
"distortion_1 = [1 if where.find('distortion')>-1 else 0 for where in ann1]\n",
"distortion_2 = [1 if where.find('distortion')>-1 else 0 for where in ann2]\n",
"count_distortion_1, count_distortion_2 = sum(distortion_1), sum(distortion_2)\n",
"\n",
"print(f'cohen_kappa score for distortion : {cohen_kappa(distortion_1, distortion_2)} and total distortion\\'s according to ann_1 & ann_2 are {count_distortion_1} & {count_distortion_2} respectively!')\n",
"\n",
"\n",
"# For bias\n",
"bias_1 = [1 if what.find('bias')>-1 else 0 for what in ann1]\n",
"bias_2 = [1 if what.find('bias')>-1 else 0 for what in ann2]\n",
"count_bias_1, count_bias_2 = sum(bias_1), sum(bias_2)\n",
"\n",
"print(f'cohen_kappa score for bias : {cohen_kappa(bias_1, bias_2)} and total bias\\'s according to ann_1 & ann_2 are {count_bias_1} & {count_bias_2} respectively!')\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "9ksNDUyzqc-5"
},
"source": [
"## For Missing W's Column:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "VJzuMBCcizjn",
"outputId": "b279befa-3c8d-4acb-800b-c483c3de7996"
},
"outputs": [
{
"data": {
"text/plain": [
"when,where,why 247\n",
"when,why 80\n",
"when,where 41\n",
"why 27\n",
"what,when,where,why 17\n",
"when 16\n",
"where,why 16\n",
"when,where,who,why 11\n",
"where 6\n",
"when,who,why 4\n",
"when,where,who 4\n",
"nan 3\n",
"where,who,why 3\n",
"what,when,why 3\n",
"what,why 3\n",
"when,who 2\n",
"what,when,where 2\n",
"what,where,why 2\n",
"what 1\n",
"whose,why 1\n",
"who,why 1\n",
"who 1\n",
"what,when,who,why 1\n",
"what,where,who,why 1\n",
"Name: Ann_1.3, dtype: int64"
]
},
"execution_count": 611,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_1.3'].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "oqnA5zbLizhS",
"outputId": "a9541730-a44c-4fe5-cbb5-7b42f0eb6a55"
},
"outputs": [
{
"data": {
"text/plain": [
"when,where,why 218\n",
"when,why 114\n",
"when,where 50\n",
"why 40\n",
"when 18\n",
"where,why 16\n",
"nan 8\n",
"where 5\n",
"when,where,who,why 4\n",
"what,when,why 3\n",
"what 3\n",
"when,who 3\n",
"what,when 2\n",
"what,when,where 2\n",
"when,who,why 2\n",
"where,who,why 2\n",
"who 1\n",
"what,when,where,why 1\n",
"who,why 1\n",
"Name: Ann_2.3, dtype: int64"
]
},
"execution_count": 612,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_2.3'].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "HdZKnQ7pqg7-"
},
"source": [
"### Element-wise Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "nuVIRKYXizdq",
"outputId": "c7bf60fa-e84e-4f28-e419-d6d482bedc57"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cohen_kappa score for When : 0.5453 and total when's according to ann_1 & ann_2 are 428 & 417 respectively!\n",
"cohen_kappa score for Why : 0.556 and total why's according to ann_1 & ann_2 are 417 & 401 respectively!\n",
"cohen_kappa score for Who : 0.061 and total who's according to ann_1 & ann_2 are 29 & 13 respectively!\n",
"cohen_kappa score for Where : 0.4753 and total where's according to ann_1 & ann_2 are 350 & 298 respectively!\n",
"cohen_kappa score for What : 0.0671 and total what's according to ann_1 & ann_2 are 30 & 11 respectively!\n"
]
}
],
"source": [
"ann1 = df2['Ann_1.3'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.3'].str.strip().to_list()\n",
"\n",
"# for when\n",
"when_1 = [1 if when.find('when')>-1 else 0 for when in ann1]\n",
"when_2 = [1 if when.find('when')>-1 else 0 for when in ann2]\n",
"count_when_1, count_when_2 = sum(when_1), sum(when_2)\n",
"print(f'cohen_kappa score for When : {cohen_kappa(when_1, when_2)} and total when\\'s according to ann_1 & ann_2 are {count_when_1} & {count_when_2} respectively!')\n",
"\n",
"# For why\n",
"why_1 = [1 if why.find('why')>-1 else 0 for why in ann1]\n",
"why_2 = [1 if why.find('why')>-1 else 0 for why in ann2]\n",
"count_why_1, count_why_2 = sum(why_1), sum(why_2)\n",
"\n",
"print(f'cohen_kappa score for Why : {cohen_kappa(why_1, why_2)} and total why\\'s according to ann_1 & ann_2 are {count_why_1} & {count_why_2} respectively!')\n",
"\n",
"\n",
"# For who\n",
"who_1 = [1 if who.find('who')>-1 else 0 for who in ann1]\n",
"who_2 = [1 if who.find('who')>-1 else 0 for who in ann2]\n",
"count_who_1, count_who_2 = sum(who_1), sum(who_2)\n",
"\n",
"print(f'cohen_kappa score for Who : {cohen_kappa(who_1, who_2)} and total who\\'s according to ann_1 & ann_2 are {count_who_1} & {count_who_2} respectively!')\n",
"\n",
"\n",
"# For where\n",
"where_1 = [1 if where.find('where')>-1 else 0 for where in ann1]\n",
"where_2 = [1 if where.find('where')>-1 else 0 for where in ann2]\n",
"count_where_1, count_where_2 = sum(where_1), sum(where_2)\n",
"\n",
"print(f'cohen_kappa score for Where : {cohen_kappa(where_1, where_2)} and total where\\'s according to ann_1 & ann_2 are {count_where_1} & {count_where_2} respectively!')\n",
"\n",
"\n",
"# For what\n",
"what_1 = [1 if what.find('what')>-1 else 0 for what in ann1]\n",
"what_2 = [1 if what.find('what')>-1 else 0 for what in ann2]\n",
"count_what_1, count_what_2 = sum(what_1), sum(what_2)\n",
"\n",
"print(f'cohen_kappa score for What : {cohen_kappa(what_1, what_2)} and total what\\'s according to ann_1 & ann_2 are {count_what_1} & {count_what_2} respectively!')\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "do3qpvqSqhwx"
},
"source": [
"## For Color of lie Column:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "kDNWn13wizas",
"outputId": "f6cabe7e-7d24-4462-990b-2f427c9025d3"
},
"outputs": [
{
"data": {
"text/plain": [
"grey 127\n",
"nan 118\n",
"black 115\n",
"red 77\n",
"white 56\n",
"Name: Ann_1.4, dtype: int64"
]
},
"execution_count": 614,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_1.4'].str.strip().value_counts()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "XB068WS0izYo",
"outputId": "d02e613d-e5d0-4a27-f9db-410de66a1b45"
},
"outputs": [
{
"data": {
"text/plain": [
"black 168\n",
"grey 150\n",
"nan 86\n",
"red 49\n",
"white 40\n",
"Name: Ann_2.4, dtype: int64"
]
},
"execution_count": 615,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_2.4'].str.strip().value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "YvnrVXS0qmNf"
},
"source": [
"### Overall Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "iIPP6IK2izVY",
"outputId": "514911a9-0c14-4ed4-954d-c09bc613471d"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cohen kappa score for Color of lie column: 0.5371\n"
]
}
],
"source": [
"ann1 = df2['Ann_1.4'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.4'].str.strip().to_list()\n",
"print(f'Cohen kappa score for Color of lie column: {cohen_kappa(ann1, ann2)}')"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dAwp8A_Hqo9R"
},
"source": [
"### Element Wise Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "vpnQvOBKSz4U",
"outputId": "50e54c8d-9d86-4f58-9498-3d515641ea31"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cohen_kappa score for grey : 0.5043 and total grey's according to ann_1 & ann_2 are 127 & 150 respectively!\n",
"cohen_kappa score for black : 0.438 and total black's according to ann_1 & ann_2 are 115 & 168 respectively!\n",
"cohen_kappa score for red : 0.5122 and total red's according to ann_1 & ann_2 are 77 & 49 respectively!\n",
"cohen_kappa score for white : 0.5628 and total white's according to ann_1 & ann_2 are 56 & 40 respectively!\n",
"cohen_kappa score for nan : 0.7052 and total nan's according to ann_1 & ann_2 are 118 & 86 respectively!\n"
]
}
],
"source": [
"df2['Ann_1.4'] = df2['Ann_1.4'].fillna('nan')\n",
"df2['Ann_2.4'] = df2['Ann_2.4'].fillna('nan')\n",
"\n",
"ann1 = df2['Ann_1.4'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.4'].str.strip().to_list()\n",
"\n",
"# for grey\n",
"grey_1 = [1 if color.find('grey')>-1 else 0 for color in ann1]\n",
"grey_2 = [1 if color.find('grey')>-1 else 0 for color in ann2]\n",
"count_grey_1, count_grey_2 = sum(grey_1), sum(grey_2)\n",
"print(f'cohen_kappa score for grey : {cohen_kappa(grey_1, grey_2)} and total grey\\'s according to ann_1 & ann_2 are {count_grey_1} & {count_grey_2} respectively!')\n",
"\n",
"# For black\n",
"black_1 = [1 if color.find('black')>-1 else 0 for color in ann1]\n",
"black_2 = [1 if color.find('black')>-1 else 0 for color in ann2]\n",
"count_black_1, count_black_2 = sum(black_1), sum(black_2)\n",
"\n",
"print(f'cohen_kappa score for black : {cohen_kappa(black_1, black_2)} and total black\\'s according to ann_1 & ann_2 are {count_black_1} & {count_black_2} respectively!')\n",
"\n",
"\n",
"# For red\n",
"red_1 = [1 if color.find('red')>-1 else 0 for color in ann1]\n",
"red_2 = [1 if color.find('red')>-1 else 0 for color in ann2]\n",
"count_red_1, count_red_2 = sum(red_1), sum(red_2)\n",
"\n",
"print(f'cohen_kappa score for red : {cohen_kappa(red_1, red_2)} and total red\\'s according to ann_1 & ann_2 are {count_red_1} & {count_red_2} respectively!')\n",
"\n",
"\n",
"# For white\n",
"white_1 = [1 if color.find('white')>-1 else 0 for color in ann1]\n",
"white_2 = [1 if color.find('white')>-1 else 0 for color in ann2]\n",
"count_white_1, count_white_2 = sum(white_1), sum(white_2)\n",
"\n",
"print(f'cohen_kappa score for white : {cohen_kappa(white_1, white_2)} and total white\\'s according to ann_1 & ann_2 are {count_white_1} & {count_white_2} respectively!')\n",
"\n",
"\n",
"# For null values\n",
"nan_1 = [1 if color.find('nan')>-1 else 0 for color in ann1]\n",
"nan_2 = [1 if color.find('nan')>-1 else 0 for color in ann2]\n",
"count_nan_1, count_nan_2 = sum(nan_1), sum(nan_2)\n",
"\n",
"print(f'cohen_kappa score for nan : {cohen_kappa(nan_1, nan_2)} and total nan\\'s according to ann_1 & ann_2 are {count_nan_1} & {count_nan_2} respectively!')\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "vwNdgAhjqlj5"
},
"source": [
"## For Intent of Lie Column:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "sZMRUcomizSO",
"outputId": "3a2459e3-c6ed-4754-af26-153e03823b0e"
},
"outputs": [
{
"data": {
"text/plain": [
"gaining advantage 156\n",
"nan 136\n",
"protecting themselves 66\n",
"gaining esteem 65\n",
"protecting others 53\n",
"avoiding embarrassment 9\n",
"defaming esteem 8\n",
"Name: Ann_1.6, dtype: int64"
]
},
"execution_count": 618,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_1.6'].str.strip().value_counts()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "rI57NwXZizOv",
"outputId": "416e01f1-292d-4555-c4eb-98d76d82bcec"
},
"outputs": [
{
"data": {
"text/plain": [
"gaining advantage 188\n",
"nan 104\n",
"gaining esteem 79\n",
"protecting themselves 64\n",
"protecting others 29\n",
"avoiding embarrassment 16\n",
"defaming esteem 13\n",
"Name: Ann_2.6, dtype: int64"
]
},
"execution_count": 619,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_2.6'].str.strip().value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "rcv3bJoSqspW"
},
"source": [
"### Overall Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "FNMMZNkbizLv",
"outputId": "8907ab3e-9cf8-4656-8463-070858b2fa89"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cohen kappa score for Intent of lie column: 0.4846\n"
]
}
],
"source": [
"ann1 = df2['Ann_1.6'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.6'].str.strip().to_list()\n",
"print(f'Cohen kappa score for Intent of lie column: {cohen_kappa(ann1, ann2)}')"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "eL7pKSsNqupD"
},
"source": [
"### Element Wise Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "RwmBoEwRiMWv",
"outputId": "ae5c0b0b-15a7-4242-fe75-8e6f19ac685e"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cohen_kappa score gaining advantage : 0.4312 and total gaining advantage's according to ann_1 & ann_2 are 156 & 188 respectively!\n",
"cohen_kappa score for gaining_esteem : 0.4966 and total gaining_esteem's according to ann_1 & ann_2 are 65 & 79 respectively!\n",
"cohen_kappa score for protecting_themsprotecting_others : 0.557 and total protecting_themselves's according to ann_1 & ann_2 are 66 & 64 respectively!\n",
"cohen_kappa score for protecting_others : 0.3401 and total protecting_others's according to ann_1 & ann_2 are 53 & 29 respectively!\n",
"cohen_kappa score for avoiding_embarrassment : 0.6314 and total avoiding_embarrassment's according to ann_1 & ann_2 are 9 & 16 respectively!\n",
"cohen_kappa score for defaming_esteem : 0.2711 and total defaming_esteem's according to ann_1 & ann_2 are 8 & 13 respectively!\n",
"cohen_kappa score for nan : 0.5619 and total nan's according to ann_1 & ann_2 are 136 & 104 respectively!\n"
]
}
],
"source": [
"df2['Ann_1.6'] = df2['Ann_1.6'].fillna('nan')\n",
"df2['Ann_2.6'] = df2['Ann_2.6'].fillna('nan')\n",
"\n",
"ann1 = df2['Ann_1.6'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.6'].str.strip().to_list()\n",
"\n",
"# for gaining advantage\n",
"gaining_advantage_1 = [1 if color.find('gaining advantage')>-1 else 0 for color in ann1]\n",
"gaining_advantage_2 = [1 if color.find('gaining advantage')>-1 else 0 for color in ann2]\n",
"count_gaining_advantage_1, count_gaining_advantage_2 = sum(gaining_advantage_1), sum(gaining_advantage_2)\n",
"print(f'cohen_kappa score gaining advantage : {cohen_kappa(gaining_advantage_1, gaining_advantage_2)} and total gaining advantage\\'s according to ann_1 & ann_2 are {count_gaining_advantage_1} & {count_gaining_advantage_2} respectively!')\n",
"\n",
"# For gaining_esteem\n",
"gaining_esteem_1 = [1 if color.find('gaining esteem')>-1 else 0 for color in ann1]\n",
"gaining_esteem_2 = [1 if color.find('gaining esteem')>-1 else 0 for color in ann2]\n",
"count_gaining_esteem_1, count_gaining_esteem_2 = sum(gaining_esteem_1), sum(gaining_esteem_2)\n",
"\n",
"print(f'cohen_kappa score for gaining_esteem : {cohen_kappa(gaining_esteem_1, gaining_esteem_2)} and total gaining_esteem\\'s according to ann_1 & ann_2 are {count_gaining_esteem_1} & {count_gaining_esteem_2} respectively!')\n",
"\n",
"\n",
"# For protecting_themselves\n",
"protecting_themselves_1 = [1 if color.find('protecting themselves')>-1 else 0 for color in ann1]\n",
"protecting_themselves_2 = [1 if color.find('protecting themselves')>-1 else 0 for color in ann2]\n",
"count_protecting_themselves_1, count_protecting_themselves_2 = sum(protecting_themselves_1), sum(protecting_themselves_2)\n",
"\n",
"print(f'cohen_kappa score for protecting_themselves : {cohen_kappa(protecting_themselves_1, protecting_themselves_2)} and total protecting_themselves\\'s according to ann_1 & ann_2 are {count_protecting_themselves_1} & {count_protecting_themselves_2} respectively!')\n",
"\n",
"\n",
"# For protecting_others\n",
"protecting_others_1 = [1 if color.find('protecting others')>-1 else 0 for color in ann1]\n",
"protecting_others_2 = [1 if color.find('protecting others')>-1 else 0 for color in ann2]\n",
"count_protecting_others_1, count_protecting_others_2 = sum(protecting_others_1), sum(protecting_others_2)\n",
"\n",
"print(f'cohen_kappa score for protecting_others : {cohen_kappa(protecting_others_1, protecting_others_2)} and total protecting_others\\'s according to ann_1 & ann_2 are {count_protecting_others_1} & {count_protecting_others_2} respectively!')\n",
"\n",
"\n",
"# For voiding_embarrassment \n",
"avoiding_embarrassment_1 = [1 if color.find('avoiding embarrassment')>-1 else 0 for color in ann1]\n",
"avoiding_embarrassment_2 = [1 if color.find('avoiding embarrassment')>-1 else 0 for color in ann2]\n",
"count_avoiding_embarrassment_1, count_avoiding_embarrassment_2 = sum(avoiding_embarrassment_1), sum(avoiding_embarrassment_2)\n",
"\n",
"print(f'cohen_kappa score for avoiding_embarrassment : {cohen_kappa(avoiding_embarrassment_1, avoiding_embarrassment_2)} and total avoiding_embarrassment\\'s according to ann_1 & ann_2 are {count_avoiding_embarrassment_1} & {count_avoiding_embarrassment_2} respectively!')\n",
"\n",
"\n",
"# For defaming esteem\n",
"defaming_esteem_1 = [1 if color.find('defaming esteem')>-1 else 0 for color in ann1]\n",
"defaming_esteem_2 = [1 if color.find('defaming esteem')>-1 else 0 for color in ann2]\n",
"count_defaming_esteem_1, count_defaming_esteem_2 = sum(defaming_esteem_1), sum(defaming_esteem_2)\n",
"\n",
"print(f'cohen_kappa score for defaming_esteem : {cohen_kappa(defaming_esteem_1, defaming_esteem_2)} and total defaming_esteem\\'s according to ann_1 & ann_2 are {count_defaming_esteem_1} & {count_defaming_esteem_2} respectively!')\n",
"\n",
"\n",
"# For null values\n",
"nan_1 = [1 if color.find('nan')>-1 else 0 for color in ann1]\n",
"nan_2 = [1 if color.find('nan')>-1 else 0 for color in ann2]\n",
"count_nan_1, count_nan_2 = sum(nan_1), sum(nan_2)\n",
"\n",
"print(f'cohen_kappa score for nan : {cohen_kappa(nan_1, nan_2)} and total nan\\'s according to ann_1 & ann_2 are {count_nan_1} & {count_nan_2} respectively!')\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "kxGkBjo5qo-9"
},
"source": [
"## For category of lie Column:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "lr46SsDSizI0",
"outputId": "e52b93c0-77aa-4a06-b118-5fc9903c996a"
},
"outputs": [
{
"data": {
"text/plain": [
"political 281\n",
"educational 102\n",
"nan 47\n",
"ethnicity 20\n",
"religious 18\n",
"racial 18\n",
"other 7\n",
"Name: Ann_1.7, dtype: int64"
]
},
"execution_count": 622,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_1.7'].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "C0RRl0TfizFk",
"outputId": "10e4c3bf-182a-4c40-87fa-ce4abf3a1bfc"
},
"outputs": [
{
"data": {
"text/plain": [
"political 293\n",
"educational 81\n",
"nan 45\n",
"ethnicity 41\n",
"religious 17\n",
"other 8\n",
"racial 8\n",
"Name: Ann_2.7, dtype: int64"
]
},
"execution_count": 623,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_2.7'].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ij4K7XrxqzEY"
},
"source": [
"### Overall Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "eArT7b3hizCd",
"outputId": "883b8c7b-a275-4609-aeb7-9a2dd6f93ce0"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cohen kappa score for Final column: 0.7089\n"
]
}
],
"source": [
"ann1 = df2['Ann_1.7'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.7'].str.strip().to_list()\n",
"print(f'Cohen kappa score for Final column: {cohen_kappa(ann1, ann2)}')"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "m8805L-Jq2Ng"
},
"source": [
"### Element Wise Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "RS9tkWl1kbPO",
"outputId": "917e6408-6861-4764-b288-de17c77e3763"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cohen_kappa score political : 0.7417 and total political's according to ann_1 & ann_2 are 281 & 293 respectively!\n",
"cohen_kappa score for educational : 0.7257 and total educational's according to ann_1 & ann_2 are 102 & 81 respectively!\n",
"cohen_kappa score for ethnicity : 0.5665 and total ethnicity's according to ann_1 & ann_2 are 20 & 41 respectively!\n",
"cohen_kappa score for religious : 0.6149 and total religious's according to ann_1 & ann_2 are 18 & 17 respectively!\n",
"cohen_kappa score for racial : 0.4492 and total racial's according to ann_1 & ann_2 are 18 & 8 respectively!\n",
"cohen_kappa score for other : 0.2554 and total other's according to ann_1 & ann_2 are 7 & 8 respectively!\n",
"cohen_kappa score for nan : 0.8801 and total nan's according to ann_1 & ann_2 are 47 & 45 respectively!\n"
]
}
],
"source": [
"df2['Ann_1.7'] = df2['Ann_1.7'].fillna('nan')\n",
"df2['Ann_2.7'] = df2['Ann_2.7'].fillna('nan')\n",
"\n",
"ann1 = df2['Ann_1.7'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.7'].str.strip().to_list()\n",
"\n",
"# for political\n",
"political_1 = [1 if color.find('political')>-1 else 0 for color in ann1]\n",
"political_2 = [1 if color.find('political')>-1 else 0 for color in ann2]\n",
"count_political_1, count_political_2 = sum(political_1), sum(political_2)\n",
"print(f'cohen_kappa score political : {cohen_kappa(political_1, political_2)} and total political\\'s according to ann_1 & ann_2 are {count_political_1} & {count_political_2} respectively!')\n",
"\n",
"\n",
"# For educational\n",
"educational_1 = [1 if color.find('educational')>-1 else 0 for color in ann1]\n",
"educational_2 = [1 if color.find('educational')>-1 else 0 for color in ann2]\n",
"count_educational_1, count_educational_2 = sum(educational_1), sum(educational_2)\n",
"\n",
"print(f'cohen_kappa score for educational : {cohen_kappa(educational_1, educational_2)} and total educational\\'s according to ann_1 & ann_2 are {count_educational_1} & {count_educational_2} respectively!')\n",
"\n",
"\n",
"# For ethnicity\n",
"ethnicity_1 = [1 if color.find('ethnicity')>-1 else 0 for color in ann1]\n",
"ethnicity_2 = [1 if color.find('ethnicity')>-1 else 0 for color in ann2]\n",
"count_ethnicity_1, count_ethnicity_2 = sum(ethnicity_1), sum(ethnicity_2)\n",
"\n",
"print(f'cohen_kappa score for ethnicity : {cohen_kappa(ethnicity_1, ethnicity_2)} and total ethnicity\\'s according to ann_1 & ann_2 are {count_ethnicity_1} & {count_ethnicity_2} respectively!')\n",
"\n",
"\n",
"# For religious\n",
"religious_1 = [1 if color.find('religious')>-1 else 0 for color in ann1]\n",
"religious_2 = [1 if color.find('religious')>-1 else 0 for color in ann2]\n",
"count_religious_1, count_religious_2 = sum(religious_1), sum(religious_2)\n",
"\n",
"print(f'cohen_kappa score for religious : {cohen_kappa(religious_1, religious_2)} and total religious\\'s according to ann_1 & ann_2 are {count_religious_1} & {count_religious_2} respectively!')\n",
"\n",
"\n",
"# For racial \n",
"racial_1 = [1 if color.find('racial')>-1 else 0 for color in ann1]\n",
"racial_2 = [1 if color.find('racial')>-1 else 0 for color in ann2]\n",
"count_racial_1, count_racial_2 = sum(racial_1), sum(racial_2)\n",
"\n",
"print(f'cohen_kappa score for racial : {cohen_kappa(racial_1, racial_2)} and total racial\\'s according to ann_1 & ann_2 are {count_racial_1} & {count_racial_2} respectively!')\n",
"\n",
"\n",
"# For defaming other\n",
"other_1 = [1 if color.find('other')>-1 else 0 for color in ann1]\n",
"other_2 = [1 if color.find('other')>-1 else 0 for color in ann2]\n",
"count_other_1, count_other_2 = sum(other_1), sum(other_2)\n",
"\n",
"print(f'cohen_kappa score for other : {cohen_kappa(other_1, other_2)} and total other\\'s according to ann_1 & ann_2 are {count_other_1} & {count_other_2} respectively!')\n",
"\n",
"\n",
"# For null values\n",
"nan_1 = [1 if color.find('nan')>-1 else 0 for color in ann1]\n",
"nan_2 = [1 if color.find('nan')>-1 else 0 for color in ann2]\n",
"count_nan_1, count_nan_2 = sum(nan_1), sum(nan_2)\n",
"\n",
"print(f'cohen_kappa score for nan : {cohen_kappa(nan_1, nan_2)} and total nan\\'s according to ann_1 & ann_2 are {count_nan_1} & {count_nan_2} respectively!')\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "adLYMydvdJzf"
},
"source": [
"# Overlapping Fake News Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-12-06T20:07:39.395133Z",
"iopub.status.busy": "2022-12-06T20:07:39.393430Z",
"iopub.status.idle": "2022-12-06T20:07:39.402869Z",
"shell.execute_reply": "2022-12-06T20:07:39.401612Z",
"shell.execute_reply.started": "2022-12-06T20:07:39.395087Z"
},
"id": "eQPx_gEqUc9X",
"trusted": true
},
"outputs": [],
"source": [
"df = pd.read_csv(\"<Link to Fake News overlap data.csv>\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 739
},
"execution": {
"iopub.execute_input": "2022-12-06T20:07:39.405036Z",
"iopub.status.busy": "2022-12-06T20:07:39.404216Z",
"iopub.status.idle": "2022-12-06T20:07:39.420289Z",
"shell.execute_reply": "2022-12-06T20:07:39.418877Z",
"shell.execute_reply.started": "2022-12-06T20:07:39.405007Z"
},
"id": "jK7RTh6mUhWT",
"outputId": "68649967-f665-4beb-d6db-1ff1942a3a7d",
"trusted": true
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <div id=\"df-86223447-a4f7-4030-875a-8f78ec1b5225\">\n",
" <div class=\"colab-df-container\">\n",
" <div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>S_1</th>\n",
" <th>Ann_1.1</th>\n",
" <th>Ann_1.2</th>\n",
" <th>Ann_1.3</th>\n",
" <th>Ann_1.4</th>\n",
" <th>Ann_1.5</th>\n",
" <th>Ann_1.6</th>\n",
" <th>Ann_1.7</th>\n",
" <th>S_2</th>\n",
" <th>Ann_2.1</th>\n",
" <th>Ann_2.2</th>\n",
" <th>Ann_2.3</th>\n",
" <th>Ann_2.4</th>\n",
" <th>Ann_2.5</th>\n",
" <th>Ann_2.6</th>\n",
" <th>Ann_2.7</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>President Trump Travels to Orlando for Private...</td>\n",
" <td>Speculation</td>\n",
" <td>We have no proof if it is true or not</td>\n",
" <td>When,Why</td>\n",
" <td>Black</td>\n",
" <td>To defame Trump</td>\n",
" <td>Gaining Advantage</td>\n",
" <td>Political</td>\n",
" <td>President Trump Travels to Orlando for Private...</td>\n",
" <td>Speculation</td>\n",
" <td>Reason For Visting The Svhool Is Not Mentioned.</td>\n",
" <td>When,Why</td>\n",
" <td>Red</td>\n",
" <td>To Show Trump That He Does'T Care About The Pu...</td>\n",
" <td>Gaining Advantage</td>\n",
" <td>Political</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>VP MIKE PENCE Stops For BBQ Before Super Bowl…...</td>\n",
" <td>Speculation</td>\n",
" <td>We have no proof if it is true or not</td>\n",
" <td>When,Why</td>\n",
" <td>Black</td>\n",
" <td>To defame Mike</td>\n",
" <td>Gaining Advantage</td>\n",
" <td>Ethnicity</td>\n",
" <td>VP MIKE PENCE Stops For BBQ Before Super Bowl…...</td>\n",
" <td>Speculation</td>\n",
" <td>No Evidence Given Why He Had Stoppped At Bbq B...</td>\n",
" <td>When,Why</td>\n",
" <td>Black</td>\n",
" <td>To Show Mike Pence Doesn'T Gives Importance To...</td>\n",
" <td>Avoiding Embarrassment</td>\n",
" <td>Ethnicity</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>More Networks Join in the Boycott of New Trump Ad</td>\n",
" <td>Sounds Factual</td>\n",
" <td>NaN</td>\n",
" <td>When</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Political</td>\n",
" <td>More Networks Join in the Boycott of New Trump Ad</td>\n",
" <td>Sounds Factual</td>\n",
" <td>NaN</td>\n",
" <td>When</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Political</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Julian Assange – “Everything that he has said/...</td>\n",
" <td>Opinion</td>\n",
" <td>The Statement Happens To Be An Opinion By Assa...</td>\n",
" <td>Who</td>\n",
" <td>Black</td>\n",
" <td>The lie might be told to ramp up the Political...</td>\n",
" <td>Gaining Advantage</td>\n",
" <td>Political</td>\n",
" <td>Julian Assange – “Everything that he has said/...</td>\n",
" <td>Opinion</td>\n",
" <td>It Is Just A Opinion By A Person On Someone.</td>\n",
" <td>When,Why</td>\n",
" <td>White</td>\n",
" <td>A Lie Said To Protect Someone And Can Be Under...</td>\n",
" <td>Protecting Themselves</td>\n",
" <td>Political</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Without Evidence/Trump Launches 59 Cruise Miss...</td>\n",
" <td>Speculation</td>\n",
" <td>We have no proof if it is true or not</td>\n",
" <td>When,Why</td>\n",
" <td>Black</td>\n",
" <td>It could be said to defame Trump and create panic</td>\n",
" <td>Protecting Themselves</td>\n",
" <td>Political</td>\n",
" <td>Without Evidence/Trump Launches 59 Cruise Miss...</td>\n",
" <td>Speculation</td>\n",
" <td>No Evidence Given Why He Had Launched</td>\n",
" <td>When,Why</td>\n",
" <td>Red</td>\n",
" <td>Can Be Said Out Of Spite Of Rivalry Between Us...</td>\n",
" <td>Protecting Themselves</td>\n",
" <td>Political</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>\n",
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-86223447-a4f7-4030-875a-8f78ec1b5225')\"\n",
" title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
" \n",
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
" width=\"24px\">\n",
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
" </svg>\n",
" </button>\n",
" \n",
" <style>\n",
" .colab-df-container {\n",
" display:flex;\n",
" flex-wrap:wrap;\n",
" gap: 12px;\n",
" }\n",
"\n",
" .colab-df-convert {\n",
" background-color: #E8F0FE;\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: #1967D2;\n",
" height: 32px;\n",
" padding: 0 0 0 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-convert:hover {\n",
" background-color: #E2EBFA;\n",
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: #174EA6;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert {\n",
" background-color: #3B4455;\n",
" fill: #D2E3FC;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert:hover {\n",
" background-color: #434B5C;\n",
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
" fill: #FFFFFF;\n",
" }\n",
" </style>\n",
"\n",
" <script>\n",
" const buttonEl =\n",
" document.querySelector('#df-86223447-a4f7-4030-875a-8f78ec1b5225 button.colab-df-convert');\n",
" buttonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
"\n",
" async function convertToInteractive(key) {\n",
" const element = document.querySelector('#df-86223447-a4f7-4030-875a-8f78ec1b5225');\n",
" const dataTable =\n",
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
" [key], {});\n",
" if (!dataTable) return;\n",
"\n",
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
" + ' to learn more about interactive tables.';\n",
" element.innerHTML = '';\n",
" dataTable['output_type'] = 'display_data';\n",
" await google.colab.output.renderOutput(dataTable, element);\n",
" const docLink = document.createElement('div');\n",
" docLink.innerHTML = docLinkHtml;\n",
" element.appendChild(docLink);\n",
" }\n",
" </script>\n",
" </div>\n",
" </div>\n",
" "
],
"text/plain": [
" S_1 Ann_1.1 \\\n",
"0 President Trump Travels to Orlando for Private... Speculation \n",
"1 VP MIKE PENCE Stops For BBQ Before Super Bowl…... Speculation \n",
"2 More Networks Join in the Boycott of New Trump Ad Sounds Factual \n",
"3 Julian Assange – “Everything that he has said/... Opinion \n",
"4 Without Evidence/Trump Launches 59 Cruise Miss... Speculation \n",
"\n",
" Ann_1.2 Ann_1.3 Ann_1.4 \\\n",
"0 We have no proof if it is true or not When,Why Black \n",
"1 We have no proof if it is true or not When,Why Black \n",
"2 NaN When NaN \n",
"3 The Statement Happens To Be An Opinion By Assa... Who Black \n",
"4 We have no proof if it is true or not When,Why Black \n",
"\n",
" Ann_1.5 Ann_1.6 \\\n",
"0 To defame Trump Gaining Advantage \n",
"1 To defame Mike Gaining Advantage \n",
"2 NaN NaN \n",
"3 The lie might be told to ramp up the Political... Gaining Advantage \n",
"4 It could be said to defame Trump and create panic Protecting Themselves \n",
"\n",
" Ann_1.7 S_2 \\\n",
"0 Political President Trump Travels to Orlando for Private... \n",
"1 Ethnicity VP MIKE PENCE Stops For BBQ Before Super Bowl…... \n",
"2 Political More Networks Join in the Boycott of New Trump Ad \n",
"3 Political Julian Assange – “Everything that he has said/... \n",
"4 Political Without Evidence/Trump Launches 59 Cruise Miss... \n",
"\n",
" Ann_2.1 Ann_2.2 \\\n",
"0 Speculation Reason For Visting The Svhool Is Not Mentioned. \n",
"1 Speculation No Evidence Given Why He Had Stoppped At Bbq B... \n",
"2 Sounds Factual NaN \n",
"3 Opinion It Is Just A Opinion By A Person On Someone. \n",
"4 Speculation No Evidence Given Why He Had Launched \n",
"\n",
" Ann_2.3 Ann_2.4 Ann_2.5 \\\n",
"0 When,Why Red To Show Trump That He Does'T Care About The Pu... \n",
"1 When,Why Black To Show Mike Pence Doesn'T Gives Importance To... \n",
"2 When NaN NaN \n",
"3 When,Why White A Lie Said To Protect Someone And Can Be Under... \n",
"4 When,Why Red Can Be Said Out Of Spite Of Rivalry Between Us... \n",
"\n",
" Ann_2.6 Ann_2.7 \n",
"0 Gaining Advantage Political \n",
"1 Avoiding Embarrassment Ethnicity \n",
"2 NaN Political \n",
"3 Protecting Themselves Political \n",
"4 Protecting Themselves Political "
]
},
"execution_count": 627,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-12-06T20:07:39.423451Z",
"iopub.status.busy": "2022-12-06T20:07:39.422530Z",
"iopub.status.idle": "2022-12-06T20:07:39.436062Z",
"shell.execute_reply": "2022-12-06T20:07:39.433920Z",
"shell.execute_reply.started": "2022-12-06T20:07:39.423407Z"
},
"id": "BjWn56wcUjU9",
"trusted": true
},
"outputs": [],
"source": [
"#convert ann_1 and ann_2 into small letter\n",
"df2 = df.apply(lambda x: x.astype(str).str.lower())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-12-06T20:07:39.460738Z",
"iopub.status.busy": "2022-12-06T20:07:39.460391Z",
"iopub.status.idle": "2022-12-06T20:07:39.476545Z",
"shell.execute_reply": "2022-12-06T20:07:39.474667Z",
"shell.execute_reply.started": "2022-12-06T20:07:39.460708Z"
},
"id": "t1dUfuXRU7wR",
"trusted": true
},
"outputs": [],
"source": [
"def cohen_kappa(ann1, ann2):\n",
" \"\"\"Computes Cohen kappa for pair-wise annotators.\n",
" :param ann1: annotations provided by first annotator\n",
" :type ann1: list\n",
" :param ann2: annotations provided by second annotator\n",
" :type ann2: list\n",
" :rtype: float\n",
" :return: Cohen kappa statistic\n",
" \"\"\"\n",
" count = 0\n",
" for an1, an2 in zip(ann1, ann2):\n",
" if an1 == an2:\n",
" count += 1\n",
" # print(count, len(ann1))\n",
" A = count / len(ann1) # observed agreement A (Po)\n",
"\n",
" uniq = set(ann1 + ann2)\n",
" # print(uniq)\n",
" E = 0 # expected agreement E (Pe)\n",
" for item in uniq:\n",
" cnt1 = ann1.count(item)\n",
" cnt2 = ann2.count(item)\n",
" count = ((cnt1 / len(ann1)) * (cnt2 / len(ann2)))\n",
" E += count\n",
" # print(A, E)\n",
" return round((A - E) / (1 - E), 4)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "SaizLrBImtrS"
},
"source": [
"### For SBDO column"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Z1SD22F-b4To",
"outputId": "b7339cc6-06d6-4e16-bd5e-0bff62f0d734"
},
"outputs": [
{
"data": {
"text/plain": [
"speculation 294\n",
"opinion 76\n",
"distortion 31\n",
"sounds factual 16\n",
"bias 15\n",
"speculation,sounds factual 2\n",
"Name: Ann_1.1, dtype: int64"
]
},
"execution_count": 632,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_1.1'].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "7PAKecp7b-T7",
"outputId": "c7536851-1800-4866-a25d-3c01c6b254cb"
},
"outputs": [
{
"data": {
"text/plain": [
"speculation 283\n",
"opinion 76\n",
"distortion 33\n",
"sounds factual 23\n",
"bias 19\n",
"Name: Ann_2.1, dtype: int64"
]
},
"execution_count": 633,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_2.1'].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "hcnIIPdWq-es"
},
"source": [
"### Overall Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "VCvquGGFcaxH",
"outputId": "deedd8ac-9175-4589-8a89-8a6b67b294d3"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cohen kappa score for SBDOSF column: 0.6668\n"
]
}
],
"source": [
"ann1 = df2['Ann_1.1'].to_list()\n",
"ann2 = df2['Ann_2.1'].to_list()\n",
"print(f'Cohen kappa score for SBDOSF column: {cohen_kappa(ann1, ann2)}')"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "BiiGtisfrBJE"
},
"source": [
"### Element Wise Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "yGtnoW31mxrH",
"outputId": "6649432b-8ea5-42b8-da9f-de279bf9b35b"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cohen_kappa score for When : 0.6839 and total when's according to ann_1 & ann_2 are 296 & 283 respectively!\n",
"cohen_kappa score for sounds factual : 0.4628 and total sounds factual's according to ann_1 & ann_2 are 18 & 23 respectively!\n",
"cohen_kappa score for opinion : 0.7288 and total opinion's according to ann_1 & ann_2 are 76 & 76 respectively!\n",
"cohen_kappa score for distortion : 0.6964 and total distortion's according to ann_1 & ann_2 are 31 & 33 respectively!\n",
"cohen_kappa score for bias : 0.5717 and total bias's according to ann_1 & ann_2 are 15 & 19 respectively!\n"
]
}
],
"source": [
"ann1 = df2['Ann_1.1'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.1'].str.strip().to_list()\n",
"\n",
"# for speculation\n",
"speculation_1 = [1 if when.find('speculation')>-1 else 0 for when in ann1]\n",
"speculation_2 = [1 if when.find('speculation')>-1 else 0 for when in ann2]\n",
"count_speculation_1, count_speculation_2 = sum(speculation_1), sum(speculation_2)\n",
"print(f'cohen_kappa score for When : {cohen_kappa(speculation_1, speculation_2)} and total when\\'s according to ann_1 & ann_2 are {count_speculation_1} & {count_speculation_2} respectively!')\n",
"\n",
"# For sounds factual\n",
"sounds_factual_1 = [1 if why.find('sounds factual')>-1 else 0 for why in ann1]\n",
"sounds_factual_2 = [1 if why.find('sounds factual')>-1 else 0 for why in ann2]\n",
"count_sounds_factual_1, count_sounds_factual_2 = sum(sounds_factual_1), sum(sounds_factual_2)\n",
"\n",
"print(f'cohen_kappa score for sounds factual : {cohen_kappa(sounds_factual_1, sounds_factual_2)} and total sounds factual\\'s according to ann_1 & ann_2 are {count_sounds_factual_1} & {count_sounds_factual_2} respectively!')\n",
"\n",
"\n",
"# For opinion\n",
"opinion_1 = [1 if who.find('opinion')>-1 else 0 for who in ann1]\n",
"opinion_2 = [1 if who.find('opinion')>-1 else 0 for who in ann2]\n",
"count_opinion_1, count_opinion_2 = sum(opinion_1), sum(opinion_2)\n",
"\n",
"print(f'cohen_kappa score for opinion : {cohen_kappa(opinion_1, opinion_2)} and total opinion\\'s according to ann_1 & ann_2 are {count_opinion_1} & {count_opinion_2} respectively!')\n",
"\n",
"\n",
"# For distortion\n",
"distortion_1 = [1 if where.find('distortion')>-1 else 0 for where in ann1]\n",
"distortion_2 = [1 if where.find('distortion')>-1 else 0 for where in ann2]\n",
"count_distortion_1, count_distortion_2 = sum(distortion_1), sum(distortion_2)\n",
"\n",
"print(f'cohen_kappa score for distortion : {cohen_kappa(distortion_1, distortion_2)} and total distortion\\'s according to ann_1 & ann_2 are {count_distortion_1} & {count_distortion_2} respectively!')\n",
"\n",
"\n",
"# For bias\n",
"bias_1 = [1 if what.find('bias')>-1 else 0 for what in ann1]\n",
"bias_2 = [1 if what.find('bias')>-1 else 0 for what in ann2]\n",
"count_bias_1, count_bias_2 = sum(bias_1), sum(bias_2)\n",
"\n",
"print(f'cohen_kappa score for bias : {cohen_kappa(bias_1, bias_2)} and total bias\\'s according to ann_1 & ann_2 are {count_bias_1} & {count_bias_2} respectively!')\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dYFvLBnGm0Vj"
},
"source": [
"### Missing W's column"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "yOTmeXTqNis1",
"outputId": "350ad1e5-b338-4259-ea59-877eca4aefcd"
},
"outputs": [
{
"data": {
"text/plain": [
"when,where,why 250\n",
"when,where 71\n",
"when,why 28\n",
"when 20\n",
"when,where,who,why 17\n",
"why 9\n",
"what,when,where,why 5\n",
"what,where,why 5\n",
"what,why 4\n",
"what,when,why 3\n",
"where 3\n",
"where,why 3\n",
"when,where,who 3\n",
"where,who,why 2\n",
"what 2\n",
"nan 2\n",
"who 2\n",
"what,who,why 1\n",
"what,when,who,why 1\n",
"what,when,where 1\n",
"what,when,where,who 1\n",
"when,who 1\n",
"Name: Ann_1.3, dtype: int64"
]
},
"execution_count": 636,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_1.3'].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "6UzcIps07QYh",
"outputId": "0fdb3b05-03ae-40d0-a80e-a4471fb7f8c8"
},
"outputs": [
{
"data": {
"text/plain": [
"when,where,why 219\n",
"when,where 67\n",
"when,why 42\n",
"where,why 15\n",
"when,where,who,why 14\n",
"when 14\n",
"what,when 10\n",
"why,when 8\n",
"why 7\n",
"what,why 5\n",
"what,when,why 5\n",
"what 4\n",
"nan 4\n",
"when,who,why 4\n",
"when,where,who 3\n",
"what,when,where 3\n",
"where 3\n",
"why,when,where 2\n",
"what,when,where,why 1\n",
"what,who 1\n",
"what,when,who 1\n",
"when,who 1\n",
"what,where,why 1\n",
"Name: Ann_2.3, dtype: int64"
]
},
"execution_count": 637,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_2.3'].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nORd8nG5rC8m"
},
"source": [
"### Element Wise Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "QEGT9jID9qpn",
"outputId": "dbc7d6a1-58a8-4a75-d503-384280909534"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1]\n",
"[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"cohen_kappa score for When : 0.1781 and total when's according to ann_1 & ann_2 are 401 & 394 respectively!\n",
"cohen_kappa score for Why : 0.6253 and total why's according to ann_1 & ann_2 are 328 & 323 respectively!\n",
"cohen_kappa score for Who : -0.0224 and total who's according to ann_1 & ann_2 are 28 & 24 respectively!\n",
"cohen_kappa score for Where : 0.4768 and total where's according to ann_1 & ann_2 are 361 & 394 respectively!\n",
"cohen_kappa score for What : 0.0141 and total what's according to ann_1 & ann_2 are 23 & 31 respectively!\n"
]
}
],
"source": [
"ann1 = df2['Ann_1.3'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.3'].str.strip().to_list()\n",
"\n",
"# for when\n",
"when_1 = [1 if when.find('when') != -1 else 0 for when in ann1]\n",
"when_2 = [1 if when.find('when') != -1 else 0 for when in ann2]\n",
"print(when_1, when_2, sep = '\\n')\n",
"count_when_1, count_when_2 = sum(when_1), sum(when_2)\n",
"print(f'cohen_kappa score for When : {cohen_kappa(when_1, when_2)} and total when\\'s according to ann_1 & ann_2 are {count_when_1} & {count_when_2} respectively!')\n",
"\n",
"# For why\n",
"why_1 = [1 if why.find('why')>-1 else 0 for why in ann1]\n",
"why_2 = [1 if why.find('why')>-1 else 0 for why in ann2]\n",
"count_why_1, count_why_2 = sum(why_1), sum(why_2)\n",
"\n",
"print(f'cohen_kappa score for Why : {cohen_kappa(why_1, why_2)} and total why\\'s according to ann_1 & ann_2 are {count_why_1} & {count_why_2} respectively!')\n",
"\n",
"\n",
"# For who\n",
"who_1 = [1 if who.find('who')>-1 else 0 for who in ann1]\n",
"who_2 = [1 if who.find('who')>-1 else 0 for who in ann2]\n",
"count_who_1, count_who_2 = sum(who_1), sum(who_2)\n",
"\n",
"print(f'cohen_kappa score for Who : {cohen_kappa(who_1, who_2)} and total who\\'s according to ann_1 & ann_2 are {count_who_1} & {count_who_2} respectively!')\n",
"\n",
"\n",
"# For where\n",
"where_1 = [1 if where.find('where')>-1 else 0 for where in ann1]\n",
"where_2 = [1 if where.find('where')>-1 else 0 for where in ann2]\n",
"count_where_1, count_where_2 = sum(where_1), sum(where_2)\n",
"\n",
"print(f'cohen_kappa score for Where : {cohen_kappa(where_1, where_2)} and total where\\'s according to ann_1 & ann_2 are {count_where_1} & {count_when_2} respectively!')\n",
"\n",
"\n",
"# For what\n",
"what_1 = [1 if what.find('what')>-1 else 0 for what in ann1]\n",
"what_2 = [1 if what.find('what')>-1 else 0 for what in ann2]\n",
"count_what_1, count_what_2 = sum(what_1), sum(what_2)\n",
"\n",
"print(f'cohen_kappa score for What : {cohen_kappa(what_1, what_2)} and total what\\'s according to ann_1 & ann_2 are {count_what_1} & {count_what_2} respectively!')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ReBYogmtpGtc"
},
"outputs": [],
"source": [
"# Sanity Check using Sklearn's implementation of Cohen Kappa Scores\n",
"from sklearn.metrics import cohen_kappa_score\n",
"cohen_kappa_score(when_1, when_2), cohen_kappa_score(why_1, why_2), cohen_kappa_score(what_1, what_2), cohen_kappa_score(where_1, where_2), cohen_kappa_score(who_1, who_2)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "IjWo98Luq3Gq"
},
"source": [
"## For color of lie column"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "zFp0zHWSdX1a",
"outputId": "3a9a7d51-c38e-45d3-d838-330a78714f35"
},
"outputs": [
{
"data": {
"text/plain": [
"black 281\n",
"grey 73\n",
"red 32\n",
"white 30\n",
"nan 18\n",
"Name: Ann_1.4, dtype: int64"
]
},
"execution_count": 640,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_1.4'].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "yjSwlzqXddYH",
"outputId": "239fae53-2b72-4ed9-bf46-1a02bbc97385"
},
"outputs": [
{
"data": {
"text/plain": [
"black 253\n",
"grey 90\n",
"white 44\n",
"red 24\n",
"nan 23\n",
"Name: Ann_2.4, dtype: int64"
]
},
"execution_count": 641,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_2.4'].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "hbXO9IsfrNCU"
},
"source": [
"### Overall Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "w8pCnUT7dAqR",
"outputId": "ea441567-f02e-4168-d7f3-1d0e78176e2f"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cohen kappa score for Color of lie column: 0.5828\n"
]
}
],
"source": [
"ann1 = df2['Ann_1.4'].to_list()\n",
"ann2 = df2['Ann_2.4'].to_list()\n",
"print(f'Cohen kappa score for Color of lie column: {cohen_kappa(ann1, ann2)}')"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "OqOp0c4orOw8"
},
"source": [
"### Element Wise Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "YlocrY-gm8kO",
"outputId": "81056363-5617-4ca2-a556-2f4c0d0d00ae"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cohen_kappa score for grey : 0.5705 and total grey's according to ann_1 & ann_2 are 73 & 90 respectively!\n",
"cohen_kappa score for black : 0.593 and total black's according to ann_1 & ann_2 are 281 & 253 respectively!\n",
"cohen_kappa score for red : 0.5425 and total red's according to ann_1 & ann_2 are 32 & 24 respectively!\n",
"cohen_kappa score for white : 0.7055 and total white's according to ann_1 & ann_2 are 30 & 44 respectively!\n",
"cohen_kappa score for nan : 0.4116 and total nan's according to ann_1 & ann_2 are 18 & 23 respectively!\n"
]
}
],
"source": [
"df2['Ann_1.4'] = df2['Ann_1.4'].fillna('nan')\n",
"df2['Ann_2.4'] = df2['Ann_2.4'].fillna('nan')\n",
"\n",
"ann1 = df2['Ann_1.4'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.4'].str.strip().to_list()\n",
"\n",
"# for grey\n",
"grey_1 = [1 if color.find('grey')>-1 else 0 for color in ann1]\n",
"grey_2 = [1 if color.find('grey')>-1 else 0 for color in ann2]\n",
"count_grey_1, count_grey_2 = sum(grey_1), sum(grey_2)\n",
"print(f'cohen_kappa score for grey : {cohen_kappa(grey_1, grey_2)} and total grey\\'s according to ann_1 & ann_2 are {count_grey_1} & {count_grey_2} respectively!')\n",
"\n",
"# For black\n",
"black_1 = [1 if color.find('black')>-1 else 0 for color in ann1]\n",
"black_2 = [1 if color.find('black')>-1 else 0 for color in ann2]\n",
"count_black_1, count_black_2 = sum(black_1), sum(black_2)\n",
"\n",
"print(f'cohen_kappa score for black : {cohen_kappa(black_1, black_2)} and total black\\'s according to ann_1 & ann_2 are {count_black_1} & {count_black_2} respectively!')\n",
"\n",
"\n",
"# For red\n",
"red_1 = [1 if color.find('red')>-1 else 0 for color in ann1]\n",
"red_2 = [1 if color.find('red')>-1 else 0 for color in ann2]\n",
"count_red_1, count_red_2 = sum(red_1), sum(red_2)\n",
"\n",
"print(f'cohen_kappa score for red : {cohen_kappa(red_1, red_2)} and total red\\'s according to ann_1 & ann_2 are {count_red_1} & {count_red_2} respectively!')\n",
"\n",
"\n",
"# For white\n",
"white_1 = [1 if color.find('white')>-1 else 0 for color in ann1]\n",
"white_2 = [1 if color.find('white')>-1 else 0 for color in ann2]\n",
"count_white_1, count_white_2 = sum(white_1), sum(white_2)\n",
"\n",
"print(f'cohen_kappa score for white : {cohen_kappa(white_1, white_2)} and total white\\'s according to ann_1 & ann_2 are {count_white_1} & {count_white_2} respectively!')\n",
"\n",
"\n",
"# For null values\n",
"nan_1 = [1 if color.find('nan')>-1 else 0 for color in ann1]\n",
"nan_2 = [1 if color.find('nan')>-1 else 0 for color in ann2]\n",
"count_nan_1, count_nan_2 = sum(nan_1), sum(nan_2)\n",
"\n",
"print(f'cohen_kappa score for nan : {cohen_kappa(nan_1, nan_2)} and total nan\\'s according to ann_1 & ann_2 are {count_nan_1} & {count_nan_2} respectively!')\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "IkZRFH46q1nn"
},
"source": [
"## For Intent of Lie Column:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Jhciajeodhso",
"outputId": "303f3aeb-0302-4295-9a3b-b8ebac8b695a"
},
"outputs": [
{
"data": {
"text/plain": [
"gaining advantage 261\n",
"protecting themselves 117\n",
"gaining esteem 30\n",
"nan 21\n",
"avoiding embarrassment 5\n",
"Name: Ann_1.6, dtype: int64"
]
},
"execution_count": 644,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_1.6'].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "EFxWPeSjdmbi",
"outputId": "c31d5118-e272-4631-af89-03a92a7b08c7"
},
"outputs": [
{
"data": {
"text/plain": [
"gaining advantage 218\n",
"protecting themselves 133\n",
"gaining esteem 52\n",
"nan 22\n",
"avoiding embarrassment 9\n",
"Name: Ann_2.6, dtype: int64"
]
},
"execution_count": 645,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_2.6'].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "JRqI1TlYrP-Z"
},
"source": [
"### Overall Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "tdgAxyPldM3Q",
"outputId": "87b8f7d6-631d-47cf-e523-d8ba6f726add"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cohen kappa score for Intent of lie column: 0.3823\n"
]
}
],
"source": [
"ann1 = df2['Ann_1.6'].to_list()\n",
"ann2 = df2['Ann_2.6'].to_list()\n",
"print(f'Cohen kappa score for Intent of lie column: {cohen_kappa(ann1, ann2)}')"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "C6UNrtUSrR-8"
},
"source": [
"### Element Wise Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "frXwHRUOm_3D",
"outputId": "f266ee79-472d-486b-cebf-1ccc27866cd1"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cohen_kappa score gaining advantage : 0.3773 and total gaining advantage's according to ann_1 & ann_2 are 261 & 218 respectively!\n",
"cohen_kappa score for gaining_esteem : 0.2782 and total gaining_esteem's according to ann_1 & ann_2 are 30 & 52 respectively!\n",
"cohen_kappa score for protecting_themselves : 0.4503 and total protecting_themselves's according to ann_1 & ann_2 are 117 & 133 respectively!\n",
"cohen_kappa score for avoiding_embarrassment : -0.015 and total avoiding_embarrassment's according to ann_1 & ann_2 are 5 & 9 respectively!\n",
"cohen_kappa score for nan : 0.4373 and total nan's according to ann_1 & ann_2 are 21 & 22 respectively!\n"
]
}
],
"source": [
"df2['Ann_1.6'] = df2['Ann_1.6'].fillna('nan')\n",
"df2['Ann_2.6'] = df2['Ann_2.6'].fillna('nan')\n",
"\n",
"ann1 = df2['Ann_1.6'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.6'].str.strip().to_list()\n",
"\n",
"# for gaining advantage\n",
"gaining_advantage_1 = [1 if color.find('gaining advantage')>-1 else 0 for color in ann1]\n",
"gaining_advantage_2 = [1 if color.find('gaining advantage')>-1 else 0 for color in ann2]\n",
"count_gaining_advantage_1, count_gaining_advantage_2 = sum(gaining_advantage_1), sum(gaining_advantage_2)\n",
"print(f'cohen_kappa score gaining advantage : {cohen_kappa(gaining_advantage_1, gaining_advantage_2)} and total gaining advantage\\'s according to ann_1 & ann_2 are {count_gaining_advantage_1} & {count_gaining_advantage_2} respectively!')\n",
"\n",
"# For gaining_esteem\n",
"gaining_esteem_1 = [1 if color.find('gaining esteem')>-1 else 0 for color in ann1]\n",
"gaining_esteem_2 = [1 if color.find('gaining esteem')>-1 else 0 for color in ann2]\n",
"count_gaining_esteem_1, count_gaining_esteem_2 = sum(gaining_esteem_1), sum(gaining_esteem_2)\n",
"\n",
"print(f'cohen_kappa score for gaining_esteem : {cohen_kappa(gaining_esteem_1, gaining_esteem_2)} and total gaining_esteem\\'s according to ann_1 & ann_2 are {count_gaining_esteem_1} & {count_gaining_esteem_2} respectively!')\n",
"\n",
"\n",
"# For protecting_themselves\n",
"protecting_themselves_1 = [1 if color.find('protecting themselves')>-1 else 0 for color in ann1]\n",
"protecting_themselves_2 = [1 if color.find('protecting themselves')>-1 else 0 for color in ann2]\n",
"count_protecting_themselves_1, count_protecting_themselves_2 = sum(protecting_themselves_1), sum(protecting_themselves_2)\n",
"\n",
"print(f'cohen_kappa score for protecting_themselves : {cohen_kappa(protecting_themselves_1, protecting_themselves_2)} and total protecting_themselves\\'s according to ann_1 & ann_2 are {count_protecting_themselves_1} & {count_protecting_themselves_2} respectively!')\n",
"\n",
"\n",
"\n",
"\n",
"# For voiding_embarrassment \n",
"avoiding_embarrassment_1 = [1 if color.find('avoiding embarrassment')>-1 else 0 for color in ann1]\n",
"avoiding_embarrassment_2 = [1 if color.find('avoiding embarrassment')>-1 else 0 for color in ann2]\n",
"count_avoiding_embarrassment_1, count_avoiding_embarrassment_2 = sum(avoiding_embarrassment_1), sum(avoiding_embarrassment_2)\n",
"\n",
"print(f'cohen_kappa score for avoiding_embarrassment : {cohen_kappa(avoiding_embarrassment_1, avoiding_embarrassment_2)} and total avoiding_embarrassment\\'s according to ann_1 & ann_2 are {count_avoiding_embarrassment_1} & {count_avoiding_embarrassment_2} respectively!')\n",
"\n",
"\n",
"\n",
"# For null values\n",
"nan_1 = [1 if color.find('nan')>-1 else 0 for color in ann1]\n",
"nan_2 = [1 if color.find('nan')>-1 else 0 for color in ann2]\n",
"count_nan_1, count_nan_2 = sum(nan_1), sum(nan_2)\n",
"\n",
"print(f'cohen_kappa score for nan : {cohen_kappa(nan_1, nan_2)} and total nan\\'s according to ann_1 & ann_2 are {count_nan_1} & {count_nan_2} respectively!')\n",
"\n",
"\n",
"# Extra classes not present in our dataset\n",
"# # For protecting_others\n",
"# protecting_others_1 = [1 if color.find('protecting others')>-1 else 0 for color in ann1]\n",
"# protecting_others_2 = [1 if color.find('protecting others')>-1 else 0 for color in ann2]\n",
"# count_protecting_others_1, count_protecting_others_2 = sum(protecting_others_1), sum(protecting_others_2)\n",
"\n",
"# print(f'cohen_kappa score for protecting_others : {cohen_kappa(protecting_others_1, protecting_others_2)} and total protecting_others\\'s according to ann_1 & ann_2 are {count_protecting_others_1} & {count_protecting_others_2} respectively!')\n",
"\n",
"# # For defaming esteem\n",
"# defaming_esteem_1 = [1 if color.find('defaming esteem')>-1 else 0 for color in ann1]\n",
"# defaming_esteem_2 = [1 if color.find('defaming esteem')>-1 else 0 for color in ann2]\n",
"# count_defaming_esteem_1, count_defaming_esteem_2 = sum(defaming_esteem_1), sum(defaming_esteem_2)\n",
"\n",
"# print(f'cohen_kappa score for defaming_esteem : {cohen_kappa(defaming_esteem_1, defaming_esteem_2)} and total defaming_esteem\\'s according to ann_1 & ann_2 are {count_defaming_esteem_1} & {count_defaming_esteem_2} respectively!')\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ayz3ibQ4qwwm"
},
"source": [
"## For category of lie Column:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "8e7b_sTVdrr1",
"outputId": "92fe3936-b486-424a-f227-b60cc2d3984e"
},
"outputs": [
{
"data": {
"text/plain": [
"political 297\n",
"educational 99\n",
"ethnicity 18\n",
"racial 12\n",
"religious 4\n",
"nan 2\n",
"others 2\n",
"Name: Ann_1.7, dtype: int64"
]
},
"execution_count": 648,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_1.7'].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "QYoYGDY_dvll",
"outputId": "642e5369-ee03-4e7b-b096-fe793c8d6466"
},
"outputs": [
{
"data": {
"text/plain": [
"political 297\n",
"educational 83\n",
"ethnicity 23\n",
"racial 20\n",
"religious 8\n",
"nan 2\n",
"others 1\n",
"Name: Ann_2.7, dtype: int64"
]
},
"execution_count": 649,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2['Ann_2.7'].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "UjgiMUVord4f"
},
"source": [
"### Overall Kappa Score:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "xsK4jodOd3RT",
"outputId": "e7a93825-6014-44e6-a3c1-51077cf5a94a"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cohen kappa score for Final column: 0.7098\n"
]
}
],
"source": [
"ann1 = df2['Ann_1.7'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.7'].str.strip().to_list()\n",
"print(f'Cohen kappa score for Final column: {cohen_kappa(ann1, ann2)}')"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "t1xU4zAYrg5v"
},
"source": [
"### Element wise Kappa Scores:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "7svIEqAIqIes",
"outputId": "3eb33ba9-8cd3-425e-e46a-11290fc6496e"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cohen_kappa score gaining advantage : 0.776 and total political's according to ann_1 & ann_2 are 297 & 297 respectively!\n",
"cohen_kappa score for educational : 0.7086 and total educational's according to ann_1 & ann_2 are 99 & 83 respectively!\n",
"cohen_kappa score for ethnicity : 0.514 and total ethnicity's according to ann_1 & ann_2 are 18 & 23 respectively!\n",
"cohen_kappa score for religious : 0.4938 and total religious's according to ann_1 & ann_2 are 4 & 8 respectively!\n",
"cohen_kappa score for racial : 0.6116 and total racial's according to ann_1 & ann_2 are 12 & 20 respectively!\n",
"cohen_kappa score for other : 0.6656 and total other's according to ann_1 & ann_2 are 2 & 1 respectively!\n",
"cohen_kappa score for nan : 1.0 and total nan's according to ann_1 & ann_2 are 2 & 2 respectively!\n"
]
}
],
"source": [
"df2['Ann_1.7'] = df2['Ann_1.7'].fillna('nan')\n",
"df2['Ann_2.7'] = df2['Ann_2.7'].fillna('nan')\n",
"\n",
"ann1 = df2['Ann_1.7'].str.strip().to_list()\n",
"ann2 = df2['Ann_2.7'].str.strip().to_list()\n",
"\n",
"# for political\n",
"political_1 = [1 if color.find('political')>-1 else 0 for color in ann1]\n",
"political_2 = [1 if color.find('political')>-1 else 0 for color in ann2]\n",
"count_political_1, count_political_2 = sum(political_1), sum(political_2)\n",
"print(f'cohen_kappa score gaining advantage : {cohen_kappa(political_1, political_2)} and total political\\'s according to ann_1 & ann_2 are {count_political_1} & {count_political_2} respectively!')\n",
"\n",
"\n",
"# For educational\n",
"educational_1 = [1 if color.find('educational')>-1 else 0 for color in ann1]\n",
"educational_2 = [1 if color.find('educational')>-1 else 0 for color in ann2]\n",
"count_educational_1, count_educational_2 = sum(educational_1), sum(educational_2)\n",
"\n",
"print(f'cohen_kappa score for educational : {cohen_kappa(educational_1, educational_2)} and total educational\\'s according to ann_1 & ann_2 are {count_educational_1} & {count_educational_2} respectively!')\n",
"\n",
"\n",
"# For ethnicity\n",
"ethnicity_1 = [1 if color.find('ethnicity')>-1 else 0 for color in ann1]\n",
"ethnicity_2 = [1 if color.find('ethnicity')>-1 else 0 for color in ann2]\n",
"count_ethnicity_1, count_ethnicity_2 = sum(ethnicity_1), sum(ethnicity_2)\n",
"\n",
"print(f'cohen_kappa score for ethnicity : {cohen_kappa(ethnicity_1, ethnicity_2)} and total ethnicity\\'s according to ann_1 & ann_2 are {count_ethnicity_1} & {count_ethnicity_2} respectively!')\n",
"\n",
"\n",
"# For religious\n",
"religious_1 = [1 if color.find('religious')>-1 else 0 for color in ann1]\n",
"religious_2 = [1 if color.find('religious')>-1 else 0 for color in ann2]\n",
"count_religious_1, count_religious_2 = sum(religious_1), sum(religious_2)\n",
"\n",
"print(f'cohen_kappa score for religious : {cohen_kappa(religious_1, religious_2)} and total religious\\'s according to ann_1 & ann_2 are {count_religious_1} & {count_religious_2} respectively!')\n",
"\n",
"\n",
"# For racial \n",
"racial_1 = [1 if color.find('racial')>-1 else 0 for color in ann1]\n",
"racial_2 = [1 if color.find('racial')>-1 else 0 for color in ann2]\n",
"count_racial_1, count_racial_2 = sum(racial_1), sum(racial_2)\n",
"\n",
"print(f'cohen_kappa score for racial : {cohen_kappa(racial_1, racial_2)} and total racial\\'s according to ann_1 & ann_2 are {count_racial_1} & {count_racial_2} respectively!')\n",
"\n",
"\n",
"# For defaming other\n",
"other_1 = [1 if color.find('other')>-1 else 0 for color in ann1]\n",
"other_2 = [1 if color.find('other')>-1 else 0 for color in ann2]\n",
"count_other_1, count_other_2 = sum(other_1), sum(other_2)\n",
"\n",
"print(f'cohen_kappa score for other : {cohen_kappa(other_1, other_2)} and total other\\'s according to ann_1 & ann_2 are {count_other_1} & {count_other_2} respectively!')\n",
"\n",
"\n",
"# For null values\n",
"nan_1 = [1 if color.find('nan')>-1 else 0 for color in ann1]\n",
"nan_2 = [1 if color.find('nan')>-1 else 0 for color in ann2]\n",
"count_nan_1, count_nan_2 = sum(nan_1), sum(nan_2)\n",
"\n",
"print(f'cohen_kappa score for nan : {cohen_kappa(nan_1, nan_2)} and total nan\\'s according to ann_1 & ann_2 are {count_nan_1} & {count_nan_2} respectively!')\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "xxL4i4X_rq8M"
},
"source": [
"### END"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "8-sxitPzrr61"
},
"outputs": [],
"source": []
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|