Re: [Tutor] Cluster algorithms
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Are there any example programs depicting Clustering algorithms such as agglomerative, complete link, partional , squared error clustering, k-means or clustering algos based on Neural networks or genetic algorithm. although I just learned python, (to major extent in programming also), I need to apply some of these algos to my data. Any suggestions/recommendations? Have you looked at the orange machine learning tool kit, many clustering, classification and learning tools are implemented in this package. PLus it has a nice widget style interface now where you can build your own tools. (if you like to use widgets, or you can just write you own code calling it). Its all GPL and its pretty fantastic stuff. http://magix.fri.uni-lj.si/orange/ good luck kim Dr Kim Branson Diffraction and Theory CSIRO Health Sciences and Nutrition 343 Royal Parade, Parkville Melbourne Ph +613 9662 7136 [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (Darwin) iD8DBQFB+P+Oer2hmGbHcokRApb0AJ91FNkREGPCawfRFQqP4/HcDp+QEACfTSTO VxKX/E3bY/Y8WKCHOM+ydQU= =fEya -END PGP SIGNATURE- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] rounding
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi all, heres a quick one for you, I have a series of data that I am using dictionaries to build histograms for. I'd like to round the data to the nearest 10, i.e if the value is 15.34 should we round down to 10? and conversely rounding say 19.30 to 20. I'm thinking 15.5 and above would round up. Can anyone point me a at a quick and painless way of achieving this? cheers Kim -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (Darwin) iD8DBQFB/Uo9er2hmGbHcokRAroEAJ9ALQrg7Ku3K62RNiFy0HUki6LjZwCeL4c3 uAT7UoIMg/IzJavBMR2Wbik= =FwNi -END PGP SIGNATURE- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] rounding
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 ahhh, the second argument to round. That will do what i want. It was fairly late and i didn't see that argument in the docs. although now i look at it in the light of day its there. neat. I've replaced by divide by 10 stuff with that. now i have different bugs to chase :) cheers Kim On 31/01/2005, at 9:37 AM, Alan Gauld wrote: The round function will do what you want though not quite what you say you want :-) round(15., -1) 20.0 Interesting, I didn't remember the second parameter to round... let alone the fact it could be negative!! Batteries included once again! Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Kim Branson Diffraction and Theory CSIRO Health Sciences and Nutrition 343 Royal Parade, Parkville Melbourne Ph +613 9662 7136 [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (Darwin) iD8DBQFB/W8Oer2hmGbHcokRAlRwAJkB1NNVnxUN3i2/4bNyKEeiVorDzQCfXGIo JnnkKWdwrIH9XOkB6gFUFAY= =iCJq -END PGP SIGNATURE- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] cross platform gui
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi all, i'm interested in building a gui for some code we have. I'm after pointers on gui programming, and a recommendation on a cross platform gui library, wxpython? pythoncard, qt? What do people use. Ideally i'd like something that can work on windows, osx and linux. Its a science program so the look is a of lesser importance :) cheers Kim -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (Darwin) iD8DBQFCDsrfer2hmGbHcokRAlYLAKCXGmve611OUdqprrpLUVAa2rJdDwCdGRKo dqMFRWAYlM60wlMyWpsLG8w= =bqSk -END PGP SIGNATURE- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] metaclass question
Hi i'm interested in implementing a factoryclass in python What i'd like to do is have my factoryClass produce an instance of a class with some methods defined in arguments to the factory class. The classes that are produced have many common methods, but a single unique method. This method actually is a series of calls to a c++ api. Depending on what we are doing with the produced class, i'd like the unique method to call api function A, or api function B etc. Alternatively the unique method might call A and the B and return a dict of the results. I'm doing this because i'd like all my produced class instances to simply have a calculateResults method which will then go and do the right thing. I don't want to set some values in the init, like A== True and have a if A: call methodA etc statement. I'm not sure if a factory class is the best way to solve this problem, but i can see future cases where the unique function will need to do many things with intermediate results before returning the results dict. i think a factory class might be the best way of ensuring an extensible design. So whats the best way to do this. I have found many references to creating a class with __metaclass__ = SomeMetaClass, but i don't see how one can pass arguments to the meta class. An alternative might be to have a class that operates on an existing instance and adds the correct method, but this seems slightly clunky, and is probably not the python way Cheers Kim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] metaclass question
Hi, what i've ended up doing is the following define a EmpiricalScore class that has all the methods for computing results define a single method in the evaluation class that is called Score. This method simply walks though a list and executes the methods in that list. There may be one or many. def score(self): """ this function computes the interaction energy and returns a dict of key=value pairs for the scoring functions requested """ for x in self.functionList: x() return(self.scoreResults) The factory class takes as agument some input data and determine which of the methods in the Evaluation class should be called. it then produces an instance of the EmpiricalScore class, (called scoreObject,) and then append the methods from that instance to its internal list. scoreObject=EmpiricalScore() #for each valid scoring function in the functions #tuple we call the method which adds the attribute for x in self.functionsToUse: #we need to check if we want both smog and smogh if x == "smog": if bothSmog == True: continue for y in self.functionsToUse: if y == "smog_h": scoreObject.functionList.append (scoreObject.calBothSmog) This is possibly not the best way to approach this, the factory class is possibly not required and could be added to the EmpiricalScore class. I think its probably better to separate these to keep things clean. In a way this method is constructing a decorator for the EmpiricalScore.score method. Is there a way of appending a method to the class after it is initialized. Or adding decorators to the method after it is defined? kim On Jan 22, 2007, at 5:14 PM, Kent Johnson wrote: > Kim Branson wrote: >> Hi i'm interested in implementing a factoryclass in python >> What i'd like to do is have my factoryClass produce an instance of >> a class with some methods defined in arguments to the factory class. >> The classes that are produced have many common methods, but a >> single unique method. This method actually is a series of calls >> to a c++ api. >> Depending on what we are doing with the produced class, i'd like >> the unique method to call api function A, or api function B >> etc. Alternatively the unique method might call A and the B and >> return a dict of the results. >> I'm doing this because i'd like all my produced class instances >> to simply have a calculateResults method which will then go and >> do the right thing. I don't want to set some values in the init, >> like A== True and have a if A: call methodA etc statement. > > Do you need to be passing in the unique method, or can you just > make a base class with the common methods and subclasses that > define their unique methods? For example, > > class Base(object): > def a(self): > pass > def b(self): > pass > def calculateResults(self): > raise NotImplementedError > > class A(Base): > def calculateResults(self): > return self.a() * self.b() > > class B(Base): > def calculateResults(self): > return dict(a=self.a(), b=self.b()) > > Kent > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] get cpu time used by a python script
Hi whats the simplest cross platform way of getting the cpu time used by a python script? Kim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] get cpu time used by a python script
The time in used by the cpu for the execution of the script, rather than the wall clock time. CPU execution time for program = Clock Cycles for program x Clock Cycle Time But i'm interested in the cpu cycles used purely for the python app, regardless of what other processes may be running. kim On Feb 6, 2007, at 8:20 PM, Christopher Lucas wrote: > > On Feb 6, 2007, at 9:14 PM, Kim Branson wrote: > >> Hi >> >> whats the simplest cross platform way of getting the cpu time used by >> a python script? >> >> Kim > > What do you mean by "cpu time", Kim? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] get cpu time used by a python script
Hi Chris, that seems to be exactly what i need. Cheers Kim >>> import resource >>> def cpu_time(): ... return resource.getrusage(resource.RUSAGE_SELF)[0] ... Now try this out >>> def f(): ... for i in xrange(10): ... pass ... >>> start = cpu_time(); f(); dt = cpu_time() - start; print dt 0.008001 >>> start = cpu_time(); f(); dt = cpu_time() - start; print dt 0.012001 On Feb 6, 2007, at 8:58 PM, Christopher Lucas wrote: > python/python/545797?page=las ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor