[Tutor] python clusters

Alan Gauld alan.gauld at btinternet.com
Thu Apr 14 01:51:38 CEST 2011


"nookasree ponamala" <nookasree at yahoo.com> wrote

> I've 30 variables in a text file 

I've no idea what a variable in a text file looks like or means.
variables only make sense inside a program context, in 
a file the only thing that exists is data. You may have 30 values?

> and I want to read this text file and create 10 clusters 
> based on 18 variables.

What is a cluster? I know the general concept but how 
does it relate to programming?

> I want to read an other text file and find the closest 
> match  using these clusters 

Define a class to represent your clusters - whatever they are. 
Write a method of the class to take a value and return a 
comparison score, based on whatever arbnitrary definition 
of closeness you want to use. Call that method to compare 
your value and the cluster and keep track of the minimum
(on the asumption that the value represents "distance" from 
the cluster...)

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list