kmeans Update 1.0
- Exported some functions in seperate libaries - Finished the algorithm, added calcCusters function - Optimized code
This commit is contained in:
28
src/algorithms/dmtest.py
Normal file
28
src/algorithms/dmtest.py
Normal 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
|
||||
Reference in New Issue
Block a user