forked from ML-Challenge/week4-unsupervised-learning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
69 lines (53 loc) · 31.5 KB
/
utils.py
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
import numpy as np
import pandas as pd
from scipy.sparse import csr_matrix
# L1.Clustering for dataset exploration
points = np.array([[0.06544649120573354, -0.7686637583746054], [-1.5290154723631335, -0.4295307892836781], [1.7099337125153655, 0.698852527207745], [1.1677914530353883, 1.0126263823062864], [-1.8011008765125671, -0.3186129561722616], [-1.635678878103174, -0.02859534770489522], [1.2199037530859576, 0.7464346306206472], [-0.2617515511040414, -0.6249293924445927], [-1.6192580392899492, -0.4798394895824938], [-1.843295821844137, -0.16694431084935166], [1.3599960195356797, 0.9499582661886437], [0.42291856473720796, -0.7349534005968037], [-1.6857613901150803, 0.10686727571590626], [0.9062999493855556, 1.0910516186925248], [-1.5647832151997594, -0.8467539409172038], [-0.025784901040515423, -1.1867253939984086], [0.8302732361682478, 1.1450461198177004], [1.224504318044118, 1.3506675856135453], [-0.15394595513245585, -0.7170430090340084], [0.8635880949171804, 1.068246134206403], [-1.433863658847475, -0.2381297048308357], [0.03844768620526845, -0.7463502234351036], [-1.585679224619341, 0.08499354465579917], [0.6359887951357822, -0.5847769797814781], [0.24417242307388476, -0.5317246502745662], [-2.196803585261628, 0.4947367720571247], [1.0323502988225113, -0.5568799954803777], [-0.2885806653720872, -0.39972527763075705], [0.20597008007219075, -0.8017153577365872], [-1.210730799565148, -0.3492410894419737], [1.3342368384681809, 0.7721489008208623], [1.1948015178340623, 1.047885558425092], [0.9917476953726534, 0.8920200767628542], [-1.8356219039361112, -0.04839732479614648], [0.08415720766561488, -0.7156432575403593], [-1.4897017522845528, -0.19299604094122305], [0.3878241808139117, -0.8206011901833663], [-0.014480440773439684, -0.9779840987237762], [-2.0521340998721707, -0.02129125401311013], [0.10331194324225318, -0.8216278059218872], [-0.4418931501740598, -0.6571097360468146], [1.103909263225082, 1.024811819134689], [-1.5922775939582692, -0.17374037962574693], [-1.473441520416564, -0.02202853049685249], [-1.3551470405553263, 0.2297106712795478], [0.04123369958015996, -1.2377662208006797], [0.4761516993039864, -1.136721236563179], [1.043356760427954, 0.8234590470870763], [-0.0796188170335298, -0.8567739353621651], [0.8706505901795596, 1.0805284140253724], [1.4026731334929738, 1.0752511922343315], [0.8011115670043031, 1.283428254742632], [-0.16527515500861514, -1.2358380385590229], [-0.3377922091012056, -0.5919432342243465], [0.8061074868332878, -0.7375215868012956], [-1.4359003186858177, -0.5638444576816151], [0.5486889533068995, -0.9514382937143939], [0.4680313077949052, -0.7497390745187791], [-1.513712896942057, -0.8391432284169498], [0.913843599841932, 1.5112653172575654], [-1.972339030423432, -0.41155374962957947], [0.5213406016331779, -0.8865489365482295], [0.6275949431557073, -1.185904771196431], [0.9416301405581072, 1.3539933545913059], [0.5699476779996157, 1.07036605536564], [-1.8766338206265312, 0.14745773409173726], [0.9061218594658672, 0.9108401052814168], [-1.3748145362460542, 0.28428394728799217], [-1.8056402943668943, -0.9671057419425316], [0.3430775659691717, -0.7999927487937941], [0.7038056620973427, 1.000258041761561], [-1.6848986211185557, -0.3056459496643352], [1.3147322131175057, 0.986149780647387], [0.2615121623829735, -0.2606925092787008], [0.9193121024473212, 0.823714845526499], [-1.2179592899480618, -0.2021967434650836], [-0.1772272310977897, -1.0266524532448829], [0.6482486163633215, -0.6682288060013553], [0.412067864292622, -0.28783784420181835], [1.0156820171676155, 1.1348166724278068], [0.6790025410486296, -0.9148950199813576], [-1.051827471063715, -0.010623762325267516], [0.6130659861093055, 1.7821038376771536], [-1.5021974801612847, -0.5230892170854781], [-1.7271729328459169, -0.4617391574563362], [-1.6099563119906712, -0.1821007032109933], [-1.0911102066045015, -0.07813980218573177], [-0.01046978156325079, -0.8091303412886869], [0.32782303252220457, -0.8073475437162415], [1.220385032027253, 1.195979302100845], [-1.333286810602751, -0.3000193743679564], [0.8795951689645072, 1.1156649125877478], [-1.148290981079215, -0.30400762010005744], [-0.5801975462632827, -1.1999601847068089], [-0.011611594015490669, -0.7846885353997791], [0.17359724107621646, -0.6339814535829698], [1.3273855590403572, 0.6775996875620109], [-1.9346732743106585, 0.30572472057151284], [-1.5776189340196929, -0.2772636496588521], [0.4763900025188839, 1.2142264755806365], [-1.6523750865252471, -0.6803981003840274], [-0.12609976246678, -1.0432745741405829], [-1.8960708245432247, -0.7008550197468331], [0.5746689857995531, 0.748783693306254], [-0.1666031224121718, -0.831102946952984], [0.8013354959100127, 1.2224443484235474], [1.1845542591567533, 1.434646700177676], [1.0886442772018283, 0.6466711158456921], [-1.6115850479861942, 0.2280572487292947], [-1.5751220451660382, -0.09612576005083648], [0.0721356955324795, -0.6964032764653807], [-1.4005429784650547, 0.16390597510235927], [1.0960771260886046, 1.1680469115344367], [-2.5434620433141517, -0.23089821715764086], [-1.3454487471580343, 0.25151125700096744], [-1.3547862853823236, -0.1910331668559034], [0.1836811292599628, -1.1582772499848413], [-1.3136867742972251, -0.3763569984538013], [0.09990128656336106, 1.2250049094266122], [1.1722557441252894, 1.3083514263524965], [0.08653969877007911, -0.7971437137358454], [-0.21053922872177586, -1.1342151077436895], [0.26496023904754856, -0.9476074245480344], [-0.2557591033928975, -1.0626602197221122], [-0.2603975738337485, -0.7477422467984205], [-1.917873593816116, 0.16434571406389192], [0.9302113924561816, 0.4943633069333503], [0.4477046652125147, -0.7287791759929736], [-1.6380286912248638, -0.5892552757456395], [-1.9571276340863957, -0.10125137401907584], [0.9270337011305244, 0.882514226728072], [1.2566009331779366, 0.6082807304621214], [-1.7281863178915309, 0.08416886607685152], [0.3499787973638875, -0.30490298294617035], [-1.516960820018647, -0.5091310892535825], [0.18763604846446186, -0.5542492405318324], [0.8960980862983607, 0.8355150812307898], [-1.5496885650240504, -0.1711478213441832], [1.215745697288779, 1.233177284686227], [0.20307745359011034, -1.0378490610962725], [0.8458908629104305, 1.0361527283579377], [0.5323791878568742, 1.4736288387658585], [-0.05319044083262858, -1.361505529107807], [1.388197431517556, 1.117299153890155], [1.0069630382934158, 1.036772104404645], [0.5668186879625374, -1.0963717575863503], [0.8688829648688388, 1.0524887417163158], [-1.1628660935320507, -0.5587524541922939], [0.27717767905113744, -0.8384401498713722], [0.16563267253352665, -0.8030660737386272], [0.3826330298198334, -0.4268324141890895], [1.1451980736781826, 0.896590262377021], [0.8145585690063701, 0.6753366702240604], [-1.8603152008514652, -0.0953756097092091], [0.9656409952874998, 0.9029557901112318], [-1.4989745116151008, -0.3325404360102928], [-0.13354890109847573, -0.8072758221114568], [0.12541527427567012, -1.1335490643888846], [1.0606243632066137, 1.2881635792978954], [-1.491545784548984, -0.20246410211880406], [1.1618903199872417, 1.2881987698905646], [0.5428203291239563, 0.7520352396594223], [0.8922106508467552, 0.9921162366040982], [-1.4993201058946146, -0.3243066695752808], [0.3166647012635424, -1.3448291507175296], [0.1397246854860243, -1.220974476481136], [-1.5499723960767195, -0.1078258420141638], [1.2384685817822878, 1.3766880413971587], [1.2555895446451386, 0.7202609833504818], [0.2555868919333049, -1.2852976316843507], [0.4516893307622061, -0.5595209318010728], [1.0620205708618238, 1.0340460421826372], [0.6745190801340936, -0.5497029857556341], [0.2275967613293482, -1.0272946849858042], [-1.458352812370112, -0.04951073923368979], [0.2327350078517041, -0.7084926203827929], [1.5967958880334026, 1.1139507626418677], [0.8047610524694737, 0.5446269982211378], [1.1549252092617004, 1.043521906912246], [0.5963277561336563, -1.1914289691414517], [0.02839068319290647, -0.4382936594500548], [1.1345158357541545, 0.5632632979739165], [0.2157620438343024, -1.044457529514499], [1.4104898664048482, 1.0283071932971288], [1.1228930156204953, 0.5802944134502128], [0.25200688174273445, -0.8258843605974264], [-1.2856608057922851, -0.07390909007813573], [1.5284981499353048, 1.1182246872982793], [-0.23907858404898005, -0.7054197249485433], [-0.25792784205946145, -0.8182503454141075], [0.5936781798705313, -0.4523991501399457], [0.07931909469133648, -0.29233213019632065], [-1.2725681463070748, 0.11630576987440865], [0.669301293330272, 1.0073148108513286], [0.34791545789361034, -1.208228767089348], [-2.112839925038438, -0.6689793468549369], [-1.629382396252732, -0.32718221913696793], [-1.5381913876982258, -0.015019717960366831], [-0.11988544731011096, -0.6036338950688659], [-1.54418955684223, -0.30389843747389284], [0.3002661436530568, -0.7772317303459549], [0.009354485200616963, -0.5388819155394995], [-1.3342439259126522, -0.11560430921312267], [0.4750448911523113, 0.7842138380132909], [0.5931326371015391, 1.2322389981754205], [0.413703694582358, -1.3520585677651438], [0.5584094792445969, 0.7883105304005376], [0.4985501752387235, -0.7899490037783341], [0.35675808586971114, -0.8103869319941585], [-1.8619782516712928, -0.5907130477671053], [-1.619776710874009, -0.1607668738067014], [0.8077929471500505, -0.7331129406344682], [1.6274577523743008, 0.6278716346647928], [-1.5699359287017738, -0.08467566885898843], [1.0255856065996505, 0.8938330199548162], [0.24293460986231455, -0.6088253049848489], [1.2313024182884664, 1.00262186248261], [-1.9651013042574703, -0.15886289144686555], [0.42795032119840093, -0.7038443183784787], [-1.5830681762844188, -0.19431922518999764], [-1.571959224996652, 0.014134687055555316], [-0.9814537326582891, 0.06132285389771569], [-1.4863784427733069, -0.5746531036642516], [0.9874582844136752, 0.6918805326527924], [1.2861972092838352, 1.281288207379233], [0.8585059551128833, 0.9554148145127936], [0.19028285631963046, -0.8211294209700777], [0.265610462319974, -0.04255238966504527], [-1.6189789738321865, 0.008623723050546345], [0.24070182637758594, -0.5266420923479008], [1.152209930162803, 0.4391669350892604], [-1.2196781174958202, -0.25803129868336666], [0.33412532725218475, -0.8611776145578867], [0.17131003346811258, -0.7563896476095736], [-1.1982839682225466, -0.7374466455494118], [-0.12245931761906542, -0.4564887912252412], [1.5120069752500735, 0.888257407072307], [1.1033886565948183, 0.9234747873184772], [1.309720948221406, 0.5906698871295553], [0.19964875767967785, 1.1485588868394758], [0.8146051520392743, 0.8453897200875109], [-1.6422739047620531, -0.422962062831202], [0.012243506797408292, -0.21247815863310515], [0.33709102487199016, -0.7461806494867055], [0.4730105400145989, 0.7271207469354536], [0.3470662595395132, 1.2303375668004732], [-0.003932786491855854, -0.9720969390416028], [-1.6430311859446451, 0.05276337015050203], [1.4464962531199248, 1.1421703264724763], [-1.93030086937966, -0.4002614600446369], [-2.3729613540644605, -0.7263364464821149], [0.4586012242999578, -1.060489534287036], [0.4896361019129961, -1.1892831318183212], [-1.0233590198483322, -0.1752057838356285], [-1.3276110716139322, -0.9396354945749504], [-1.509879085473856, -0.09473658216200102], [0.027230566962399616, -0.7987054916040169], [1.0169411977558729, 1.264617008757151], [0.4773352695039988, -0.9898471005648101], [-1.2778422374901173, -0.5474159989810934], [0.4989880164093402, -0.6237259029530492], [1.0600473141462636, 0.8687000769741766], [1.0020750128100304, 1.3829351167050397], [1.3116139353733458, 0.6283395589328151], [1.134284427193519, 1.1834654169384748], [1.2767134615403704, 0.966328781070547], [-0.6334288525144172, -0.977682512557856], [0.1269877885696956, -0.931423170361161], [-1.3451081215324, -0.2375422563556249], [-0.5316227754264695, -1.251535942097754], [0.21959933809083773, -0.9026993798427284], [-1.7899747917891926, -0.12115748411511088], [1.231974725796502, -0.07453764354880478], [1.4163536023718353, 1.2155175194021297], [-1.9028097613580028, -0.16389760152034846], [-0.2244008096180195, -0.7545424755075612], [0.5955941249273331, 0.9241455296828398], [1.219307731244579, 1.081752840147472], [-1.9942753549563843, -0.3758779909018822], [-1.2781847418397052, -0.5245455082345866], [0.6235268908283551, -1.0143010810673632], [0.14024251288742887, -0.4282660048507156], [-0.16145712613074958, -1.1635973109595263], [-1.7479586549697352, -0.06033100879409306], [-1.166597912654541, 0.09023930193838893], [0.411104079705134, -0.8084248985775087], [1.1475716820615272, 0.7780452823812295], [-1.6559074832196319, -0.4010544588749239], [-1.1530686547465177, 0.008586993168223117], [0.6089212149735674, 0.6897483335328548], [-0.08434137552326887, -0.976152563706225], [0.1917005299655985, -0.4233143781546386], [0.2966316166211803, -1.1335739943157594], [-1.3689362766976974, -0.2505212448026501], [-0.08037807115393003, -0.5678415453281473], [0.35695011364327656, -1.150644084910159], [0.024821793764037925, -0.6359482849591866], [-1.4907555757248412, -0.24825069850518605], [-1.4085879959335197, 0.2563543054178052], [-1.9827462594741505, -0.545844746986447]])
new_points = np.array([[0.4002333320265674, -1.2654447065553371], [0.8032303700813846, 1.2826016688170383], [-1.3950755249367135, 0.055729292090629545], [-0.3411926769123959, -1.076619940010254], [1.547817473545126, 1.4025004898994076], [0.24503201753754994, -0.4834423276216081], [1.2070688617175875, 0.8887526050500794], [1.2513262772309852, 1.1555539518148343], [1.810044147829991, 0.9655307305763632], [-1.669634014657854, -0.30810350945803905], [-0.07174821045840446, -0.9379396997933668], [0.6826319270615404, 1.1025816032172124], [1.0903959845516995, 1.4389952903513694], [-1.6764541393208259, -0.5045570492933269], [-1.8444780366259956, 0.045253954376114465], [1.2423485050862004, 1.0208866089127862], [-1.8614704081677675, 0.00638645810856478], [-1.4604494285267078, 0.15325238308363198], [0.4989818169744145, 0.8980060577763966], [0.9839622443099741, 1.0436937477386998], [-1.831367418957484, -0.16363283503661946], [1.3062261736796343, 1.0765871744481543], [0.3534203282015242, -0.7513202179121603], [1.1395797044536962, 1.5450386043690263], [0.2939956935455874, -1.2613500521442478], [-1.145582247220963, -0.037870963554070464], [1.1871610476838488, 0.6002406629352124], [-2.232119462281373, 0.2304750944808799], [-1.2832042998796784, -0.3933145682714113], [0.4942966961525396, -0.8839720087642245], [0.06318349304308901, -0.9119522278514528], [0.9357595389694396, 0.8668206847501292], [1.5801472050501468, 1.0378839166980027], [1.0630495965303597, 1.0270608188286456], [-1.3973253641181504, -0.5051622490313863], [-0.10993523963069728, -0.908113619012788], [1.1734675783939748, 0.9475010921789884], [0.9200845106983088, 1.4576767182024295], [0.5826589564675202, -0.9000868321743926], [0.9527723280673276, 0.8990423859001851], [-1.3726695553001729, -0.031787821490623924], [0.02127067600085084, -0.7076141940283391], [0.3270490517353891, -0.5559981073787117], [-1.7159026735270893, 0.21522226611516804], [0.5125162088827879, -0.7601282452864132], [1.1302346873969018, 0.7224511221624661], [-1.430743100030984, -0.34278751082640724], [-1.8272462496627275, 0.11765777468368645], [1.41801349539704, 1.1145507980398308], [1.2689730355046054, 1.4192597123818338], [0.8040764937373096, 1.6398855683919011], [0.8345677518010617, 1.099566888938277], [-1.2471473202906656, -0.2235223195135434], [-1.294225372060266, 0.08187700243761464], [-0.22737831566090266, -0.4133313867163021], [0.21883038725584325, -0.4681831195396797], [-1.2259341395432908, 0.2555991474864147], [-1.3129403283209065, -0.4288920696757677], [-1.3353238174034492, 0.6520537761945147], [-0.3011002328629553, -1.2515645072433799], [0.20277835613322046, -0.9052774447453354], [1.0135778414771135, 1.1237898051898965], [0.8183243943552136, 0.8608412565444068], [1.2618155625202765, 1.4661374378864431], [0.4648677244304033, -0.7972124589573605], [0.3609088981639311, 0.8441067198291454], [-2.150983103026574, -0.3695839369151511], [1.0500528098687707, 0.8741813644980215], [0.10658007406809468, -0.7492681533935283], [-1.7394572308492744, 0.2521835769814145], [-0.11201768661400867, -0.6524697876040267], [0.5166189510067274, -0.6412675816881157], [0.3266217871239109, -0.8806080148889077], [1.0901775875963506, 1.109525584516946], [0.3644595761914319, -0.6942156216036032], [-1.9077931816808351, 0.18738367404067435], [-1.9560182911330304, 0.139959126119237], [0.3185417014931509, -0.4052717041359056], [0.7365126986835167, 1.7641625460023058], [-1.4417516180120409, -0.057232042866411585], [0.3217571684082834, -0.5342838213080934], [-1.3731730463544376, 0.04644846441285158], [0.06872259098410069, -1.1052294378912342], [0.9593142184469996, 0.6523162095118378], [-1.626419187808163, -0.5624232801807939], [1.0678830524625211, 0.7292604817658017], [-1.7964354693700573, -0.9883074177396988], [-0.09886283766053412, -0.06811980918444828], [-0.10513569966767866, 1.1702214346983502], [0.8799646993015682, 1.253403167715908], [0.9807534068479892, 1.1548653876175397], [-0.08332249663379743, -0.9248443677429224], [0.8487596732932929, 1.0939742455294217], [1.3294164939525177, 1.137345628305919], [0.3237880684751769, -0.7497324512066812], [-1.5261097030195439, -0.24901692884281745], [-1.4859811551413251, -0.2688286079948604], [-1.8047955294480482, 0.18705270020134698], [-2.0190734747511296, -0.4495116509492829], [0.28720240197139146, -0.6554874148914515], [0.8222951016345545, 1.3844323435720964], [-0.03569970357693916, -0.8018258068955944], [-1.6695543980809435, -0.13825850468570902], [-1.7822682110743764, 0.2933530329302973], [0.7258371377839856, -0.6233740238035452], [0.3884325927706244, -0.7612834972221451], [1.49002782668951, 0.7956786712532995], [0.0006554232279744611, -0.7405807019362622], [-1.3453311598066255, -0.4756299369161786], [-0.8038451057116693, -0.3099430125960101], [-0.2490412950059105, -1.0066241847122213], [-1.4109511807922228, -0.0706744126632764], [-1.7511959356833808, -0.30049133577057163], [-1.2794272423458892, 0.17377459990981498], [0.33502818267433954, 0.6247611513773945], [1.1681964908549058, 1.1890225089718274], [0.7152104568601423, 0.9260774191562786], [1.300572781743362, 0.916349564697178], [-1.2169700759337978, 0.1100394768992078], [-1.7070793484711009, -0.05996595355493217], [1.2073065505131004, 1.0548046315261794], [0.18689600860487554, -0.9580472344730616], [0.8034634709748233, 0.38613313957714746], [-1.7348679046802356, -0.14983191338255186], [1.3126149924762784, 1.11802981738963], [0.4049931475801489, -0.51090034730328], [-1.932679684301072, 0.22076469428888174], [0.6560047985146118, 0.9618871607020404], [-1.405882153104396, 0.1171344034664284], [-1.7430626422339452, -0.07474739588180918], [0.5437454124343493, 1.4720922360345101], [-1.973316692928232, -0.22712449341197186], [1.5390117095155558, 1.3604908086817358], [-1.4832345230186001, -0.4903020632514634], [0.3867484837065093, -1.261733998094538], [1.170157157781722, 1.185494153696634], [-0.0805381721060609, -0.32192362738669106], [-0.06822731561561057, -0.8528258870251585], [0.7135000278803649, 1.2786851950310625], [-1.8501437762114057, -0.5034905576730881], [0.06360852657782562, -1.4125703999747332], [1.5296606194895932, 0.9660565718481976], [0.16216571438837646, -1.3737484274059804], [-0.3234744968085503, -0.7066202689006988], [-1.5176899333956642, 0.1876583021123376], [0.8888959113837018, 0.7622371605566541], [0.48316403224714793, 0.8819318692890954], [-0.05529977660045904, -0.7113050163965421], [-1.5796644099147938, -0.6292203127968155], [0.05513086450579202, -0.8472067629036832], [-2.0600158163670144, 0.058769778676059974], [1.1181085496719971, 1.3025417465032032], [0.4870161641475913, -0.9901439374583558], [-1.6551804200375655, -0.16938638279232876], [-1.4434973799529995, 0.190299243117064], [-0.17007454748807474, -0.8267360220133111], [-1.824339789139913, -0.30781462607157506], [1.030934850193869, 1.2645769050131583], [1.6443116943156395, 1.2777311525997004], [-1.4761769264381148, 0.026078387244023254], [1.0095306707588962, 1.1427018140753182], [-1.4528563647019344, -0.25521620652981336], [-1.7409291726803937, -0.08344431770974857], [1.2203829912336142, 1.2869996131495278], [0.916925397059932, 0.7320702754102352], [-0.0016075418496920846, -0.7263755713166965], [0.8938412382881398, 0.8411466431487012], [0.6337919611890583, 1.0091513357290842], [-1.4792707460559875, -0.6997819362786284], [0.05447993735263179, -1.0644197014122958], [-1.5193556824925778, -0.4892769290772026], [0.28993902630874063, -0.7731455226767868], [-0.009681540610637612, -1.1330220710411107], [1.1347463930946602, 0.971541744341109], [0.5364214059773794, -0.8479063881175805], [1.1475986378655694, 0.6899152046491732], [0.5732919022586174, 0.7908027102433104], [0.2123773967237214, -0.6075698078151486], [0.5265795477728625, -0.8159302635461885], [-2.0183164148773765, 0.06786507404223903], [-0.23551262366373565, -1.0820513247221837], [0.15927477956772199, -0.6007172613865557], [0.22812035636194486, -1.1600354896605691], [-1.5365837800714561, 0.08407988075318508], [1.1395460916729012, 0.6317820011520845], [1.0111925531921029, 1.0436080478160479], [-0.14203986668230473, -0.4812303372945994], [-2.231201820617505, 0.08491629053739214], [0.1255548110642637, -1.017947931672471], [-1.7249350918334918, -0.6944261771347984], [-1.6043463038969006, 0.4455508679133457], [0.7371539787409838, 0.9265607436412832], [0.6729052709588117, 1.1336602959159123], [1.200664556764366, 0.7262730934489203], [0.07587472088808289, -0.9833783259664118], [1.2878326230927817, 1.1808860066647064], [1.065219295449487, 1.0071474604016484], [1.058716978914834, 1.129565193019349], [-1.1264340979123897, 0.16678774377085234], [-1.101572175412031, -0.3641378058993379], [0.23511821680542264, -0.1397699490301142], [1.1385379537720148, 1.010185185416075], [0.5312056535944205, -0.8819907915506771], [0.4330859360296099, -0.7640590419867354], [-0.00448926155719931, -1.3054841053771022], [-1.7634858858975817, -0.4974307390604293], [1.3648568100147571, 0.5834046987674564], [0.5669238996877362, 1.5139196303045417], [1.3573682575435084, 0.6709153176202536], [1.07173397131927, 0.6119908837452674], [1.0010691544116854, 0.8938153256093224], [1.33091007084542, 0.8797738791009336], [-1.7960374038799916, -0.0353883973153408], [-1.2722297859037501, 0.4001566415831013], [0.8474806027520546, 1.1703236354150213], [-1.5098912912157934, -0.7123183296610254], [-1.2495357580091535, -0.5578597299906052], [-1.277179730682378, -0.5993505497357117], [-1.81946743441716, 0.7370576727236302], [1.1994986715117046, 1.5696938611171598], [-1.255438466250899, -0.2338928257571077], [-1.6305205810978964, 0.1614558646111886], [1.1061130532991692, 0.7396982244750188], [0.6701931918150288, 0.8705670005920064], [0.36967015614450893, -0.6946453064135064], [-1.2636229292628256, -0.6992492849533154], [-0.3666875074417829, -1.3531025998574808], [0.244032146778522, -0.6594707932203552], [-1.2767914239764049, -0.48545341180964], [0.03774736124308442, -0.6992516050983633], [-2.1914853929412086, -0.4911994999491013], [-0.2932777772250221, -0.5894882119288223], [-1.6573739723897742, -0.2983377855098531], [0.7366388611344399, 0.5780370567291455], [1.1370908117465266, 1.3011975437641738], [-1.4414660113823912, 0.0313934680115914], [0.5923607081206381, 1.225451138247612], [0.6517194143329134, 0.49267489445638396], [0.5945591391812747, 0.8256373151538152], [-1.8790072189725529, -0.5218996262712949], [0.215225040643176, -1.2826985114132357], [0.4991459650764026, -0.6702686338109364], [-1.8295417631450963, -0.33926973062405463], [0.7927214032273834, 1.3378560641922397], [0.9543633716714262, 0.9803966258728768], [-1.353598455664638, 0.1039763401001232], [1.0559506192051886, 0.8070319271614147], [-1.9431101010974, -0.11897696424755992], [-1.3960413695739495, -0.3100959758834197], [1.2897762394609942, 1.0175336493188667], [-1.5950313888468417, -0.540574609207296], [-1.41994045911711, -0.381032569275004], [-0.02355698013966676, -1.1013370175277757], [-1.260385682681977, -0.6932738864756782], [0.9602159807545396, -0.8115536940366752], [0.551803308270898, -1.0179317577818612], [0.3701850851909715, -1.0688546750973675], [0.8255292066733384, 0.8770070597519889], [-1.870325947723697, 0.2875071987566922], [-1.5626076921394083, -0.1891967118876786], [-1.2634654755771513, -0.7747252373004758], [-0.06338004205825187, -0.7594006111349588], [0.8852982802867434, 0.8856205186736593], [-0.14332468573965634, -1.1608367821528174], [-1.8390872522515156, -0.3266555153279336], [0.2747092294908228, -1.045468290017301], [-1.4570357313623459, -0.2918420360744182], [-1.5904884225125158, 0.16606303108184184], [0.9255492842349158, 0.741406406421462], [0.19724546858474468, -0.7807032247389641], [0.2884016972818718, -0.8324255513983669], [0.7241416179667342, -0.7991491997426731], [-1.6265863937272311, -0.18000554338188188], [0.5844815882480341, 1.1319564042970958], [1.0214673158906118, 0.4596577990099158], [0.8650505541075891, 0.9577148872898591], [0.3987177664298797, -1.2427314680567312], [0.8622348918988015, 1.1095556084481029], [-1.3599943045133849, 0.024994265382756148], [-1.1917850535860444, -0.038294632325886896], [1.2939242406012197, 1.103205093863668], [1.256796300232616, -0.7798575815567014], [0.09380403020551704, -0.5532472578192074], [-1.735121753247433, -0.09762716669678152], [0.22315358715490693, -0.9434743514736362], [0.40198909967283897, -1.1096305109671036], [-1.4224415820890841, 0.181914703358554], [0.39247626718270345, -0.8784262773053151], [1.2518187471885425, 0.6936149956889932], [0.017748131656740745, -0.7203042351849521], [-1.877525213291965, -0.2638704239110657], [-1.580636023186551, -0.5504563439340334], [-1.5958949270817768, -0.15393289210602967], [-1.0182977039639498, 0.03885423697922805], [1.2481965891402875, 0.6600418031465439], [-1.2555137688133542, -0.02961720092068407], [-1.4186455928109607, -0.3582301789223188], [0.5257583257407314, 0.8705005425324366], [0.5555999878971989, 1.1876507197090485], [0.028134443916536883, -0.6991113135804631]])
seeds = pd.read_csv('data/Grains/seeds.csv', header=None)
grain = seeds.iloc[:, :-1].values
varieties = ['Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Kama wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Rosa wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat', 'Canadian wheat']
variety_numbers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
grains = np.flip(grain[:,3:5], axis=1)
fish = pd.read_csv('data/fish.csv', header=None)
fish_samples = fish.iloc[:, 1:].values
species = fish.iloc[:, 0].values
stock_movements = pd.read_csv('data/company-stock-movements-2010-2015-incl.csv')
movements = stock_movements.iloc[:, 1:].values
companies = stock_movements.iloc[:, 0].values
eurovision = pd.read_csv('data/eurovision-2016.csv')
eurovision.fillna(0, inplace=True)
eurovision = eurovision.sort_values(by=['From country', 'To country'])
eurovision_samples = eurovision[['From country', 'To country', 'Televote Points']]
eurovision_samples = eurovision_samples.pivot('From country', columns='To country', values='Televote Points')
eurovision_samples.fillna(12, inplace=True)
eurovision_samples = eurovision_samples.values
country_names = eurovision['From country'].unique().tolist()
df_articles = pd.read_csv('data/Wikipedia articles/wikipedia-vectors.csv', index_col=0)
articles = csr_matrix(df_articles.transpose())
titles = list(df_articles.columns)
words = pd.read_csv('data/Wikipedia articles/wikipedia-vocabulary-utf8.txt', header=None).iloc[:, 0].tolist()
leds = pd.read_csv('data/lcd-digits.csv', header=None).values
df_artists = pd.read_csv('data/Musical artists/scrobbler-small-sample.csv')
df_artists = df_artists.pivot(index='artist_offset', columns='user_offset', values='playcount')
df_artists.fillna(0, inplace=True)
artists = csr_matrix(df_artists).toarray()
artist_names = pd.read_csv('data/Musical artists/artists.csv', header=None).iloc[:, 0].tolist()
def how_many_merges(number=0):
if number not in [1,2,3]:
print('Enter 1, 2 or 3 as the answer')
if number == 1:
print('Well done! With 5 data samples, there would be 4 merge operations, and with 6 data samples, there would be 5 merges, and so on.')
if number == 2:
print('Close, but incorrect')
if number == 3:
print('Incorrect. This can actually be known in advance.')
def clusters_linkage_riddle(number=0):
if number not in [1,2,3]:
print('Enter 1, 2 or 3 as the answer')
if number == 1:
print('Think again!')
if number == 2:
print('Not only A!')
if number == 3:
print('Well done!')