Repository: JuliaML/MLUtils.jl
Pull request #19 (2022-01-30 11:00:34)

add data generators and create Datasets module


Patch:
diff --git a/src/Datasets/Datasets.jl b/src/Datasets/Datasets.jl
new file mode 100644
index 0000000..134e33b
--- /dev/null
+++ b/src/Datasets/Datasets.jl
@@ -0,0 +1,17 @@
+module Datasets
+using Random
+using DelimitedFiles: readdlm
+
+include("datasets.jl")
+export load_iris,
+       load_line,
+       load_sin,
+       load_spiral,
+       load_poly
+
+include("generators.jl")
+export make_spiral,
+       make_poly,
+       make_sin
+
+end
\ No newline at end of file
diff --git a/src/Datasets/data/iris.csv b/src/Datasets/data/iris.csv
new file mode 100644
index 0000000..dfe765e
--- /dev/null
+++ b/src/Datasets/data/iris.csv
@@ -0,0 +1,151 @@
+5.1,3.5,1.4,0.2,setosa
+4.9,3.0,1.4,0.2,setosa
+4.7,3.2,1.3,0.2,setosa
+4.6,3.1,1.5,0.2,setosa
+5.0,3.6,1.4,0.2,setosa
+5.4,3.9,1.7,0.4,setosa
+4.6,3.4,1.4,0.3,setosa
+5.0,3.4,1.5,0.2,setosa
+4.4,2.9,1.4,0.2,setosa
+4.9,3.1,1.5,0.1,setosa
+5.4,3.7,1.5,0.2,setosa
+4.8,3.4,1.6,0.2,setosa
+4.8,3.0,1.4,0.1,setosa
+4.3,3.0,1.1,0.1,setosa
+5.8,4.0,1.2,0.2,setosa
+5.7,4.4,1.5,0.4,setosa
+5.4,3.9,1.3,0.4,setosa
+5.1,3.5,1.4,0.3,setosa
+5.7,3.8,1.7,0.3,setosa
+5.1,3.8,1.5,0.3,setosa
+5.4,3.4,1.7,0.2,setosa
+5.1,3.7,1.5,0.4,setosa
+4.6,3.6,1.0,0.2,setosa
+5.1,3.3,1.7,0.5,setosa
+4.8,3.4,1.9,0.2,setosa
+5.0,3.0,1.6,0.2,setosa
+5.0,3.4,1.6,0.4,setosa
+5.2,3.5,1.5,0.2,setosa
+5.2,3.4,1.4,0.2,setosa
+4.7,3.2,1.6,0.2,setosa
+4.8,3.1,1.6,0.2,setosa
+5.4,3.4,1.5,0.4,setosa
+5.2,4.1,1.5,0.1,setosa
+5.5,4.2,1.4,0.2,setosa
+4.9,3.1,1.5,0.2,setosa
+5.0,3.2,1.2,0.2,setosa
+5.5,3.5,1.3,0.2,setosa
+4.9,3.6,1.4,0.1,setosa
+4.4,3.0,1.3,0.2,setosa
+5.1,3.4,1.5,0.2,setosa
+5.0,3.5,1.3,0.3,setosa
+4.5,2.3,1.3,0.3,setosa
+4.4,3.2,1.3,0.2,setosa
+5.0,3.5,1.6,0.6,setosa
+5.1,3.8,1.9,0.4,setosa
+4.8,3.0,1.4,0.3,setosa
+5.1,3.8,1.6,0.2,setosa
+4.6,3.2,1.4,0.2,setosa
+5.3,3.7,1.5,0.2,setosa
+5.0,3.3,1.4,0.2,setosa
+7.0,3.2,4.7,1.4,versicolor
+6.4,3.2,4.5,1.5,versicolor
+6.9,3.1,4.9,1.5,versicolor
+5.5,2.3,4.0,1.3,versicolor
+6.5,2.8,4.6,1.5,versicolor
+5.7,2.8,4.5,1.3,versicolor
+6.3,3.3,4.7,1.6,versicolor
+4.9,2.4,3.3,1.0,versicolor
+6.6,2.9,4.6,1.3,versicolor
+5.2,2.7,3.9,1.4,versicolor
+5.0,2.0,3.5,1.0,versicolor
+5.9,3.0,4.2,1.5,versicolor
+6.0,2.2,4.0,1.0,versicolor
+6.1,2.9,4.7,1.4,versicolor
+5.6,2.9,3.6,1.3,versicolor
+6.7,3.1,4.4,1.4,versicolor
+5.6,3.0,4.5,1.5,versicolor
+5.8,2.7,4.1,1.0,versicolor
+6.2,2.2,4.5,1.5,versicolor
+5.6,2.5,3.9,1.1,versicolor
+5.9,3.2,4.8,1.8,versicolor
+6.1,2.8,4.0,1.3,versicolor
+6.3,2.5,4.9,1.5,versicolor
+6.1,2.8,4.7,1.2,versicolor
+6.4,2.9,4.3,1.3,versicolor
+6.6,3.0,4.4,1.4,versicolor
+6.8,2.8,4.8,1.4,versicolor
+6.7,3.0,5.0,1.7,versicolor
+6.0,2.9,4.5,1.5,versicolor
+5.7,2.6,3.5,1.0,versicolor
+5.5,2.4,3.8,1.1,versicolor
+5.5,2.4,3.7,1.0,versicolor
+5.8,2.7,3.9,1.2,versicolor
+6.0,2.7,5.1,1.6,versicolor
+5.4,3.0,4.5,1.5,versicolor
+6.0,3.4,4.5,1.6,versicolor
+6.7,3.1,4.7,1.5,versicolor
+6.3,2.3,4.4,1.3,versicolor
+5.6,3.0,4.1,1.3,versicolor
+5.5,2.5,4.0,1.3,versicolor
+5.5,2.6,4.4,1.2,versicolor
+6.1,3.0,4.6,1.4,versicolor
+5.8,2.6,4.0,1.2,versicolor
+5.0,2.3,3.3,1.0,versicolor
+5.6,2.7,4.2,1.3,versicolor
+5.7,3.0,4.2,1.2,versicolor
+5.7,2.9,4.2,1.3,versicolor
+6.2,2.9,4.3,1.3,versicolor
+5.1,2.5,3.0,1.1,versicolor
+5.7,2.8,4.1,1.3,versicolor
+6.3,3.3,6.0,2.5,virginica
+5.8,2.7,5.1,1.9,virginica
+7.1,3.0,5.9,2.1,virginica
+6.3,2.9,5.6,1.8,virginica
+6.5,3.0,5.8,2.2,virginica
+7.6,3.0,6.6,2.1,virginica
+4.9,2.5,4.5,1.7,virginica
+7.3,2.9,6.3,1.8,virginica
+6.7,2.5,5.8,1.8,virginica
+7.2,3.6,6.1,2.5,virginica
+6.5,3.2,5.1,2.0,virginica
+6.4,2.7,5.3,1.9,virginica
+6.8,3.0,5.5,2.1,virginica
+5.7,2.5,5.0,2.0,virginica
+5.8,2.8,5.1,2.4,virginica
+6.4,3.2,5.3,2.3,virginica
+6.5,3.0,5.5,1.8,virginica
+7.7,3.8,6.7,2.2,virginica
+7.7,2.6,6.9,2.3,virginica
+6.0,2.2,5.0,1.5,virginica
+6.9,3.2,5.7,2.3,virginica
+5.6,2.8,4.9,2.0,virginica
+7.7,2.8,6.7,2.0,virginica
+6.3,2.7,4.9,1.8,virginica
+6.7,3.3,5.7,2.1,virginica
+7.2,3.2,6.0,1.8,virginica
+6.2,2.8,4.8,1.8,virginica
+6.1,3.0,4.9,1.8,virginica
+6.4,2.8,5.6,2.1,virginica
+7.2,3.0,5.8,1.6,virginica
+7.4,2.8,6.1,1.9,virginica
+7.9,3.8,6.4,2.0,virginica
+6.4,2.8,5.6,2.2,virginica
+6.3,2.8,5.1,1.5,virginica
+6.1,2.6,5.6,1.4,virginica
+7.7,3.0,6.1,2.3,virginica
+6.3,3.4,5.6,2.4,virginica
+6.4,3.1,5.5,1.8,virginica
+6.0,3.0,4.8,1.8,virginica
+6.9,3.1,5.4,2.1,virginica
+6.7,3.1,5.6,2.4,virginica
+6.9,3.1,5.1,2.3,virginica
+5.8,2.7,5.1,1.9,virginica
+6.8,3.2,5.9,2.3,virginica
+6.7,3.3,5.7,2.5,virginica
+6.7,3.0,5.2,2.3,virginica
+6.3,2.5,5.0,1.9,virginica
+6.5,3.0,5.2,2.0,virginica
+6.2,3.4,5.4,2.3,virginica
+5.9,3.0,5.1,1.8,virginica
+
diff --git a/src/Datasets/data/line.csv b/src/Datasets/data/line.csv
new file mode 100644
index 0000000..cd84935
--- /dev/null
+++ b/src/Datasets/data/line.csv
@@ -0,0 +1,11 @@
+0.0,1.03262
+0.1,1.06073
+0.2,1.15507
+0.3,1.08
+0.4,1.25422
+0.5,1.22779
+0.6,1.28097
+0.7,1.29575
+0.8,1.40697
+0.9,1.42855
+1.0,1.49955
diff --git a/src/Datasets/data/poly.csv b/src/Datasets/data/poly.csv
new file mode 100644
index 0000000..d6ae3a9
--- /dev/null
+++ b/src/Datasets/data/poly.csv
@@ -0,0 +1,50 @@
+0,2.223419553338138
+.1,1.7805726892633231
+.3,-5.716829441083398
+.5,-.682058107638464
+.55,2.6763063434621097
+.55,9.37104004480659
+.6,11.391379488443846
+.65,-6.9671916547758
+.85,8.61376304175232
+1,9.19934019056284
+1.1,-.1750124009411449
+1.1,2.7361201785948457
+1.1,4.5042666887166325
+1.15,5.206292739456437
+1.2,4.2914681957733
+1.4,.3102710324198741
+1.4,3.040208370559652
+1.45,6.9270382127457095
+1.55,4.411123203587441
+1.6,12.889767390299745
+1.7,2.904950813095579
+1.75,12.318025326620523
+1.75,15.260346743887172
+1.85,10.980027985914617
+1.9,16.543741597752494
+2.05,7.055541109038335
+2.05,9.839638662319805
+2.35,7.512008254835029
+2.35,18.230218775218162
+2.4,14.923226956484182
+2.4,17.45984102210545
+2.5,18.51285541655192
+2.8,27.41083128398315
+2.95,23.42324788828631
+2.95,24.45928754030199
+3,22.953228243417506
+3,29.42005014077799
+3.35,28.74127495362708
+3.35,39.67036546504957
+3.4,33.935234200494904
+3.45,36.886434778461975
+3.55,30.71131816420634
+3.6,42.37800594176847
+3.75,40.15207973743326
+3.85,36.22015324378707
+3.9,52.58788879504117
+3.95,39.9730048603351
+3.95,42.27720198008184
+3.95,44.00878946378536
+4,42.07191540399073
diff --git a/src/Datasets/data/sin.csv b/src/Datasets/data/sin.csv
new file mode 100644
index 0000000..aaffe48
--- /dev/null
+++ b/src/Datasets/data/sin.csv
@@ -0,0 +1,15 @@
+0.0,0.0204103
+0.448799,0.435274
+0.897598,0.747859
+1.3464,0.832367
+1.7952,1.0575
+2.24399,0.695844
+2.69279,0.522679
+3.14159,-0.0496367
+3.59039,-0.42627
+4.03919,-0.525765
+4.48799,-0.849164
+4.93679,-0.866368
+5.38559,-0.808921
+5.83439,-0.558357
+6.28319,0.0494465
diff --git a/src/Datasets/data/spiral.csv b/src/Datasets/data/spiral.csv
new file mode 100644
index 0000000..213bf53
--- /dev/null
+++ b/src/Datasets/data/spiral.csv
@@ -0,0 +1,194 @@
+0.03645959152196413,6.446865485598094,1
+1.1385050875226623,6.139478772640795,1
+2.486197686890597,5.811586154431765,1
+3.414861686545728,5.151489027338726,1
+4.340193282182579,4.363860209039293,1
+5.0611771299459765,3.5041753253301704,1
+5.56930345595983,2.38161596203082,1
+5.984007971086329,1.2200892559103682,1
+5.7071524481637566,-0.047833736596034425,1
+5.797270683536632,-0.9720634478739789,1
+5.505287112957243,-2.180206753614093,1
+4.7151575332549545,-3.310402985829317,1
+4.109488535814551,-4.035161343598505,1
+3.143799480954868,-4.791577326894877,1
+2.1438215915786096,-5.178683833202409,1
+1.1047783415913859,-5.5665685261834925,1
+-0.03367444685585712,-5.523109464515866,1
+-1.2968136802043682,-5.244900978313944,1
+-1.9211209213786589,-4.93107511524941,1
+-3.259129026103086,-4.314053890627883,1
+-3.8331359169665458,-3.5454441256017826,1
+-4.290570203910764,-2.7318935289087785,1
+-4.6819050827028645,-2.081313229436072,1
+-5.0989505852416475,-1.0308783802520847,1
+-5.012166737983614,-0.03784550108155144,1
+-4.890600036636378,1.0258283640377137,1
+-4.625585698836164,1.786121515805461,1
+-3.94075777585929,2.6353548284013395,1
+-3.1450559978433565,3.3717065609779975,1
+-2.6805378518219882,3.8935580438598762,1
+-1.6627930532003274,4.229849743044041,1
+-0.9473718412609237,4.291730774911536,1
+0.28362285913734375,4.4111445464835235,1
+0.9485044271234938,4.215389431859368,1
+1.545954703253828,4.070733605302977,1
+2.557598288458158,3.4732389728602624,1
+3.2122957053801864,2.984711969789745,1
+3.243332417456673,2.472930580343431,1
+3.844879351450337,1.5734987918170222,1
+3.84989403600886,0.7354550500098099,1
+4.052393568291256,0.0506454997567472,1
+3.968968937841058,-0.7377560560666326,1
+3.591729735077906,-1.489694381442196,1
+3.2309977182171448,-2.177007459717478,1
+2.6275222437980226,-2.6504464361590987,1
+2.1240004981816636,-3.131377608858162,1
+1.2555944820211433,-3.309456404757145,1
+0.7685342120202895,-3.5132784076818937,1
+0.21245413729309837,-3.5138961671856808,1
+-0.5544381661496699,-3.3096813726580923,1
+-1.2280672694156636,-2.979932542968411,1
+-1.871162628074335,-2.773911719414717,1
+-2.438311197774279,-2.190338223194375,1
+-2.716557800032341,-1.8282852298536885,1
+-2.8287196668757724,-1.1353544559768542,1
+-2.9090944026924004,-0.553339438888888,1
+-2.91315835469628,-0.14022218189458582,1
+-2.8907261708406593,0.4834880734902385,1
+-2.7369088934121892,0.9918833589191767,1
+-2.444383293731387,1.4365586936474097,1
+-2.0261328724068988,1.99490691860646,1
+-1.4881260254887279,2.1899286155079247,1
+-1.0020092958191689,2.3493591931690485,1
+-0.3527180953104062,2.4209941550678793,1
+0.004583835229828053,2.3038522359254014,1
+0.38803420611981976,2.483350450302998,1
+0.7730569728222585,2.2284484245933927,1
+1.2043500922954167,1.8812898364383865,1
+1.4491754230420169,1.565663519335673,1
+1.7209185480292426,1.3125321835423935,1
+1.8476681192814444,0.7870725995089145,1
+1.718991806021823,0.2631180276989003,1
+2.142060497297383,0.014728311282183293,1
+2.116553019935831,-0.5734708426476491,1
+1.4601372503237726,-0.6815487972835923,1
+1.4713446307972695,-0.9771475130360784,1
+1.2382262480578434,-1.1099394142207542,1
+0.930211670212059,-1.3555327382484983,1
+0.5781468364270642,-1.4182850421105055,1
+0.2465877768888984,-1.4134212027145954,1
+-0.1975727988801421,-1.4506436679214991,1
+-0.4874125439516556,-1.4442901931387027,1
+-0.43952076346756697,-1.361968102136069,1
+-0.7624283759348323,-1.1383332189259625,1
+-0.8901184337263252,-0.7668536960367816,1
+-1.0399289179247864,-0.684216253651134,1
+-0.9858046727676586,-0.6319399988147192,1
+-1.0439325759037956,-0.19856233217979702,1
+-0.8829153526589755,-0.05206607236926327,1
+-1.0243327762581587,0.07857233511809962,1
+-0.8777949275052733,0.29344646056759266,1
+-0.47099062599248,0.6109830000778593,1
+-0.7182034012028695,0.5676541998267801,1
+-0.38351190050077544,0.5982298599699696,1
+-0.16782819435626106,0.5224015649909731,1
+0.030637530041537867,0.5052246471584865,1
+-0.044621480238351184,0.5354919355347961,1
+-0.03767487640571351,-6.577667284801569,0
+-1.2487757642793196,-6.26916041851351,0
+-2.407712105411157,-5.962108219108039,0
+-3.5469746617981888,-5.091617970446876,0
+-4.3999501785445485,-4.473570698677982,0
+-5.227517267516643,-3.4826742035294735,0
+-5.734597174440115,-2.1876051467871203,0
+-6.0668481165997035,-1.4549632664913603,0
+-5.983348806051909,-0.1425511875761164,0
+-5.813142569952833,1.1846843842383263,0
+-5.487594877816482,2.364707015463829,0
+-4.684209893471426,3.1108250332960816,0
+-4.112624570717741,3.988390785829909,0
+-3.209277365504515,4.594997410122987,0
+-2.366972499729198,5.24586656601035,0
+-0.9836997830122446,5.483714175810774,0
+-0.014386288781629713,5.274614070807892,0
+1.0053293840256368,5.2875795650495,0
+2.154672198864051,4.990716096821039,0
+3.1838936167035623,4.255617538118133,0
+3.6748008376085832,3.8702363632848678,0
+4.291952558224686,3.015105613686358,0
+4.6747270900260585,2.0170677924494473,0
+5.028146244132899,0.9925965373073113,0
+5.01795660490613,-0.03902229708680274,0
+4.687885786250179,-0.7017880311486282,0
+4.557242687842707,-1.8886150314598056,0
+3.989661644817355,-2.620060057277587,0
+3.5247858969663466,-3.2920925572988224,0
+2.6138757780209314,-4.065424412806843,0
+1.8581674943179618,-4.197807304540974,0
+0.8782468821473064,-4.699689888818971,0
+0.01945217509519937,-4.704537499025092,0
+-0.6941180268858422,-4.356342986393793,0
+-1.6823335377314668,-4.153919965282444,0
+-2.3125855396590285,-3.4900792059563743,0
+-3.0024437376356254,-2.986956356232634,0
+-3.5070492031967575,-2.362182981500119,0
+-3.6142408958103642,-1.4776393125499083,0
+-3.9736388398992317,-0.7303745777833702,0
+-3.876749535646581,-0.05508360584274651,0
+-3.745485116233096,0.7330359466460191,0
+-3.591998843422483,1.4000096552557262,0
+-3.119736618801921,2.0041951542314695,0
+-2.557195760245553,2.8036907764326493,0
+-2.106778165665475,3.2138049969715388,0
+-1.3871801109393913,3.2741198393589026,0
+-0.656174427161494,3.4680260945283257,0
+-0.06491605238105108,3.6101633770499686,0
+0.7072557694751102,3.2433784673235437,0
+1.3461572222724776,3.0953832620026582,0
+1.8003814303875403,2.8322579161258514,0
+2.5691209099189853,2.3720134234230836,0
+2.597745782114411,1.9263917346055048,0
+3.064381674974615,1.0999471936508303,0
+2.959231732823652,0.6984223335295836,0
+2.994297956170136,-0.05157107308788926,0
+2.781104792879222,-0.4847292967712263,0
+2.7594648352316495,-1.2558363204522167,0
+2.385299763256989,-1.573963548887906,0
+1.9413779591444402,-2.0267645399706917,0
+1.4171426879546938,-2.353979262233314,0
+0.9499911900667156,-2.342976428758056,0
+0.5276615650072684,-2.7870730314867673,0
+0.056346070271238724,-2.3440889957513535,0
+-0.6548002550640362,-2.5236858493545227,0
+-0.9732235492479465,-2.1298963957992223,0
+-1.2218163246776068,-2.0213657510719396,0
+-1.4230298584251586,-1.8552559132234805,0
+-1.8707462743948813,-1.0678564220674318,0
+-2.002773550371381,-0.6330664648651575,0
+-1.9729183288118066,-0.4643387966189494,0
+-2.1738927848372436,-0.05604185048777541,0
+-1.9258202466104792,0.5449603620596802,0
+-1.8001744817698067,0.760135958118092,0
+-1.6126948866911273,1.1043051807563449,0
+-1.3964119936924297,1.1232183596417347,0
+-0.8235807558107759,1.3146673997545977,0
+-0.7567765581315652,1.5248284765602582,0
+-0.23914819212695215,1.4374405230513945,0
+-0.0701656252087004,1.5545468411806624,0
+0.2977546581062651,1.4098219273842751,0
+0.598310547877217,1.3359209383081032,0
+0.6902032178842633,1.120381755139589,0
+0.8843231533282643,0.6912475142563765,0
+0.8975589301916075,0.619501563725524,0
+1.086856387915531,0.35052844519757603,0
+1.0307619593294122,0.16833307815793896,0
+0.9662373172878931,-0.14042691777491878,0
+1.095836163807614,-0.12617344300991024,0
+0.9439805386267052,-0.3990632673836936,0
+0.8431966938125245,-0.3444536539443845,0
+0.3899868332685462,-0.6146235957991091,0
+0.5347233507612342,-0.5869369798959582,0
+0.12946277621212438,-0.7229554224702195,0
+-0.0937043886808482,-0.7796400307725091,0
+0.21291581143026447,-0.49197059275398286,0
diff --git a/src/datasets.jl b/src/Datasets/datasets.jl
similarity index 98%
rename from src/datasets.jl
rename to src/Datasets/datasets.jl
index f3e2adf..6885edd 100644
--- a/src/datasets.jl
+++ b/src/Datasets/datasets.jl
@@ -1,4 +1,4 @@
-DATAPATH = joinpath(@__DIR__, "..", "data")
+DATAPATH = joinpath(@__DIR__, "data")
 
 """
     load_iris() -> X, y, names
diff --git a/src/Datasets/generators.jl b/src/Datasets/generators.jl
new file mode 100644
index 0000000..8cf28c4
--- /dev/null
+++ b/src/Datasets/generators.jl
@@ -0,0 +1,66 @@
+
+"""
+    make_sin(n, start, stop; noise = 0.3, f_rand = randn) -> x, y
+
+Generates `n` noisy equally spaces samples of a sinus from `start` to `stop`
+by adding `noise .* f_rand(length(x))` to the result of `fun(x)`.
+"""
+function make_sin(n::Int = 50, start::Real = 0, stop::Real = 2π; noise::Real = 0.3, f_rand::Function = randn)
+    x = collect(range(start, stop=stop, length=n))
+    y = sin.(x) .+ noise  .* f_rand.()
+    return x, y
+end
+
+"""
+    make_poly(coef, x; noise = 0.01, f_rand = randn) -> x, y
+
+Generates a noisy response for a polynomial of degree `length(coef)`
+using the vector `x` as input and adding `noise .* f_randn(length(x))` to the result.
+The vector `coef` contains the coefficients for the terms of the polynome.
+The first element of `coef` denotes the coefficient for the term with
+the highest degree, while the last element of `coef` denotes the intercept.
+"""
+function make_poly(coef::AbstractVector{R}, x::AbstractVector{T}; 
+                noise::Real = 0.1, f_rand::Function = randn) where {T<:Real,R<:Real}
+    n = length(x)
+    m = length(coef)
+    x_vec = collect(x)
+    y = zeros(n)
+    @inbounds for i = 1:n
+        for k = 1:m
+            y[i] += coef[k] * x_vec[i]^(m-k)
+        end
+    end
+    y .+= noise .* f_rand.()
+    x_vec, y
+end
+
+
+"""
+    make_spiral(n, a, theta, b; noise = 0.01, f_rand = randn) -> x, y
+
+Generates `n` noisy responses for a spiral with two labels. Uses the radius, angle
+and scaling arguments to space the points in 2D space and adding `noise .* f_randn(n)`
+to the response.
+"""
+function make_spiral(n::Int = 97, a::Real = 6.5, theta::Real = 16.0, b::Real=104.0; 
+                noise::Real = 0.1, f_rand::Function = randn)
+    x = zeros(Float64, (2, 2*n))
+    y = zeros(Int, 2*n)
+    index = 0:1.0:(n-1)
+    for i = 1:n
+        _angle = index[i]*pi/theta
+    	_radius = a * (b-index[i]) / b
+    	x_coord = _radius * sin(_angle)
+    	y_coord = _radius * cos(_angle)
+    	x[1, i] = x_coord
+    	x[2, i] = y_coord
+        x[1, n+i] = -(x_coord)
+    	x[2, n+i] = -(y_coord)
+        y[i] = 1
+        y[n+i] = 0
+    end
+    x[1, :] .+= noise .* f_rand.()
+    x[2, :] .+= noise .* f_rand.()
+    x, y
+end
\ No newline at end of file
diff --git a/src/MLUtils.jl b/src/MLUtils.jl
index 48edd74..115a0e3 100644
--- a/src/MLUtils.jl
+++ b/src/MLUtils.jl
@@ -1,7 +1,6 @@
 module MLUtils
 
 using Random
-using DelimitedFiles: readdlm
 import StatsBase: sample
 
 include("utils.jl")
@@ -39,11 +38,6 @@ export labelmap,
         oversample,
         undersample
 
-include("datasets.jl")
-export load_iris,
-       load_line,
-       load_sin,
-       load_spiral,
-       load_poly
+include("Datasets/Datasets.jl")
 
 end


Test patch:
diff --git a/test/datasets.jl b/test/Datasets/datasets.jl
similarity index 100%
rename from test/datasets.jl
rename to test/Datasets/datasets.jl
diff --git a/test/Datasets/generators.jl b/test/Datasets/generators.jl
new file mode 100644
index 0000000..f3a3cf7
--- /dev/null
+++ b/test/Datasets/generators.jl
@@ -0,0 +1,30 @@
+@testset "make_sin" begin
+    n = 50
+    xtmp, ytmp = make_sin(n; noise = 0.)
+
+    @test length(xtmp) == length(ytmp) == n
+    for i = 1:length(xtmp)
+        @test sin.(xtmp[i]) ≈ ytmp[i]
+    end
+    # print(scatterplot(xtmp, ytmp; color = :blue, height = 5))
+end
+
+@testset "make_poly" begin
+    coef = [.8, .5, 2]
+    xtmp, ytmp = make_poly(coef, -10:.1:10; noise = 0)
+
+    @test length(xtmp) == length(ytmp)
+    for i = 1:length(xtmp)
+        @test (coef[1] * xtmp[i]^2 + coef[2] * xtmp[i]^1 + coef[3]) ≈ ytmp[i]
+    end
+    # print(scatterplot(xtmp, ytmp; color = :blue, height = 5))
+end
+
+@testset "make_spiral" begin
+    n = 97
+    xtmp, ytmp = make_spiral(n; noise = 0.)
+
+    @test length(xtmp[1, :]) == length(ytmp) == 2*n
+    # test_plot = scatterplot(xtmp[1, 1:97], xtmp[2, 1:97], title="Spiral Function", color=:blue, name="pos")
+    # print(scatterplot!(test_plot, xtmp[1, 98:194], xtmp[2, 98:194], color=:yellow, name="neg" ))
+end
diff --git a/test/runtests.jl b/test/runtests.jl
index 89eafa7..40958a0 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -1,4 +1,5 @@
 using MLUtils
+using MLUtils.Datasets
 using SparseArrays
 using Random, Statistics
 using Test
@@ -45,6 +46,7 @@ MLUtils.getobs(::CustomType, i::AbstractVector) = collect(i)
 @testset "dataiterator" begin; include("dataiterator.jl"); end
 @testset "folds" begin; include("folds.jl"); end
 @testset "resample" begin; include("resample.jl"); end
-@testset "datasets" begin; include("datasets.jl"); end
+@testset "Datasets/datasets" begin; include("Datasets/datasets.jl"); end
+@testset "Datasets/generators" begin; include("Datasets/generators.jl"); end
 
 # end