コード例 #1
0
# Hierarchical clustering
from hierarchical import Hierarchical

# Print lots of stuff
VERBOSE = False

# the input file
inputFile = "ALL-AML-TRANSPOSED.csv"
# the output file
outputFile = "results.txt"
# A CSV file reader
csvReader = CSVReader()

# get the microarray data from the csv file
microarrayData = csvReader.read(inputFile)
microarrayLabels = csvReader.getLabels(inputFile)
print ("File %s parsed succesfully!\n\tRows:\t\t%d\n\tColumns:\t%d" % (inputFile, len(microarrayData), len(microarrayData[0])))
print ("\nLabels: {%s}" % (', '.join(microarrayLabels)))

## k-means algorithm!
# set the k-value (max potential clusters)
k = 3
# holds a reference to a KMeans object 
kmeans = KMeans(verbose=VERBOSE)
# get the clusters determined by the algorithm
kMeansFinalClusters = kmeans.kmeans(microarrayData, k)

## QT algorithm!
# set the diameter for the QT algorithm
diameter = 100000# holds a reference to a QT object 
qt = QT(verbose=VERBOSE)