Commit 27821cfb authored by Jonas Boysen's avatar Jonas Boysen
Browse files

add assignments

parent 9a34f27e
Loading
Loading
Loading
Loading

assignment/.gitkeep

deleted100644 → 0
+0 −0

Empty file deleted.

+96 −0
Original line number Diff line number Diff line
%% Cell type:markdown id:00b9a8d4 tags:

# Assignment 7.1

%% Cell type:markdown id:c239dff3 tags:

## DBSCAN

%% Cell type:code id:2e1e8bbc tags:

``` python
###Add your imports here####
import pandas as pd


df = pd.read_csv("A_7_1_dbscan_data.csv")
x = df.to_numpy()

####Add your code here####

####End of your code####
```

%% Cell type:markdown id:10d24df4 tags:

## KMEANS

%% Cell type:code id:1e43bcfb tags:

``` python
###Add your imports here####
import csv
import numpy as np


def read_csv():
    x = []
    y = []
    with open("A_7_1_k_means_data.csv", newline="") as file:
        reader = csv.reader(file, delimiter=",")
        for row in reader:
            x.append([float(row[i]) for i in range(2)])
            y.append(int(row[2]))

    x = np.array(x)
    y = np.array(y)

    return x, y

x, y = read_csv()
####Add your code here####

####End of your code####
```

%% Cell type:markdown id:c30abbce tags:

## PCA

%% Cell type:code id:fb37c99c tags:

``` python
###Add your imports here####
import csv
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import ListedColormap

def visualize(x, y):
    fig, ax = plt.subplots(1, 1)
    colours = ListedColormap(["red", "blue", "green", "black", "teal", "orange"])
    scatter = ax.scatter(x[:, 0], x[:, 1], s=3, c=y, cmap=colours)
    ax.legend(scatter.legend_elements()[0], ["0", "1", "2", "3", "4", "5"])
    plt.show()


def read_csv():
    x = []
    y = []
    with open("A_7_1_pca_data.csv", newline="") as file:
        reader = csv.reader(file, delimiter=",")
        for row in reader:
            x.append([float(row[i]) for i in range(4)])
            y.append(int(row[4]))

    x = np.array(x)
    y = np.array(y)

    return x, y


x, y = read_csv()
####Add your code here####

####End of your code####
```
+429 −0
Original line number Diff line number Diff line
lat,long
0.7408953839010123,0.25680933852140075
0.27657929328231584,0.6042391972134388
0.5920513415310318,0.38910505836575876
0.3688239387639922,0.6636289166492656
0.7393489522958551,0.2079664140882151
0.9788912085368606,0.11980339954897863
0.3566844506283459,0.677145197623789
0.40733008582910296,0.6312717591643044
0.4041599010264437,0.4945730083958074
0.5430294595222827,0.49672332582328316
0.1493852934339832,0.8729264796223687
0.6439341220115193,0.34200286708875494
0.7104306812035966,0.33227524063052044
0.6502744916113439,0.33585910301025296
0.8317482409347507,0.1779643661672861
0.46222840794953657,0.4950849887362889
0.8684759916506343,0.14130657382737355
0.7969535297308078,0.2601884087645769
0.0,0.9998976039308124
0.5279517513335411,0.44194142944815185
0.7906131601309834,0.16342412451361868
0.9249980669630757,0.10147450337902238
0.9829119307179612,0.1142740118765079
0.44923838243544895,0.45207864017949906
0.8037578288132783,0.25496620929603125
0.16252996211078413,0.8637108335027968
0.32072991572053505,0.5650215031729379
0.8631408025974584,0.10086012697117218
0.8625222299575931,0.14673356543065666
0.49161060851894695,0.5468973991395379
0.8104848063088981,0.24984640589667326
0.3375086986771472,0.6960884702015955
0.23428438877468052,0.6850296948584729
0.8585015077709985,0.21103829612928504
0.9669063635639277,0.07331558468164397
0.9241475295736464,0.15973786606469853
0.7541173741591699,0.24605775138220332
0.5308126498107737,0.5089084579147374
0.9751797726756928,0.0
0.5796798886568094,0.4006758140475439
0.33573030232791995,0.5991193938140809
0.08737338591114653,0.931804218717714
0.9720869094543902,0.12779029285285018
0.5551689476524349,0.4839238173239787
0.8032165777492757,0.15134138848953316
0.27472357535173186,0.6500102396055546
0.24936209696342204,0.7805652262955496
0.3535142658311807,0.536657792340822
0.25338281914452254,0.6241040344048395
0.4243408335297851,0.5240630759780739
0.05860975798160145,0.9527954126556275
0.9836851465260339,0.11908662707194079
0.6827495554020568,0.3064714314971741
0.2124797030848252,0.6571779643650195
0.10245109409988805,0.797153389309324
0.4822546972846706,0.42269096866642025
0.4358617490145781,0.465390129019285
0.9516740122179669,0.13956584067119168
0.6568468259497443,0.32981773499911965
0.887419778863257,0.077411427400039
0.5369983762478848,0.5028670899036041
0.8847908451246004,0.19260700389014113
0.2956004020708012,0.6336268687283366
0.04422794401957592,0.965594921154932
0.19485038274427777,0.7199467540440224
0.8511559576300194,0.11161171410855071
0.5213794169951407,0.44654925250884725
0.39031933812842085,0.5517100143349709
0.5723343385158304,0.33585910301025296
0.6817443748554082,0.2477984845383852
0.9808242480488013,0.11755068605231528
0.5530039434019183,0.3551095637919845
0.3702157272119302,0.5704484947780398
0.43632567849722403,0.5146426377219456
0.5394726668238281,0.3681138644278453
0.22979973710543997,0.6448904362061966
0.1807778551021849,0.8425148474301459
0.5246269233736626,0.5156665984029085
0.12580221140039466,0.7736022936708221
0.4111961648529842,0.536657792340822
0.6697595298879693,0.31742781077110904
0.9657465398600598,0.1296334220764008
0.3773293126143333,0.5643047306977189
0.9972164231041241,0.10270325619472279
0.7575968452817617,0.2929551505208318
0.6175674630820549,0.3671922998142511
0.5483646485754584,0.4265820192500778
0.6317173123000105,0.2865041982384047
0.5202195932912727,0.38613557239387647
0.3144668677020673,0.5704484947780398
0.29459522152964657,0.5862174892474077
0.8499961339206574,0.159225885726036
0.2819918039113543,0.5986074134754182
0.5909688394030265,0.4469588367801411
0.5669991494626545,0.41173458939066643
0.2540013917898819,0.6667007986885166
0.41042294904491156,0.48853164038467417
0.3077398902064475,0.5762850706526168
0.9002551612146312,0.0625639975424465
0.5783654217902282,0.32981773499911965
0.7149926544486997,0.27902928527501464
0.8719554627677321,0.2027442146214884
0.824093404468345,0.2378660659417754
0.46563055749077176,0.5668646323983074
0.7715147297611413,0.18124104034309346
0.3941080955709454,0.640999385622539
0.4831052346740999,0.47880401392462074
0.29923451635610643,0.7336678271551021
0.8449702311929083,0.22434978496725203
0.6113817366449438,0.37272168748672185
0.9198948426484759,0.04515666598244662
0.6566148612056744,0.26756092566059825
0.7443748550236042,0.30319475732136675
0.1438181396422314,0.8773295105465078
0.3811953916327205,0.6523653491695867
0.5416376710743447,0.43139463444551074
0.8219284002178284,0.13649395863194067
0.489290961105717,0.4733770223213376
0.9760303100596281,0.12697112430844362
0.2673780252052588,0.7628507065316246
0.62537694270568,0.2916240016377627
0.16222067579085148,0.7469793159930692
0.7238846362003302,0.321523653491323
0.45581071677384943,0.44624206430492214
0.8341452099293373,0.12676633217188724
0.949122400060667,0.022015154617057473
0.9153328694033727,0.10751587139015567
0.25956854558163367,0.6198033995480692
0.9017242712439258,0.11755068605231528
0.8060774762265083,0.20079868932875014
0.6634191602881447,0.3236739709187987
0.3007809479612637,0.5810976858480497
0.46911002860786966,0.43446651648476176
0.07322353668769699,0.9421462215837988
0.9732467331637522,0.12645914396796212
0.7211783808858109,0.27298791726388133
0.1157504059394023,0.7921359819773347
0.47220289182917224,0.560208887977505
0.44173818913175655,0.5110587753422131
0.426428516198945,0.6093590006146158
0.20698987087443005,0.709195166904825
0.6690636356612533,0.2573213188600633
0.35490605427911864,0.5836575875486382
0.09804376401749822,0.8033995494570136
0.7643238227773815,0.2877329510541051
0.7969535297308078,0.1574851525698541
0.7034717389639068,0.33800942043772864
0.20567540400784876,0.8194757321321254
0.7204051650832323,0.2230186360841829
0.9434779246875584,0.08816301453923646
0.3877677259711209,0.646119189021897
0.7476996829834828,0.25087036657763623
0.5979277816427162,0.31138644275997573
0.7606123869162137,0.24042596764236385
0.24062475836901095,0.6789883268473396
0.9713136936518116,0.12881425353199422
0.8955385448068147,0.12113454843204777
0.41367045542343345,0.6241040344048395
0.6968994046255064,0.34384599631230556
0.34237995824767703,0.5928732336663912
0.35042140261537214,0.683596149908035
0.4180777855113173,0.5300020479200196
0.7509471893620047,0.2980749539201898
0.4006804299093458,0.6364939586310312
0.3906286244483535,0.5053245955350049
0.08041444367145677,0.935900061437928
0.7341684064053925,0.26213393405549623
0.5982370679681429,0.383575670693288
0.8977035490628252,0.18257218922798152
0.41676331864473604,0.48310464878139103
0.261578906674931,0.660761826744752
0.6938065414042038,0.24114274011758277
0.6323358849453697,0.4011877943880253
0.6090620892317139,0.4267868113866342
0.15634423567916703,0.7510751587132831
0.3627928554841004,0.5770018431278358
0.7707415139585627,0.28158918697378416
0.6031083275331787,0.4336473479403552
0.32730225005893554,0.5599016997735798
0.9631949277027598,0.07485152570126946
0.458903579989658,0.5739299610885847
0.19268537848826717,0.8299201310673978
0.2805226938820597,0.6450952283427529
0.7086522848543694,0.28425148474174133
0.9172659089153133,0.165369649804538
0.8885796025671249,0.12543518328881811
0.790458516973764,0.2660249846391538
0.7521070130658726,0.19567888592939214
0.2431763705263109,0.7844562768792072
0.7838088610540069,0.2704280155632929
0.9444831052342071,0.1438664755261431
0.9713136936518116,0.12881425353199422
0.3183329467259485,0.7162604955969212
0.7306889352828007,0.31619905795540865
0.13198793783201176,0.7689944706119456
0.8652284852721123,0.2061232848646645
0.2800587643994137,0.7520991193942461
0.6883167091938086,0.24370264181817125
0.5659939689160058,0.34159328281746115
0.4849609526046838,0.550993241859752
0.7648650738413841,0.1864632398116391
0.6140879919594631,0.4189023141501314
0.7274414289042788,0.26704894532011675
0.6046547591438299,0.3783534712265613
0.16832908064660596,0.7442146221577433
0.6371298229345429,0.3481466311690759
0.32335884945369764,0.6113045259055351
0.9617258176789593,0.01003481466215961
0.9883244413524938,0.11314765512999514
0.42936673625753424,0.47184108130171215
0.9713136936518116,0.12881425353199422
0.44212479703304586,0.45822240425982
0.42310368823906647,0.47747286504155156
0.20900023196772732,0.6602498464060895
0.9941235598883156,0.1006553348346158
0.8755122554716807,0.09021093589934344
0.9729374468438196,0.12400163833656133
0.16856104539067596,0.8555191480641878
0.8694811721972828,0.09522834323133271
0.7855872574032342,0.21687487200386196
0.9733240547451089,0.12758550071629382
0.9461841800075718,0.08611509317912948
0.5492151859593938,0.4905795617447811
0.18619036573122338,0.8358591030093435
0.9802829969847986,0.1142740118765079
0.0009278589652919696,1.0
0.8377793242091485,0.22834323162009726
0.03711435861717281,0.9722506655739154
0.11505451171268631,0.9067171820595866
0.3596999922682918,0.5309236125317949
0.33116832908281674,0.7022322342819164
0.36287017706545704,0.6701822650008804
0.2135622052128305,0.7042801556420234
0.1885100131444533,0.7255785377838619
0.4943168638389602,0.40907229162270925
0.3118379339689047,0.7206635265192414
0.14977190134076657,0.7567069424531226
0.6201190752338608,0.41275855007162937
0.9713136936518116,0.12881425353199422
0.06610995129078791,0.9476756092562695
0.9131678651528561,0.051710014334061395
0.09394572024954699,0.9259676428413182
0.30155416376933636,0.6290190456676411
0.39743292353082393,0.545873438458575
0.44823320188880034,0.5058365758754864
0.6385216113824809,0.39586319885211096
0.5731848758997656,0.40630759778738335
0.10013144668665813,0.9203358591032976
0.8786051186874893,0.19772680728949912
0.929792004946755,0.09830022527058371
0.7666434701906114,0.23479418390252438
0.7992731771440378,0.20684005734170235
0.937137555093228,0.03286913782362366
0.6450166241395247,0.38992422690834644
0.9537616948871268,0.0809952897797715
0.3409881697997391,0.5483309440917947
0.4756823629462701,0.4290395248814787
0.24070207995036763,0.6354699979518872
0.9309518286561169,0.15492525086926565
0.7846593984379422,0.1689535121842705
0.5335189051252929,0.3738480442350535
0.7330085826960305,0.21329100962412947
0.9791231732754366,0.1238992422691926
1.0,0.1003481466306907
0.49617258176954415,0.46651648576579774
0.8197633959618178,0.1897399139874465
0.5592669914203862,0.34865861150955735
0.2271708033722774,0.691787835346644
0.6379030387371216,0.28210116731426566
0.21882007268464967,0.8063690354288959
0.3717621588170874,0.5204792135983415
0.7790149230648338,0.223325824288108
0.5547823397511455,0.4219741961893824
0.29289414675628195,0.7403235715740857
0.9501275806073156,0.08304321113987848
0.8399443284651591,0.12195371697645435
0.5151936905580295,0.4511570755677238
0.43934122013717,0.5967642842500488
0.7585247042470538,0.191275855007072
0.8257944792417096,0.18390333811105064
0.9110028608968455,0.17151341388485894
0.6836774143673487,0.355621544132466
0.030542024278772353,0.977472865042461
0.9904894456030103,0.10833503993456226
0.8128817753034846,0.19557648986202342
0.6048094023065433,0.30565226295276754
0.4768421866556321,0.4841286094605351
0.6505064563499199,0.2726807290599562
0.7268228562589194,0.2178988326848249
0.9201268073925459,0.10505836575875487
0.6440887651742327,0.27708375998227636
0.5725663032544064,0.4667212779023541
0.9396118456691713,0.09164448085160022
0.5182092321979754,0.5220151546179669
0.6759452563195864,0.31189842310045723
0.9042758834012258,0.17724759369206713
0.845511482256911,0.11755068605231528
0.3150854403474266,0.6179602703245186
0.12193613237651345,0.8990374769596402
0.6903270702871059,0.349477780052145
0.5858656150939205,0.39483923817296696
0.97695816902492,0.12348965799607985
0.09873965823872018,0.8044235101361576
0.5460450011622285,0.361765308210968
0.12966829041878183,0.8921769404059192
0.8438104074835463,0.16618881834894458
0.5607361014441867,0.4170591849265808
0.676950436866235,0.36197010034752436
0.7135235444194051,0.2281384394835409
0.7456120003088288,0.20284661068885712
0.4200108250232579,0.6169363096453745
0.32923528957087617,0.605160761827033
0.8175210701299445,0.24400983002209634
0.10747699683313125,0.9136801146824952
0.3777159205156226,0.5145402416545769
0.4521766024885442,0.5814048740519748
0.4552694657098468,0.500204792135647
0.8281141266549396,0.13188613557124523
0.10306966674524738,0.8020684005721256
0.20142271708267823,0.7147245545772957
0.34756050413813955,0.5426991603519553
0.33464780019991464,0.5544747081702968
0.7925461996429239,0.21195986074106032
0.9580143818122974,0.13618677042801555
0.01059305652499501,0.994880196600642
0.9106162529955562,0.11140692197381326
0.5008891981773607,0.4029285275442072
0.2684605273332641,0.6551300430067315
0.40462383050908973,0.5409584271957734
0.7022345936731882,0.2895760802776557
0.1434315317409421,0.7623387261929621
0.6754040052610777,0.25250870366463046
0.5045233124571719,0.5378865451565223
0.44575891131285705,0.5892893712884776
0.9713136936518116,0.12881425353199422
0.9595608134229486,0.07761621953659538
0.004098043762457194,0.998976039319037
0.4695739580905156,0.4895556010638182
0.10809556947299653,0.7897808724133026
0.28802288719124614,0.5921564611911723
0.8308203819694587,0.23254147040767995
0.5789066728542308,0.4602703256181081
0.13631794633853897,0.8842924431694164
0.21781489213800104,0.6535941019852871
0.384056290109953,0.5100348146630691
0.9427047088849798,0.028261314764747143
0.8159746385247872,0.1408969895542608
0.25531585865646317,0.7754454228961916
0.5849377561286286,0.32357157485142996
0.6303255238520725,0.3571574851520915
0.8750483259890347,0.1359819782914592
0.3483337199407182,0.5882654106075147
0.2468104848061221,0.6737661273806128
0.5138019021100916,0.3916649600645283
0.6238305110950287,0.3633012492305935
0.23699064408919976,0.7911120212981907
0.969380654139871,0.12799508498758763
0.5666125415613652,0.4723530616421936
0.26134694193086094,0.7689944706119456
0.9864687234219097,0.10833503993456226
0.34392638985832835,0.6899447061230934
0.26575427201874485,0.6144788040139737
0.39743292353082393,0.5007167724761283
0.19871646176266497,0.8259266844145526
0.5100904662489236,0.4549457300840126
0.27348643006101325,0.757218922793604
0.7726745534705033,0.2293671922992413
0.4981056212814847,0.5430063485558804
0.4312224541881182,0.5184312922382345
0.11961648496328352,0.7783125127988862
0.9974483878481941,0.10147450337902238
0.8564911466777012,0.15359410198619652
0.43284620737463214,0.6027032561938134
0.9680661872732896,0.005119803399357992
0.2064486198104274,0.661785787425715
0.8519291734325981,0.2178988326848249
0.30565220753179356,0.7271144788034875
0.6641923760907235,0.37272168748672185
0.6512796721579925,0.3840876510337695
0.18155107090476352,0.7312103215237014
0.8912858578816442,0.18769199262733952
0.8816979819087918,0.08427196395557887
0.24642387690483278,0.6293262338715663
0.7171576587047104,0.32715543723116247
0.9626536766442512,0.13291009625220818
0.8571097193230606,0.10577513823397379
0.6956622593347878,0.2950030718809388
0.6118456661275897,0.3006348556207783
0.9713136936518116,0.12881425353199422
0.1753653444676524,0.7377636698753162
0.8938374700389441,0.06973172230191148
0.28663109873781417,0.7467745238583318
0.5611227093509701,0.4782920335859582
0.9065955308144557,0.056829817733419385
0.2882548519298221,0.6395658406702822
0.7069512100810047,0.2327462625424174
0.2243872264764015,0.8017612123682005
0.9348179076799981,0.09481875895821996
0.990102837701721,0.10342002866994171
0.11459058223004033,0.7829203358577628
0.6577746849150363,0.37886545156522383
0.48851774530313835,0.41572803604351166
0.591278125722959,0.31773499897503416
0.15564834145245102,0.8678066762230108
0.3750096651956093,0.6578947368420573
0.8820845898100811,0.13035019455161972
0.9322662955226981,0.035838623795505946
0.5851697208672046,0.4539217694030497
0.5269465707868924,0.3801966004501119
0.0514188510033357,0.9590415728033171
0.21224773834624922,0.8140487405270235
0.23482563983868315,0.6405898013512452
0.9264671769923704,0.04054884292357011
0.5025902729452313,0.46088470202595827
0.3081264981077368,0.6231824697930642
0.7372612696212011,0.3095433135364251
0.13825098585047957,0.7648986278917316
0.02373772520179592,0.9838214212575195
0.9063635660703857,0.11447880401306428
0.46253769426946917,0.4406102805650827
0.2308049176520886,0.7969485971727676
0.7003015541667416,0.23684210526263136
0.7782417072622551,0.17489248412803507
0.6187272867859228,0.2964366168331956
0.6707647104291239,0.36770428015473255
0.5969226010960675,0.4406102805650827
0.2711667826477833,0.6097685848859096
0.5112502899582857,0.5302068400565759
+800 −0

File added.

Preview size limit exceeded, changes collapsed.

+2500 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading