kmeans Update 1.0

- Exported some functions in seperate libaries
- Finished the algorithm, added calcCusters function
- Optimized code
This commit is contained in:
2018-05-30 23:22:02 +02:00
parent 5f9143b604
commit 77f3a16c45
5 changed files with 96 additions and 78 deletions

28
src/algorithms/dmtest.py Normal file
View File

@@ -0,0 +1,28 @@
# For random generation of numbers import randint
from random import randint, shuffle
# Simple generator for test data (100 plzs, 20-30-50 biased), returns 1D array of plzs
def testgenerator():
dataArray = []
for i in range(0,100):
if i <= 40:
plz = generatePLZ("05")
elif i > 40 and i < 80:
plz = generatePLZ("50")
else:
plz = generatePLZ("")
dataArray.append(plz)
shuffle(dataArray)
return dataArray
# Generates a PLZ from a certain start point
def generatePLZ(start):
if len(start) == 0:
plz = ""
for j in range(1,6):
plz = plz + str(randint(0,9))
else:
plz = start
for j in range(1,4):
plz = plz + str(randint(0,9))
return plz