In [1]:
%matplotlib inline

import configparser
import os

import requests
from tqdm import tqdm
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import sparse, stats, spatial
import scipy.sparse.linalg
from sklearn import preprocessing, decomposition
import librosa
import IPython.display as ipd
import json
import tmdbsimple as tmdb
from itertools import chain
from pygsp import graphs, filters, plotting

plt.rcParams['figure.figsize'] = (17, 5)
plotting.BACKEND = 'matplotlib'

In [172]:
dataset = pd.read_csv('Saved_Datasets/NewFeaturesDataset.csv')

In [173]:
dataset.head(10)


Out[173]:
id budget genres imdb_id overview production_companies release_date revenue tagline title director_name director_id actor_names actor_ids Metacritic Normed_Metacritic ROI Normed_ROI success
0 12 94000000 Animation|Family 266543 Nemo, an adventurous young clownfish, is unexp... Pixar Animation Studios 2003-05-30 940335536 There are 3.7 trillion fish in the ocean, they... Finding Nemo Andrew Stanton 0 ['Albert Brooks', 'Ellen DeGeneres', 'Alexande... [0, 908, 2000, 772, 3304] 90 0.943 9.003570 0.47 1
1 16 12800000 Drama|Crime|Music 168629 Selma, a Czech immigrant on the verge of blind... Fine Line Features 2000-05-17 40031879 You don't need eyes to see. Dancer in the Dark Lars von Trier 1 ['Björk', 'Catherine Deneuve', 'David Morse', ... [1, 434, 2001, 1630, 3993] 61 0.731 2.127491 0.14 1
2 22 140000000 Adventure|Fantasy|Action 325980 Jack Sparrow, a freewheeling 17th-century pira... Walt Disney Pictures 2003-09-07 655011224 Prepare to be blown out of the water. Pirates of the Caribbean: The Curse of the Bla... Gore Verbinski 2 ['Johnny Depp', 'Geoffrey Rush', 'Orlando Bloo... [2, 412, 136, 71, 3143] 63 0.754 3.678652 0.23 1
3 24 30000000 Action|Crime 266697 An assassin is shot at the altar by her ruthle... Miramax Films 2003-10-10 180949000 Go for the kill. Kill Bill: Vol. 1 Quentin Tarantino 3 ['Uma Thurman', 'Lucy Liu', 'Vivica A. Fox', '... [3, 1071, 2002, 1684, 1097] 69 0.814 5.031633 0.30 1
4 25 72000000 Drama|War 418763 Jarhead is a film about a US Marine Anthony Sw... Universal Pictures 2005-04-11 96889998 Welcome to the suck. Jarhead Sam Mendes 4 ['Jamie Foxx', 'Scott MacDonald', 'Lucas Black... [4, 1072, 328, 1293] 58 0.695 0.345694 0.02 1
5 27 1000000 Drama|Music|Romance 411705 Matt, a young glaciologist, soars across the v... Revolution Films 2004-07-16 1574623 2 lovers, one summer, and the 9 songs that def... 9 Songs Michael Winterbottom 5 ["Kieran O'Brien", 'Margo Stilley', 'Courtney ... [5, 1073, 2003, 2983, 3994] 43 0.480 0.574623 0.04 1
6 35 75000000 Animation|Comedy|Family 462538 After Homer accidentally pollutes the town's w... Gracie Films 2007-07-25 527068851 See our family. And feel better about yours. The Simpsons Movie David Silverman 6 ['Dan Castellaneta', 'Julie Kavner', 'Nancy Ca... [6, 1074, 2004, 2984, 719] 80 0.896 6.027585 0.34 1
7 38 20000000 Science Fiction|Drama|Romance 338013 Joel Barish, heartbroken that his girlfriend u... Anonymous Content 2004-03-19 72258126 You can erase someone from your mind. Getting ... Eternal Sunshine of the Spotless Mind Michel Gondry 7 ['Jim Carrey', 'Kate Winslet', 'Kirsten Dunst'... [7, 131, 147, 652, 20] 89 0.939 2.612906 0.17 1
8 58 200000000 Adventure|Fantasy|Action 383574 Captain Jack Sparrow works his way out of a bl... Walt Disney Pictures 2006-06-20 1065659812 Jack is back! Pirates of the Caribbean: Dead Man's Chest Gore Verbinski 2 ['Johnny Depp', 'Orlando Bloom', 'Keira Knight... [2, 136, 71, 421, 472] 53 0.629 4.328299 0.26 1
9 59 32000000 Drama|Thriller|Crime 399146 An average family is thrust into the spotlight... New Line Cinema 2005-09-23 60740827 Tom Stall had the perfect life... until he bec... A History of Violence David Cronenberg 8 ['Viggo Mortensen', 'Maria Bello', 'Heidi Haye... [8, 1075, 2005, 2985, 636] 81 0.901 0.898151 0.06 1

1. Data exploration


In [174]:
#number of movies per directors
all_director = list(dataset['director_name'])
print(len(all_director))
diff_all_director = list(set(all_director))
print(len(diff_all_director))
#print(diff_all_director)

freqDir = []
for i in diff_all_director:
    freqDir.append(all_director.count(i))
#print(freqDir)    

#distribution nb movies per director
movies_per_dir = []
diff_freq = list(set(freqDir))
print(diff_freq)
for i in diff_freq:
    movies_per_dir.append(freqDir.count(i))
print(movies_per_dir)


2621
1294
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14]
[742, 237, 131, 73, 46, 26, 14, 11, 6, 3, 3, 2]

In [175]:
moy = ((np.array(movies_per_dir) @ np.array(diff_freq)))/(len(diff_all_director))
print(moy)


2.02550231839

In [176]:
plt.bar(diff_freq, movies_per_dir, align='center');
plt.setp(plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right');
plt.xlabel('Number of movies per director');
plt.ylabel('Number of Director');
plt.savefig('images/nb_movie_per_dir.png', dpi=300, bbox_inches='tight')



In [178]:
top_director = {}

for j in diff_freq[6:]:
    dir_name_top = []
    for i in range(0,len(freqDir)):
        if freqDir[i] == j:
            dir_name_top.append(diff_all_director[i])
    top_director[j] = dir_name_top

print(top_director)


{7: ['Kevin Smith', 'James Wan', 'Louis Leterrier', 'Danny Boyle', 'Martin Scorsese', 'Tim Story', 'Robert Luketic', 'Rob Cohen', 'Zack Snyder', 'Bryan Singer', 'Renny Harlin', 'Brett Ratner', 'Lasse Hallström', 'Dennis Dugan'], 8: ['Jon Favreau', 'Robert Zemeckis', 'Adam Shankman', 'Peter Jackson', 'Roland Emmerich', 'Gore Verbinski', 'Christopher Nolan', 'M. Night Shyamalan', 'Marc Forster', 'Peter Berg', 'Paul W.S. Anderson'], 9: ['Antoine Fuqua', 'Bobby Farrelly', 'Michael Bay', 'Todd Phillips', 'Ron Howard', 'Richard Linklater'], 10: ['Tim Burton', 'Woody Allen', 'Shawn Levy'], 12: ['Robert Rodriguez', 'Steven Spielberg', 'Ridley Scott'], 14: ['Clint Eastwood', 'Steven Soderbergh']}

2. Director similartiy between pairs of movies


In [179]:
director_list = list(set(dataset['director_id']))
nb_directors = len(director_list)

director_dic = {}
for i in range(0,len(dataset)):
    director_dic[i]=dataset['director_id'][i]
print(director_dic)


{0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 2, 9: 8, 10: 9, 11: 10, 12: 11, 13: 12, 14: 13, 15: 14, 16: 15, 17: 16, 18: 17, 19: 18, 20: 19, 21: 20, 22: 21, 23: 22, 24: 22, 25: 22, 26: 23, 27: 24, 28: 25, 29: 26, 30: 14, 31: 27, 32: 27, 33: 28, 34: 29, 35: 30, 36: 31, 37: 13, 38: 27, 39: 32, 40: 33, 41: 33, 42: 34, 43: 35, 44: 36, 45: 36, 46: 13, 47: 37, 48: 38, 49: 39, 50: 40, 51: 22, 52: 41, 53: 14, 54: 42, 55: 2, 56: 7, 57: 43, 58: 27, 59: 44, 60: 45, 61: 46, 62: 47, 63: 48, 64: 14, 65: 49, 66: 11, 67: 50, 68: 51, 69: 52, 70: 53, 71: 54, 72: 55, 73: 3, 74: 56, 75: 57, 76: 58, 77: 59, 78: 60, 79: 41, 80: 61, 81: 62, 82: 63, 83: 7, 84: 64, 85: 65, 86: 27, 87: 66, 88: 67, 89: 68, 90: 69, 91: 70, 92: 71, 93: 20, 94: 72, 95: 73, 96: 74, 97: 75, 98: 75, 99: 75, 100: 76, 101: 2, 102: 67, 103: 77, 104: 21, 105: 78, 106: 12, 107: 64, 108: 13, 109: 79, 110: 79, 111: 80, 112: 13, 113: 81, 114: 82, 115: 83, 116: 13, 117: 84, 118: 13, 119: 69, 120: 36, 121: 85, 122: 86, 123: 87, 124: 88, 125: 89, 126: 90, 127: 91, 128: 92, 129: 93, 130: 88, 131: 94, 132: 95, 133: 96, 134: 97, 135: 98, 136: 99, 137: 59, 138: 59, 139: 100, 140: 90, 141: 101, 142: 42, 143: 102, 144: 18, 145: 103, 146: 21, 147: 104, 148: 105, 149: 64, 150: 106, 151: 107, 152: 108, 153: 109, 154: 110, 155: 112, 156: 113, 157: 14, 158: 114, 159: 66, 160: 39, 161: 115, 162: 116, 163: 117, 164: 118, 165: 11, 166: 119, 167: 103, 168: 120, 169: 121, 170: 122, 171: 106, 172: 29, 173: 124, 174: 125, 175: 126, 176: 127, 177: 103, 178: 82, 179: 128, 180: 84, 181: 129, 182: 130, 183: 131, 184: 132, 185: 133, 186: 33, 187: 54, 188: 134, 189: 135, 190: 136, 191: 137, 192: 138, 193: 139, 194: 140, 195: 18, 196: 141, 197: 142, 198: 143, 199: 144, 200: 16, 201: 145, 202: 42, 203: 146, 204: 56, 205: 147, 206: 81, 207: 148, 208: 15, 209: 149, 210: 150, 211: 151, 212: 90, 213: 152, 214: 89, 215: 153, 216: 154, 217: 155, 218: 156, 219: 157, 220: 158, 221: 159, 222: 159, 223: 160, 224: 161, 225: 162, 226: 163, 227: 164, 228: 165, 229: 166, 230: 167, 231: 51, 232: 134, 233: 168, 234: 169, 235: 91, 236: 170, 237: 171, 238: 172, 239: 173, 240: 174, 241: 85, 242: 175, 243: 89, 244: 146, 245: 26, 246: 176, 247: 176, 248: 27, 249: 96, 250: 146, 251: 29, 252: 177, 253: 25, 254: 178, 255: 179, 256: 180, 257: 55, 258: 181, 259: 182, 260: 183, 261: 184, 262: 185, 263: 175, 264: 186, 265: 186, 266: 189, 267: 5, 268: 190, 269: 191, 270: 192, 271: 102, 272: 193, 273: 194, 274: 195, 275: 51, 276: 62, 277: 196, 278: 197, 279: 167, 280: 198, 281: 75, 282: 199, 283: 200, 284: 201, 285: 202, 286: 203, 287: 204, 288: 205, 289: 206, 290: 207, 291: 208, 292: 209, 293: 210, 294: 27, 295: 211, 296: 212, 297: 213, 298: 169, 299: 69, 300: 214, 301: 215, 302: 216, 303: 217, 304: 218, 305: 219, 306: 80, 307: 220, 308: 221, 309: 222, 310: 8, 311: 137, 312: 40, 313: 223, 314: 224, 315: 225, 316: 226, 317: 226, 318: 28, 319: 227, 320: 228, 321: 229, 322: 134, 323: 230, 324: 59, 325: 231, 326: 97, 327: 232, 328: 232, 329: 233, 330: 132, 331: 234, 332: 235, 333: 236, 334: 237, 335: 238, 336: 239, 337: 227, 338: 208, 339: 240, 340: 46, 341: 241, 342: 242, 343: 243, 344: 244, 345: 245, 346: 245, 347: 246, 348: 10, 349: 247, 350: 194, 351: 248, 352: 249, 353: 250, 354: 132, 355: 170, 356: 252, 357: 253, 358: 254, 359: 255, 360: 15, 361: 43, 362: 256, 363: 11, 364: 170, 365: 257, 366: 11, 367: 258, 368: 259, 369: 21, 370: 148, 371: 260, 372: 261, 373: 162, 374: 262, 375: 263, 376: 4, 377: 4, 378: 264, 379: 203, 380: 265, 381: 265, 382: 266, 383: 266, 384: 267, 385: 73, 386: 268, 387: 268, 388: 269, 389: 270, 390: 271, 391: 272, 392: 273, 393: 274, 394: 275, 395: 239, 396: 276, 397: 277, 398: 278, 399: 60, 400: 182, 401: 279, 402: 280, 403: 281, 404: 282, 405: 283, 406: 284, 407: 285, 408: 286, 409: 92, 410: 287, 411: 24, 412: 288, 413: 223, 414: 289, 415: 290, 416: 253, 417: 182, 418: 253, 419: 291, 420: 276, 421: 133, 422: 292, 423: 293, 424: 294, 425: 18, 426: 295, 427: 20, 428: 296, 429: 207, 430: 297, 431: 298, 432: 299, 433: 299, 434: 300, 435: 227, 436: 301, 437: 302, 438: 303, 439: 304, 440: 305, 441: 11, 442: 306, 443: 307, 444: 308, 445: 309, 446: 310, 447: 311, 448: 312, 449: 313, 450: 313, 451: 314, 452: 155, 453: 303, 454: 2, 455: 315, 456: 316, 457: 317, 458: 318, 459: 319, 460: 320, 461: 76, 462: 321, 463: 224, 464: 322, 465: 323, 466: 324, 467: 203, 468: 87, 469: 280, 470: 163, 471: 309, 472: 240, 473: 292, 474: 325, 475: 2, 476: 148, 477: 101, 478: 154, 479: 23, 480: 165, 481: 327, 482: 328, 483: 329, 484: 330, 485: 331, 486: 332, 487: 333, 488: 334, 489: 335, 490: 336, 491: 337, 492: 338, 493: 339, 494: 246, 495: 340, 496: 341, 497: 342, 498: 343, 499: 344, 500: 345, 501: 166, 502: 346, 503: 347, 504: 348, 505: 349, 506: 197, 507: 350, 508: 351, 509: 352, 510: 353, 511: 354, 512: 143, 513: 355, 514: 356, 515: 115, 516: 357, 517: 62, 518: 358, 519: 359, 520: 121, 521: 360, 522: 361, 523: 362, 524: 103, 525: 22, 526: 99, 527: 363, 528: 339, 529: 364, 530: 273, 531: 12, 532: 270, 533: 103, 534: 365, 535: 366, 536: 367, 537: 368, 538: 369, 539: 370, 540: 371, 541: 97, 542: 372, 543: 373, 544: 374, 545: 375, 546: 67, 547: 376, 548: 377, 549: 189, 550: 378, 551: 107, 552: 227, 553: 379, 554: 89, 555: 374, 556: 380, 557: 279, 558: 381, 559: 382, 560: 383, 561: 384, 562: 385, 563: 386, 564: 16, 565: 309, 566: 387, 567: 388, 568: 389, 569: 240, 570: 390, 571: 386, 572: 391, 573: 230, 574: 392, 575: 393, 576: 394, 577: 209, 578: 270, 579: 395, 580: 396, 581: 397, 582: 398, 583: 399, 584: 401, 585: 64, 586: 402, 587: 403, 588: 404, 589: 405, 590: 406, 591: 407, 592: 269, 593: 89, 594: 408, 595: 409, 596: 410, 597: 411, 598: 230, 599: 412, 600: 413, 601: 414, 602: 249, 603: 371, 604: 415, 605: 416, 606: 417, 607: 418, 608: 419, 609: 420, 610: 421, 611: 422, 612: 169, 613: 310, 614: 423, 615: 424, 616: 425, 617: 265, 618: 277, 619: 308, 620: 426, 621: 427, 622: 205, 623: 428, 624: 429, 625: 430, 626: 172, 627: 381, 628: 431, 629: 432, 630: 433, 631: 434, 632: 162, 633: 435, 634: 436, 635: 437, 636: 368, 637: 438, 638: 50, 639: 439, 640: 440, 641: 142, 642: 294, 643: 441, 644: 428, 645: 338, 646: 442, 647: 344, 648: 443, 649: 60, 650: 73, 651: 444, 652: 445, 653: 197, 654: 118, 655: 446, 656: 33, 657: 447, 658: 172, 659: 143, 660: 448, 661: 303, 662: 80, 663: 429, 664: 299, 665: 226, 666: 87, 667: 449, 668: 450, 669: 221, 670: 197, 671: 11, 672: 451, 673: 452, 674: 453, 675: 445, 676: 109, 677: 96, 678: 452, 679: 194, 680: 454, 681: 279, 682: 455, 683: 456, 684: 457, 685: 458, 686: 459, 687: 242, 688: 205, 689: 460, 690: 461, 691: 462, 692: 463, 693: 86, 694: 240, 695: 464, 696: 112, 697: 465, 698: 460, 699: 466, 700: 393, 701: 467, 702: 18, 703: 188, 704: 18, 705: 240, 706: 468, 707: 469, 708: 50, 709: 333, 710: 322, 711: 470, 712: 471, 713: 150, 714: 161, 715: 271, 716: 247, 717: 472, 718: 408, 719: 473, 720: 474, 721: 475, 722: 166, 723: 476, 724: 204, 725: 477, 726: 478, 727: 330, 728: 479, 729: 232, 730: 170, 731: 480, 732: 428, 733: 481, 734: 284, 735: 287, 736: 482, 737: 169, 738: 220, 739: 252, 740: 483, 741: 484, 742: 485, 743: 55, 744: 486, 745: 487, 746: 488, 747: 373, 748: 28, 749: 140, 750: 335, 751: 143, 752: 61, 753: 153, 754: 316, 755: 489, 756: 490, 757: 491, 758: 492, 759: 493, 760: 494, 761: 495, 762: 496, 763: 497, 764: 374, 765: 498, 766: 499, 767: 321, 768: 446, 769: 500, 770: 264, 771: 501, 772: 194, 773: 385, 774: 140, 775: 162, 776: 502, 777: 503, 778: 166, 779: 46, 780: 191, 781: 33, 782: 343, 783: 504, 784: 505, 785: 469, 786: 506, 787: 333, 788: 507, 789: 508, 790: 509, 791: 499, 792: 163, 793: 91, 794: 184, 795: 510, 796: 511, 797: 512, 798: 269, 799: 247, 800: 513, 801: 514, 802: 515, 803: 516, 804: 517, 805: 518, 806: 519, 807: 520, 808: 240, 809: 146, 810: 417, 811: 521, 812: 389, 813: 150, 814: 194, 815: 435, 816: 194, 817: 522, 818: 523, 819: 283, 820: 524, 821: 60, 822: 253, 823: 516, 824: 525, 825: 526, 826: 371, 827: 226, 828: 193, 829: 528, 830: 529, 831: 530, 832: 531, 833: 410, 834: 332, 835: 360, 836: 490, 837: 532, 838: 278, 839: 56, 840: 533, 841: 534, 842: 499, 843: 175, 844: 108, 845: 19, 846: 535, 847: 536, 848: 537, 849: 366, 850: 387, 851: 158, 852: 538, 853: 539, 854: 540, 855: 541, 856: 299, 857: 542, 858: 543, 859: 366, 860: 544, 861: 188, 862: 209, 863: 371, 864: 170, 865: 532, 866: 545, 867: 546, 868: 547, 869: 256, 870: 548, 871: 549, 872: 194, 873: 550, 874: 551, 875: 426, 876: 552, 877: 553, 878: 332, 879: 259, 880: 554, 881: 555, 882: 163, 883: 150, 884: 556, 885: 164, 886: 557, 887: 558, 888: 559, 889: 195, 890: 103, 891: 560, 892: 332, 893: 561, 894: 562, 895: 367, 896: 365, 897: 563, 898: 209, 899: 256, 900: 564, 901: 565, 902: 566, 903: 567, 904: 568, 905: 569, 906: 570, 907: 280, 908: 571, 909: 572, 910: 164, 911: 151, 912: 353, 913: 408, 914: 490, 915: 385, 916: 188, 917: 574, 918: 575, 919: 373, 920: 312, 921: 543, 922: 576, 923: 577, 924: 578, 925: 579, 926: 284, 927: 580, 928: 446, 929: 581, 930: 73, 931: 238, 932: 32, 933: 321, 934: 582, 935: 583, 936: 584, 937: 138, 938: 469, 939: 400, 940: 585, 941: 257, 942: 130, 943: 16, 944: 27, 945: 132, 946: 586, 947: 587, 948: 507, 949: 220, 950: 290, 951: 588, 952: 589, 953: 590, 954: 409, 955: 169, 956: 41, 957: 591, 958: 592, 959: 594, 960: 595, 961: 518, 962: 264, 963: 373, 964: 596, 965: 166, 966: 597, 967: 386, 968: 517, 969: 159, 970: 212, 971: 598, 972: 205, 973: 599, 974: 600, 975: 601, 976: 404, 977: 428, 978: 104, 979: 602, 980: 603, 981: 172, 982: 604, 983: 156, 984: 167, 985: 605, 986: 498, 987: 606, 988: 489, 989: 607, 990: 23, 991: 608, 992: 609, 993: 497, 994: 610, 995: 468, 996: 30, 997: 611, 998: 612, 999: 99, 1000: 151, 1001: 613, 1002: 614, 1003: 615, 1004: 616, 1005: 426, 1006: 398, 1007: 617, 1008: 618, 1009: 151, 1010: 416, 1011: 109, 1012: 586, 1013: 172, 1014: 18, 1015: 393, 1016: 619, 1017: 575, 1018: 620, 1019: 265, 1020: 21, 1021: 390, 1022: 84, 1023: 621, 1024: 622, 1025: 623, 1026: 624, 1027: 156, 1028: 625, 1029: 626, 1030: 627, 1031: 628, 1032: 629, 1033: 267, 1034: 33, 1035: 630, 1036: 245, 1037: 15, 1038: 29, 1039: 54, 1040: 631, 1041: 632, 1042: 88, 1043: 633, 1044: 532, 1045: 248, 1046: 352, 1047: 634, 1048: 291, 1049: 487, 1050: 169, 1051: 635, 1052: 636, 1053: 637, 1054: 638, 1055: 639, 1056: 640, 1057: 641, 1058: 642, 1059: 19, 1060: 643, 1061: 644, 1062: 645, 1063: 646, 1064: 647, 1065: 649, 1066: 605, 1067: 373, 1068: 99, 1069: 650, 1070: 651, 1071: 652, 1072: 653, 1073: 654, 1074: 655, 1075: 656, 1076: 657, 1077: 658, 1078: 106, 1079: 495, 1080: 660, 1081: 661, 1082: 142, 1083: 11, 1084: 662, 1085: 663, 1086: 664, 1087: 665, 1088: 346, 1089: 453, 1090: 466, 1091: 666, 1092: 667, 1093: 15, 1094: 668, 1095: 669, 1096: 670, 1097: 671, 1098: 672, 1099: 673, 1100: 255, 1101: 674, 1102: 269, 1103: 675, 1104: 64, 1105: 32, 1106: 676, 1107: 677, 1108: 110, 1109: 270, 1110: 678, 1111: 679, 1112: 267, 1113: 680, 1114: 681, 1115: 452, 1116: 682, 1117: 683, 1118: 474, 1119: 684, 1120: 390, 1121: 250, 1122: 685, 1123: 563, 1124: 213, 1125: 431, 1126: 686, 1127: 455, 1128: 687, 1129: 688, 1130: 689, 1131: 472, 1132: 453, 1133: 333, 1134: 19, 1135: 199, 1136: 690, 1137: 82, 1138: 455, 1139: 692, 1140: 21, 1141: 693, 1142: 694, 1143: 367, 1144: 695, 1145: 266, 1146: 587, 1147: 696, 1148: 697, 1149: 698, 1150: 699, 1151: 700, 1152: 701, 1153: 702, 1154: 30, 1155: 704, 1156: 705, 1157: 675, 1158: 707, 1159: 640, 1160: 405, 1161: 708, 1162: 709, 1163: 77, 1164: 62, 1165: 710, 1166: 711, 1167: 502, 1168: 712, 1169: 713, 1170: 33, 1171: 715, 1172: 716, 1173: 717, 1174: 657, 1175: 53, 1176: 586, 1177: 719, 1178: 720, 1179: 721, 1180: 722, 1181: 680, 1182: 724, 1183: 452, 1184: 725, 1185: 726, 1186: 541, 1187: 727, 1188: 728, 1189: 729, 1190: 731, 1191: 733, 1192: 332, 1193: 735, 1194: 556, 1195: 210, 1196: 646, 1197: 671, 1198: 737, 1199: 738, 1200: 739, 1201: 165, 1202: 740, 1203: 545, 1204: 741, 1205: 742, 1206: 735, 1207: 528, 1208: 590, 1209: 181, 1210: 27, 1211: 743, 1212: 209, 1213: 217, 1214: 620, 1215: 745, 1216: 518, 1217: 168, 1218: 337, 1219: 746, 1220: 747, 1221: 526, 1222: 748, 1223: 418, 1224: 702, 1225: 514, 1226: 749, 1227: 750, 1228: 751, 1229: 163, 1230: 752, 1231: 37, 1232: 755, 1233: 756, 1234: 67, 1235: 757, 1236: 681, 1237: 758, 1238: 759, 1239: 243, 1240: 314, 1241: 760, 1242: 282, 1243: 600, 1244: 761, 1245: 379, 1246: 490, 1247: 234, 1248: 633, 1249: 762, 1250: 764, 1251: 765, 1252: 766, 1253: 404, 1254: 760, 1255: 140, 1256: 767, 1257: 3, 1258: 75, 1259: 768, 1260: 642, 1261: 770, 1262: 141, 1263: 462, 1264: 771, 1265: 773, 1266: 774, 1267: 490, 1268: 760, 1269: 268, 1270: 775, 1271: 776, 1272: 336, 1273: 777, 1274: 778, 1275: 779, 1276: 13, 1277: 119, 1278: 153, 1279: 780, 1280: 27, 1281: 781, 1282: 782, 1283: 246, 1284: 336, 1285: 783, 1286: 784, 1287: 227, 1288: 120, 1289: 168, 1290: 271, 1291: 607, 1292: 786, 1293: 788, 1294: 40, 1295: 322, 1296: 789, 1297: 151, 1298: 790, 1299: 791, 1300: 792, 1301: 143, 1302: 181, 1303: 793, 1304: 794, 1305: 795, 1306: 796, 1307: 428, 1308: 162, 1309: 704, 1310: 727, 1311: 798, 1312: 799, 1313: 4, 1314: 20, 1315: 800, 1316: 801, 1317: 714, 1318: 802, 1319: 803, 1320: 804, 1321: 805, 1322: 50, 1323: 178, 1324: 43, 1325: 370, 1326: 806, 1327: 807, 1328: 544, 1329: 808, 1330: 809, 1331: 588, 1332: 810, 1333: 811, 1334: 812, 1335: 94, 1336: 813, 1337: 627, 1338: 578, 1339: 18, 1340: 469, 1341: 815, 1342: 761, 1343: 816, 1344: 292, 1345: 817, 1346: 54, 1347: 270, 1348: 818, 1349: 819, 1350: 505, 1351: 602, 1352: 821, 1353: 823, 1354: 427, 1355: 134, 1356: 39, 1357: 206, 1358: 92, 1359: 825, 1360: 460, 1361: 826, 1362: 827, 1363: 279, 1364: 828, 1365: 829, 1366: 830, 1367: 24, 1368: 93, 1369: 556, 1370: 832, 1371: 148, 1372: 833, 1373: 338, 1374: 593, 1375: 11, 1376: 834, 1377: 55, 1378: 232, 1379: 418, 1380: 460, 1381: 473, 1382: 140, 1383: 835, 1384: 288, 1385: 104, 1386: 837, 1387: 381, 1388: 838, 1389: 839, 1390: 223, 1391: 840, 1392: 841, 1393: 106, 1394: 33, 1395: 737, 1396: 842, 1397: 226, 1398: 676, 1399: 843, 1400: 844, 1401: 15, 1402: 766, 1403: 239, 1404: 845, 1405: 271, 1406: 208, 1407: 432, 1408: 433, 1409: 758, 1410: 238, 1411: 439, 1412: 847, 1413: 467, 1414: 848, 1415: 849, 1416: 371, 1417: 806, 1418: 33, 1419: 507, 1420: 850, 1421: 851, 1422: 530, 1423: 235, 1424: 852, 1425: 853, 1426: 854, 1427: 537, 1428: 855, 1429: 359, 1430: 856, 1431: 857, 1432: 391, 1433: 197, 1434: 180, 1435: 859, 1436: 694, 1437: 724, 1438: 860, 1439: 861, 1440: 203, 1441: 14, 1442: 420, 1443: 386, 1444: 369, 1445: 115, 1446: 863, 1447: 393, 1448: 191, 1449: 128, 1450: 864, 1451: 865, 1452: 866, 1453: 655, 1454: 868, 1455: 802, 1456: 870, 1457: 871, 1458: 872, 1459: 341, 1460: 567, 1461: 466, 1462: 873, 1463: 607, 1464: 874, 1465: 875, 1466: 540, 1467: 877, 1468: 878, 1469: 879, 1470: 85, 1471: 481, 1472: 284, 1473: 880, 1474: 743, 1475: 136, 1476: 175, 1477: 882, 1478: 353, 1479: 320, 1480: 883, 1481: 884, 1482: 885, 1483: 886, 1484: 466, 1485: 887, 1486: 179, 1487: 283, 1488: 151, 1489: 890, 1490: 610, 1491: 760, 1492: 56, 1493: 891, 1494: 892, 1495: 893, 1496: 156, 1497: 138, 1498: 472, 1499: 137, 1500: 137, 1501: 299, 1502: 167, 1503: 350, 1504: 237, 1505: 142, 1506: 894, 1507: 110, 1508: 895, 1509: 896, 1510: 4, 1511: 784, 1512: 281, 1513: 182, 1514: 270, 1515: 10, 1516: 897, 1517: 462, 1518: 397, 1519: 898, 1520: 899, 1521: 870, 1522: 900, 1523: 351, 1524: 455, 1525: 435, 1526: 516, 1527: 832, 1528: 598, 1529: 89, 1530: 144, 1531: 902, 1532: 97, 1533: 256, 1534: 903, 1535: 272, 1536: 152, 1537: 904, 1538: 905, 1539: 566, 1540: 309, 1541: 745, 1542: 906, 1543: 90, 1544: 907, 1545: 908, 1546: 499, 1547: 151, 1548: 432, 1549: 542, 1550: 379, 1551: 433, 1552: 27, 1553: 910, 1554: 911, 1555: 912, 1556: 321, 1557: 333, 1558: 7, 1559: 700, 1560: 913, 1561: 106, 1562: 617, 1563: 328, 1564: 915, 1565: 264, 1566: 916, 1567: 917, 1568: 452, 1569: 918, 1570: 919, 1571: 442, 1572: 428, 1573: 438, 1574: 921, 1575: 922, 1576: 63, 1577: 923, 1578: 233, 1579: 924, 1580: 925, 1581: 82, 1582: 926, 1583: 154, 1584: 280, 1585: 474, 1586: 927, 1587: 358, 1588: 929, 1589: 264, 1590: 930, 1591: 124, 1592: 931, 1593: 932, 1594: 246, 1595: 760, 1596: 705, 1597: 933, 1598: 934, 1599: 690, 1600: 143, 1601: 841, 1602: 29, 1603: 935, 1604: 206, 1605: 84, 1606: 291, 1607: 64, 1608: 11, 1609: 937, 1610: 127, 1611: 938, 1612: 939, 1613: 132, 1614: 269, 1615: 940, 1616: 942, 1617: 2, 1618: 156, 1619: 943, 1620: 361, 1621: 944, 1622: 945, 1623: 428, 1624: 946, 1625: 947, 1626: 948, 1627: 949, 1628: 103, 1629: 777, 1630: 950, 1631: 501, 1632: 951, 1633: 419, 1634: 107, 1635: 952, 1636: 953, 1637: 954, 1638: 373, 1639: 955, 1640: 956, 1641: 957, 1642: 958, 1643: 631, 1644: 541, 1645: 959, 1646: 91, 1647: 62, 1648: 99, 1649: 505, 1650: 249, 1651: 8, 1652: 161, 1653: 960, 1654: 226, 1655: 961, 1656: 169, 1657: 388, 1658: 962, 1659: 963, 1660: 105, 1661: 8, 1662: 964, 1663: 30, 1664: 965, 1665: 543, 1666: 14, 1667: 282, 1668: 86, 1669: 348, 1670: 22, 1671: 966, 1672: 141, 1673: 609, 1674: 303, 1675: 106, 1676: 433, 1677: 149, 1678: 967, 1679: 0, 1680: 173, 1681: 223, 1682: 408, 1683: 163, 1684: 970, 1685: 971, 1686: 972, 1687: 973, 1688: 214, 1689: 974, 1690: 975, 1691: 320, 1692: 268, 1693: 784, 1694: 256, 1695: 490, 1696: 114, 1697: 114, 1698: 407, 1699: 217, 1700: 976, 1701: 977, 1702: 978, 1703: 760, 1704: 979, 1705: 520, 1706: 453, 1707: 624, 1708: 558, 1709: 847, 1710: 139, 1711: 981, 1712: 301, 1713: 323, 1714: 56, 1715: 561, 1716: 917, 1717: 982, 1718: 983, 1719: 984, 1720: 647, 1721: 985, 1722: 986, 1723: 110, 1724: 579, 1725: 377, 1726: 987, 1727: 518, 1728: 989, 1729: 990, 1730: 991, 1731: 40, 1732: 925, 1733: 201, 1734: 992, 1735: 76, 1736: 33, 1737: 204, 1738: 994, 1739: 996, 1740: 997, 1741: 998, 1742: 999, 1743: 338, 1744: 22, 1745: 943, 1746: 2, 1747: 13, 1748: 1000, 1749: 516, 1750: 1001, 1751: 1002, 1752: 324, 1753: 371, 1754: 842, 1755: 1003, 1756: 1004, 1757: 1005, 1758: 462, 1759: 19, 1760: 1006, 1761: 1007, 1762: 336, 1763: 299, 1764: 20, 1765: 657, 1766: 1010, 1767: 1011, 1768: 383, 1769: 1012, 1770: 1013, 1771: 1014, 1772: 73, 1773: 426, 1774: 67, 1775: 427, 1776: 1015, 1777: 1016, 1778: 817, 1779: 1017, 1780: 600, 1781: 57, 1782: 276, 1783: 1018, 1784: 1019, 1785: 1020, 1786: 1021, 1787: 1022, 1788: 880, 1789: 1023, 1790: 62, 1791: 164, 1792: 1024, 1793: 805, 1794: 1025, 1795: 21, 1796: 21, 1797: 167, 1798: 397, 1799: 673, 1800: 1027, 1801: 284, 1802: 1030, 1803: 1031, 1804: 1032, 1805: 1033, 1806: 42, 1807: 210, 1808: 101, 1809: 12, 1810: 1034, 1811: 826, 1812: 275, 1813: 1035, 1814: 1036, 1815: 172, 1816: 50, 1817: 242, 1818: 1037, 1819: 182, 1820: 480, 1821: 141, 1822: 188, 1823: 1038, 1824: 1039, 1825: 1040, 1826: 1041, 1827: 3, 1828: 300, 1829: 339, 1830: 780, 1831: 138, 1832: 29, 1833: 75, 1834: 132, 1835: 288, 1836: 777, 1837: 1042, 1838: 1043, 1839: 360, 1840: 1045, 1841: 1048, 1842: 1051, 1843: 343, 1844: 528, 1845: 274, 1846: 27, 1847: 93, 1848: 170, 1849: 1055, 1850: 459, 1851: 18, 1852: 1057, 1853: 667, 1854: 1058, 1855: 181, 1856: 56, 1857: 601, 1858: 1059, 1859: 256, 1860: 1060, 1861: 41, 1862: 103, 1863: 481, 1864: 727, 1865: 403, 1866: 469, 1867: 545, 1868: 1061, 1869: 909, 1870: 377, 1871: 1062, 1872: 921, 1873: 173, 1874: 1063, 1875: 13, 1876: 1064, 1877: 532, 1878: 1065, 1879: 695, 1880: 53, 1881: 96, 1882: 161, 1883: 1067, 1884: 1068, 1885: 398, 1886: 353, 1887: 813, 1888: 866, 1889: 857, 1890: 162, 1891: 1069, 1892: 1070, 1893: 1071, 1894: 1072, 1895: 191, 1896: 10, 1897: 1072, 1898: 743, 1899: 1073, 1900: 480, 1901: 506, 1902: 169, 1903: 1074, 1904: 68, 1905: 585, 1906: 1075, 1907: 833, 1908: 56, 1909: 1076, 1910: 347, 1911: 121, 1912: 1077, 1913: 102, 1914: 905, 1915: 637, 1916: 257, 1917: 1078, 1918: 27, 1919: 452, 1920: 1080, 1921: 1081, 1922: 1082, 1923: 1083, 1924: 1035, 1925: 247, 1926: 1085, 1927: 1086, 1928: 1087, 1929: 1088, 1930: 1089, 1931: 207, 1932: 1090, 1933: 108, 1934: 194, 1935: 1091, 1936: 137, 1937: 55, 1938: 1092, 1939: 1094, 1940: 20, 1941: 855, 1942: 1095, 1943: 389, 1944: 175, 1945: 1096, 1946: 921, 1947: 453, 1948: 79, 1949: 60, 1950: 1097, 1951: 415, 1952: 1098, 1953: 1099, 1954: 1100, 1955: 1101, 1956: 39, 1957: 1102, 1958: 1103, 1959: 1104, 1960: 1105, 1961: 1106, 1962: 1107, 1963: 15, 1964: 1109, 1965: 1110, 1966: 1111, 1967: 23, 1968: 84, 1969: 376, 1970: 21, 1971: 1073, 1972: 245, 1973: 684, 1974: 57, 1975: 1112, 1976: 227, 1977: 54, 1978: 1113, 1979: 1114, 1980: 25, 1981: 1115, 1982: 999, 1983: 455, 1984: 918, 1985: 11, 1986: 292, 1987: 1116, 1988: 1117, 1989: 89, 1990: 1119, 1991: 17, 1992: 810, 1993: 1121, 1994: 166, 1995: 1122, 1996: 83, 1997: 1123, 1998: 64, 1999: 26, 2000: 1125, 2001: 956, 2002: 1126, 2003: 1127, 2004: 1128, 2005: 390, 2006: 1129, 2007: 1130, 2008: 1131, 2009: 1132, 2010: 943, 2011: 758, 2012: 169, 2013: 929, 2014: 171, 2015: 1133, 2016: 1134, 2017: 76, 2018: 178, 2019: 1135, 2020: 272, 2021: 150, 2022: 677, 2023: 1036, 2024: 208, 2025: 1136, 2026: 132, 2027: 33, 2028: 1137, 2029: 249, 2030: 92, 2031: 18, 2032: 445, 2033: 1138, 2034: 1139, 2035: 256, 2036: 27, 2037: 232, 2038: 1140, 2039: 624, 2040: 428, 2041: 393, 2042: 1141, 2043: 1142, 2044: 155, 2045: 1143, 2046: 640, 2047: 1144, 2048: 702, 2049: 500, 2050: 55, 2051: 1145, 2052: 1146, 2053: 1148, 2054: 270, 2055: 515, 2056: 1149, 2057: 1150, 2058: 61, 2059: 151, 2060: 344, 2061: 62, 2062: 197, 2063: 289, 2064: 945, 2065: 157, 2066: 328, 2067: 60, 2068: 1153, 2069: 1154, 2070: 1155, 2071: 1156, 2072: 1157, 2073: 869, 2074: 22, 2075: 513, 2076: 566, 2077: 1158, 2078: 930, 2079: 1159, 2080: 0, 2081: 191, 2082: 717, 2083: 1160, 2084: 137, 2085: 1161, 2086: 1162, 2087: 242, 2088: 338, 2089: 1163, 2090: 76, 2091: 76, 2092: 1164, 2093: 15, 2094: 855, 2095: 91, 2096: 413, 2097: 89, 2098: 1166, 2099: 1167, 2100: 1103, 2101: 637, 2102: 925, 2103: 1169, 2104: 518, 2105: 1170, 2106: 203, 2107: 520, 2108: 826, 2109: 97, 2110: 1171, 2111: 1172, 2112: 1173, 2113: 444, 2114: 30, 2115: 1174, 2116: 1176, 2117: 1177, 2118: 966, 2119: 110, 2120: 556, 2121: 121, 2122: 432, 2123: 832, 2124: 719, 2125: 1033, 2126: 761, 2127: 1178, 2128: 612, 2129: 1179, 2130: 974, 2131: 1180, 2132: 1181, 2133: 267, 2134: 18, 2135: 1182, 2136: 77, 2137: 520, 2138: 1183, 2139: 1184, 2140: 789, 2141: 193, 2142: 243, 2143: 935, 2144: 1185, 2145: 978, 2146: 253, 2147: 1186, 2148: 1188, 2149: 197, 2150: 1189, 2151: 1190, 2152: 14, 2153: 139, 2154: 1191, 2155: 1192, 2156: 1105, 2157: 1193, 2158: 1194, 2159: 273, 2160: 1195, 2161: 937, 2162: 516, 2163: 863, 2164: 280, 2165: 1196, 2166: 204, 2167: 1197, 2168: 1074, 2169: 20, 2170: 1198, 2171: 114, 2172: 852, 2173: 1076, 2174: 770, 2175: 1199, 2176: 30, 2177: 188, 2178: 948, 2179: 575, 2180: 1201, 2181: 372, 2182: 1202, 2183: 339, 2184: 159, 2185: 107, 2186: 1204, 2187: 56, 2188: 657, 2189: 1205, 2190: 1206, 2191: 627, 2192: 1207, 2193: 1208, 2194: 1209, 2195: 650, 2196: 1070, 2197: 1014, 2198: 151, 2199: 1211, 2200: 188, 2201: 299, 2202: 826, 2203: 195, 2204: 490, 2205: 1212, 2206: 1213, 2207: 453, 2208: 1175, 2209: 11, 2210: 1215, 2211: 73, 2212: 1216, 2213: 690, 2214: 154, 2215: 385, 2216: 1217, 2217: 283, 2218: 269, 2219: 543, 2220: 66, 2221: 481, 2222: 1121, 2223: 1218, 2224: 482, 2225: 442, 2226: 138, 2227: 16, 2228: 19, 2229: 586, 2230: 1220, 2231: 39, 2232: 199, 2233: 303, 2234: 1221, 2235: 1222, 2236: 64, 2237: 804, 2238: 4, 2239: 223, 2240: 64, 2241: 416, 2242: 106, 2243: 1223, 2244: 1224, 2245: 1225, 2246: 1226, 2247: 11, 2248: 1227, 2249: 1168, 2250: 182, 2251: 149, 2252: 1228, 2253: 1005, 2254: 1065, 2255: 976, 2256: 163, 2257: 368, 2258: 1229, 2259: 1060, 2260: 1230, 2261: 992, 2262: 1234, 2263: 493, 2264: 1235, 2265: 473, 2266: 1236, 2267: 96, 2268: 1237, 2269: 146, 2270: 1238, 2271: 505, 2272: 1156, 2273: 323, 2274: 1239, 2275: 947, 2276: 369, 2277: 684, 2278: 1088, 2279: 1240, 2280: 1242, 2281: 1243, 2282: 1027, 2283: 1002, 2284: 32, 2285: 121, 2286: 725, 2287: 1244, 2288: 55, 2289: 617, 2290: 1245, 2291: 1138, 2292: 789, 2293: 20, 2294: 1246, 2295: 1247, 2296: 58, 2297: 1248, 2298: 247, 2299: 435, 2300: 330, 2301: 124, 2302: 1250, 2303: 1251, 2304: 542, 2305: 1252, 2306: 397, 2307: 1196, 2308: 925, 2309: 1254, 2310: 1255, 2311: 1180, 2312: 151, 2313: 1256, 2314: 500, 2315: 978, 2316: 166, 2317: 1257, 2318: 1033, 2319: 505, 2320: 646, 2321: 1258, 2322: 1259, 2323: 1260, 2324: 1261, 2325: 1262, 2326: 1263, 2327: 431, 2328: 473, 2329: 1264, 2330: 1265, 2331: 1266, 2332: 1267, 2333: 1268, 2334: 1269, 2335: 1270, 2336: 1036, 2337: 1271, 2338: 1272, 2339: 786, 2340: 226, 2341: 137, 2342: 926, 2343: 1273, 2344: 1274, 2345: 1275, 2346: 1276, 2347: 1277, 2348: 1278, 2349: 1279, 2350: 553, 2351: 1280, 2352: 246, 2353: 229, 2354: 637, 2355: 252, 2356: 909, 2357: 1281, 2358: 1282, 2359: 1283, 2360: 1284, 2361: 1285, 2362: 398, 2363: 516, 2364: 690, 2365: 407, 2366: 1286, 2367: 1287, 2368: 455, 2369: 1288, 2370: 1289, 2371: 1290, 2372: 148, 2373: 85, 2374: 482, 2375: 745, 2376: 1291, 2377: 1090, 2378: 259, 2379: 88, 2380: 88, 2381: 30, 2382: 1293, 2383: 288, 2384: 673, 2385: 852, 2386: 1000, 2387: 433, 2388: 433, 2389: 159, 2390: 1298, 2391: 364, 2392: 1299, 2393: 1300, 2394: 1301, 2395: 1146, 2396: 391, 2397: 377, 2398: 268, 2399: 1104, 2400: 162, 2401: 1303, 2402: 13, 2403: 161, 2404: 322, 2405: 906, 2406: 1304, 2407: 23, 2408: 108, 2409: 171, 2410: 1306, 2411: 292, 2412: 403, 2413: 1307, 2414: 1308, 2415: 545, 2416: 3, 2417: 1240, 2418: 1179, 2419: 1309, 2420: 62, 2421: 684, 2422: 1310, 2423: 948, 2424: 341, 2425: 1221, 2426: 729, 2427: 1313, 2428: 445, 2429: 279, 2430: 1314, 2431: 417, 2432: 1315, 2433: 1316, 2434: 1317, 2435: 163, 2436: 407, 2437: 1318, 2438: 66, 2439: 1319, 2440: 1320, 2441: 20, 2442: 1321, 2443: 1322, 2444: 21, 2445: 1323, 2446: 956, 2447: 1324, 2448: 389, 2449: 900, 2450: 1325, 2451: 1023, 2452: 227, 2453: 33, 2454: 18, 2455: 1327, 2456: 468, 2457: 1102, 2458: 724, 2459: 1328, 2460: 1329, 2461: 1284, 2462: 1330, 2463: 300, 2464: 1331, 2465: 685, 2466: 1332, 2467: 1333, 2468: 1334, 2469: 377, 2470: 1335, 2471: 885, 2472: 1338, 2473: 1339, 2474: 25, 2475: 1340, 2476: 90, 2477: 1341, 2478: 1342, 2479: 15, 2480: 935, 2481: 1343, 2482: 13, 2483: 1344, 2484: 700, 2485: 1345, 2486: 269, 2487: 121, 2488: 1346, 2489: 240, 2490: 1347, 2491: 1348, 2492: 904, 2493: 1140, 2494: 89, 2495: 324, 2496: 1349, 2497: 1350, 2498: 1035, 2499: 1351, 2500: 1043, 2501: 175, 2502: 585, 2503: 444, 2504: 657, 2505: 977, 2506: 1071, 2507: 1352, 2508: 623, 2509: 946, 2510: 197, 2511: 1354, 2512: 428, 2513: 1355, 2514: 1252, 2515: 1356, 2516: 883, 2517: 432, 2518: 447, 2519: 1357, 2520: 556, 2521: 1358, 2522: 1359, 2523: 1360, 2524: 1269, 2525: 1361, 2526: 201, 2527: 1088, 2528: 39, 2529: 1362, 2530: 1196, 2531: 1363, 2532: 393, 2533: 1364, 2534: 1365, 2535: 1366, 2536: 506, 2537: 29, 2538: 1225, 2539: 80, 2540: 727, 2541: 188, 2542: 1239, 2543: 158, 2544: 232, 2545: 81, 2546: 481, 2547: 1367, 2548: 974, 2549: 1368, 2550: 921, 2551: 1369, 2552: 387, 2553: 1370, 2554: 344, 2555: 1179, 2556: 1371, 2557: 930, 2558: 1372, 2559: 379, 2560: 1373, 2561: 505, 2562: 712, 2563: 569, 2564: 207, 2565: 1374, 2566: 197, 2567: 37, 2568: 1375, 2569: 939, 2570: 1376, 2571: 424, 2572: 1194, 2573: 1377, 2574: 1378, 2575: 38, 2576: 20, 2577: 1036, 2578: 1338, 2579: 1380, 2580: 1381, 2581: 989, 2582: 82, 2583: 298, 2584: 1382, 2585: 53, 2586: 1383, 2587: 1384, 2588: 971, 2589: 1385, 2590: 1222, 2591: 1386, 2592: 1258, 2593: 1387, 2594: 1174, 2595: 284, 2596: 314, 2597: 11, 2598: 1389, 2599: 307, 2600: 227, 2601: 45, 2602: 161, 2603: 1137, 2604: 1390, 2605: 1391, 2606: 1392, 2607: 1393, 2608: 1254, 2609: 240, 2610: 1394, 2611: 913, 2612: 1396, 2613: 269, 2614: 675, 2615: 1399, 2616: 382, 2617: 1401, 2618: 1403, 2619: 100, 2620: 1405}

In [180]:
directorArray = np.ndarray(shape=(len(dataset), nb_directors), dtype=int)
for i in range(0, len(dataset)):
    #genreDict.setdefault(i, [])
    
    vector = np.zeros(nb_directors)
    
    #add vectors of 1's and 0's to obtain vector of genres
    vector += (director_dic[i] == np.array(director_list)).astype(int)
    
    #genreDict[i].append(vector)
    directorArray[i] = vector

In [181]:
print(len(directorArray[0]))
print(directorArray.size)


1294
3391574

In [182]:
Directors = pd.DataFrame(directorArray, columns=director_list)
Directors.head(10)


Out[182]:
0 1 2 3 4 5 6 7 8 9 ... 1390 1391 1392 1393 1394 1396 1399 1401 1403 1405
0 1 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
1 0 1 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
2 0 0 1 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
3 0 0 0 1 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
4 0 0 0 0 1 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
5 0 0 0 0 0 1 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 1 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
7 0 0 0 0 0 0 0 1 0 0 ... 0 0 0 0 0 0 0 0 0 0
8 0 0 1 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
9 0 0 0 0 0 0 0 0 1 0 ... 0 0 0 0 0 0 0 0 0 0

10 rows × 1294 columns

Weight matrix computation


In [189]:
W = np.dot(directorArray,np.transpose(directorArray))

In [190]:
np.fill_diagonal(W, 0)

In [191]:
plt.spy(W)


Out[191]:
<matplotlib.image.AxesImage at 0x124dce7f0>

In [192]:
plt.hist(W[W > 0].reshape(-1), bins=50);



In [193]:
print('There are {} edges equal to zero '.format(np.sum(W == 0)/2))
print('There are {} edges equal to one '.format(np.sum(W == 1)/2))


There are 3431569.5 edges equal to zero 
There are 3251.0 edges equal to one 

In [194]:
#Compute degree distribution 
degrees = np.zeros(len(W)) 
for i in range(0, len(W)):
    degrees[i] = sum(W[i])

plt.hist(degrees, bins=50);



In [195]:
NormW = pd.DataFrame(W)
NormW.head()


Out[195]:
0 1 2 3 4 5 6 7 8 9 ... 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620
0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 1 0 ... 0 0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0

5 rows × 2621 columns


In [24]:
W.to_csv('Saved_Datasets/NormalizedDirectorW.csv', index=False)

3. Similartiy between number of movies per director


In [39]:
#Apply nb movie per director to the dataset
mov_per_dir_dataset = []
for i in range(0,len(dataset['director_name'])):
    for j in range(0,len(diff_all_director)):
        if dataset['director_name'][i] == diff_all_director[j]:
            mov_per_dir_dataset.append(freqDir[j])

In [83]:
#W = np.ndarray(shape=(10, 10), dtype=int)
W_diff = np.zeros(shape=(len(dataset), len(dataset)), dtype=int)
for i in range(0,len(dataset)):
    for j in range(i,len(dataset)):
        W_diff[i][j] = abs(mov_per_dir_dataset[i]-mov_per_dir_dataset[j])

In [84]:
print(W_diff)


[[0 2 5 ..., 2 1 2]
 [0 0 7 ..., 0 1 0]
 [0 0 0 ..., 7 6 7]
 ..., 
 [0 0 0 ..., 0 1 0]
 [0 0 0 ..., 0 0 1]
 [0 0 0 ..., 0 0 0]]

In [85]:
bigger = W_diff.transpose() > W_diff
W_diff = W_diff - W_diff*bigger + W_diff.transpose()*bigger
np.fill_diagonal(W_diff, 0)

In [86]:
plt.spy(W_diff)


Out[86]:
<matplotlib.image.AxesImage at 0x143437710>

In [101]:
plt.hist(W_diff.reshape(-1),bins=50);


Weights normalization


In [1]:
val_75 = np.percentile(W_diff,75)
print(val_75)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-d008b8b64128> in <module>()
----> 1 val_75 = np.percentile(W_diff,50)
      2 print(val_75)

NameError: name 'np' is not defined

In [136]:
W_diff_norm = np.zeros(shape=(len(dataset), len(dataset)), dtype=float)
for i in range(0,len(dataset)):
    for j in range(i,len(dataset)):
        if W_diff[i][j] == 0:
            W_diff_norm[i][j] = 1
        elif W_diff[i][j] <= 4:  
            W_diff_norm[i][j] = 1-(W_diff[i][j])/(val_75)
        else:
            W_diff_norm[i][j] = 0

In [137]:
plt.spy(W_diff_norm)


Out[137]:
<matplotlib.image.AxesImage at 0x11dc321d0>

In [138]:
bigger = W_diff_norm.transpose() > W_diff_norm
W_diff_norm = W_diff_norm - W_diff_norm*bigger + W_diff_norm.transpose()*bigger
np.fill_diagonal(W_diff_norm, 0)

In [139]:
plt.spy(W_diff_norm)


Out[139]:
<matplotlib.image.AxesImage at 0x1490e3470>

In [166]:
DiffNormW = pd.DataFrame(W_diff_norm)
DiffNormW.head()


Out[166]:
0 1 2 3 4 5 6 7 8 9 ... 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620
0 0.00 0.5 0.00 0.50 0.25 0.75 0.5 0.75 0.00 0.75 ... 0.75 0.5 0.00 1.00 0.5 0.75 0.5 0.5 0.75 0.5
1 0.50 0.0 0.00 0.00 0.00 0.75 1.0 0.25 0.00 0.25 ... 0.75 1.0 0.00 0.50 1.0 0.75 1.0 1.0 0.75 1.0
2 0.00 0.0 0.00 0.25 0.50 0.00 0.0 0.00 1.00 0.00 ... 0.00 0.0 1.00 0.00 0.0 0.00 0.0 0.0 0.00 0.0
3 0.50 0.0 0.25 0.00 0.75 0.25 0.0 0.75 0.25 0.75 ... 0.25 0.0 0.25 0.50 0.0 0.25 0.0 0.0 0.25 0.0
4 0.25 0.0 0.50 0.75 0.00 0.00 0.0 0.50 0.50 0.50 ... 0.00 0.0 0.50 0.25 0.0 0.00 0.0 0.0 0.00 0.0

5 rows × 2621 columns


In [167]:
DiffNormW.to_csv('Saved_Datasets/DiffNormDirW.csv', index=False)

In [140]:
plt.hist(W_diff_norm.reshape(-1),bins=50);



In [141]:
G = graphs.Graph(W_diff_norm)
G.compute_laplacian('normalized')

In [134]:
len(W_diff_norm)


Out[134]:
2621

In [142]:
G.compute_fourier_basis(recompute=True)
plt.plot(G.e[0:10]);



In [152]:
genres = preprocessing.LabelEncoder().fit_transform(dataset['success'])
G.set_coordinates(G.U[:,1:3])

In [148]:
G.plot_signal(genres, vertex_size=20)



In [153]:
NEIGHBORS = 300

#sort the order of the weights
sort_order = np.argsort(W_diff_norm, axis = 1)

#declaration of a sorted weight matrix
sorted_weights = np.zeros((len(W_diff_norm), len(W_diff_norm)))

for i in range (0, len(W_diff_norm)):  
    for j in range(0, len(W_diff_norm)):
        if (j >= len(W_diff_norm) - NEIGHBORS):
            #copy the k strongest edges for each node
            sorted_weights[i, sort_order[i,j]] = W_diff_norm[i,sort_order[i,j]]
        else:
            #set the other edges to zero
            sorted_weights[i, sort_order[i,j]] = 0

#ensure the matrix is symmetric
bigger = sorted_weights.transpose() > sorted_weights
sorted_weights = sorted_weights - sorted_weights*bigger + sorted_weights.transpose()*bigger

In [154]:
plt.spy(sorted_weights)


Out[154]:
<matplotlib.image.AxesImage at 0x11d044b38>

In [155]:
G_s = graphs.Graph(sorted_weights)
G_s.compute_laplacian('normalized')

In [156]:
G_s.compute_fourier_basis(recompute=True)
plt.plot(G_s.e[0:10]);



In [160]:
G_s.set_coordinates(G_s.U[:,1:3])
G_s.plot_signal(genres, vertex_size=20)



In [161]:
labels_reg = preprocessing.LabelEncoder().fit_transform(dataset['Normed_ROI'])

In [163]:
G_s.plot_signal(labels_reg, vertex_size=20)



In [ ]: