|
Have you tried reading the documentation? https://pythonhosted.org/joblib/parallel.html#common-usage According to that, the function that you want to parallelize needs to be a generator. It sounds like you need to modify your code
|
# ? Apr 26, 2015 18:33 |
|
|
# ? May 9, 2024 14:35 |
|
Cingulate posted:f is a fairly long, complicated and badly written function so I don't want to bother anybody with it. It looks to me like you're using joblib correctly. Can you trigger the same weirdness with a different f? Does f interact with the outside world at all?
|
# ? Apr 26, 2015 19:13 |
|
QuarkJets posted:Have you tried reading the documentation? In what I did, I tried to copy the docs. From what I understand, we write the code as a generator - i.e., my (delayed(f)(item) for item in list_of_items), where f is a "regular" function that returns something. FWIW it works if I set n_jobs to -2 ... Actually, you pointing out that (delayed(f)(item) for item in list_of_items) is a generator finally cleared up the joblib syntax for me.
|
# ? Apr 26, 2015 19:16 |
|
Nippashish posted:It looks to me like you're using joblib correctly. Can you trigger the same weirdness with a different f? Does f interact with the outside world at all? I do do random.seed(an_int) in there. This is pointless, as I'm just realizing, as an_int is set to the same value for all iterations by my usage of partial() to wrap f, but that's the only thing I can see loving with globals. I'm accessing a bunch of globals however. But the only stuff that's changed is created inside the function, and the function returns to a new list. I'm possibly missing something very obvious, I'm a terrible programmer. I haven't found another f it does this for, though I haven't tried much.
|
# ? Apr 26, 2015 19:20 |
|
I'm almost certain that it's something weird due to your function, so I'd like to suggest Nippashish's advice as well: try a very simple, working version of f that parallelizes correctly and keep building up f until the parallelization breaks. This is a pretty effective debugging techniqueCingulate posted:I'm accessing a bunch of globals however. This could also be the culprit, I would strongly encourage you to not even use globals. Ever.
|
# ? Apr 27, 2015 17:54 |
|
Something cool I just found out about Python: if you're unpickling e.g. a Counter object from a file, you don't need to do from collections import Counter. That's pretty nifty!
|
# ? Apr 28, 2015 14:39 |
|
pickle tries really hard to store the full module path in the file itself, so it knows where to import it from afterwards.
|
# ? Apr 28, 2015 16:23 |
|
How hard is it to get patches to the python standard library accepted? I've fixed a few things in asyncio, but they're kinda edge cases. I don't really want to spend a bunch of time on shepherding them through a long drawn out process...
|
# ? Apr 28, 2015 18:36 |
|
I'm cross-posting from the Django thread because I think this might also be a general Python question. Is it possible to pass a variable assignment statement as a parameter when I make a method call? For example: Python code:
Python code:
Python code:
|
# ? Apr 28, 2015 20:48 |
|
You can expand a dictionary into keyword arguments like this:code:
code:
code:
|
# ? Apr 28, 2015 21:20 |
|
Nippashish posted:And of course you can combine both of these things like this: Python code:
IAmKale fucked around with this message at 22:06 on Apr 28, 2015 |
# ? Apr 28, 2015 22:04 |
|
Thermopyle posted:How hard is it to get patches to the python standard library accepted? I've fixed a few things in asyncio, but they're kinda edge cases. I don't really want to spend a bunch of time on shepherding them through a long drawn out process... It's been mostly painless for me, given my track record of "a patch to the zipfile module" and "a patch to the base64 module"
|
# ? Apr 29, 2015 00:41 |
|
What if I wanted to contribute something that's only useful in unit tests?
|
# ? Apr 29, 2015 04:48 |
|
Is this a half decent tutorial for machine learning? The book that my tutor recommended ("Building Machine Learning Systems with Python") has been getting pretty poor reviews and comments about poorly-explained code, buggy examples and whatever else, so I've taken it on myself to find something else for now.
|
# ? Apr 29, 2015 22:53 |
|
Is there any reason for not using scikit-learn instead?
|
# ? Apr 29, 2015 23:11 |
|
MorsAnima posted:Is this a half decent tutorial for machine learning? The book that my tutor recommended ("Building Machine Learning Systems with Python") has been getting pretty poor reviews and comments about poorly-explained code, buggy examples and whatever else, so I've taken it on myself to find something else for now. Are you trying to learn python or to learn machine learning or to learn how to do machine learning in python? These are three different things and the sources you'd use for each of them are different. That set of tutorials looks like it covers a lot of very basic python things in a very superficial way.
|
# ? Apr 29, 2015 23:13 |
|
I'm trying to evaluate a program I wrote by comparing predicted lines against ground-truth lines. How can I pull a line from each file? I tried doing for ground_truth_line, pred_line in ground_truth, predicted: where ground_truth and predicted are the respective files, but I got an error "too many values to unpack".
|
# ? Apr 30, 2015 15:21 |
|
hooah posted:I'm trying to evaluate a program I wrote by comparing predicted lines against ground-truth lines. How can I pull a line from each file? I tried doing for ground_truth_line, pred_line in ground_truth, predicted: where ground_truth and predicted are the respective files, but I got an error "too many values to unpack". I think you want Python code:
|
# ? Apr 30, 2015 15:35 |
|
Munkeymon posted:I think you want "Cannot import name 'izip'" I'm using PyCharm with Python 3.4.1.
|
# ? Apr 30, 2015 15:46 |
|
hooah posted:"Cannot import name 'izip'" I'm using PyCharm with Python 3.4.1. In Python 3 just use the built-in zip. As I recall the difference is that Python 2's zip has the limitation that it needs actual sequences like lists or tuples rather than iterators, which izip was invented to handle. In Python 3 they just made zip capable of handling iterators and got rid of izip.
|
# ? Apr 30, 2015 15:53 |
|
hooah posted:"Cannot import name 'izip'" I'm using PyCharm with Python 3.4.1. just use zip in python 3
|
# ? Apr 30, 2015 16:11 |
|
hooah posted:"Cannot import name 'izip'" I'm using PyCharm with Python 3.4.1. My bad - I forgot I was living in the future now KICK BAMA KICK posted:In Python 3 just use the built-in zip. As I recall the difference is that Python 2's zip has the limitation that it needs actual sequences like lists or tuples rather than iterators, which izip was invented to handle. In Python 3 they just made zip capable of handling iterators and got rid of izip. zip in 2.x handles iterators just fine but it consumes them in their entirety immediately in order to return a list as opposed to izip which returns an iterator that consumes the input iterators as needed, so zip in 2.x doesn't actually do what hooah was trying to do which is iterate over the lines in the files until there was a difference.
|
# ? Apr 30, 2015 16:16 |
|
Yup, zip works great. Thanks.
|
# ? Apr 30, 2015 21:25 |
|
Nippashish posted:Are you trying to learn python or to learn machine learning or to learn how to do machine learning in python? These are three different things and the sources you'd use for each of them are different. Machine Learning in Python. I'm already fairly experienced with Python, and only mildly so in machine learning. Mix the two and improve at both, ideally. You're right about that tutorial, it does cover a lot of basic stuff - most of which I just gloss over, I don't need it. I'll work through it, I doubt it'll take too long.
|
# ? May 1, 2015 16:14 |
|
MorsAnima posted:Machine Learning in Python. I'm already fairly experienced with Python, and only mildly so in machine learning. Mix the two and improve at both, ideally. You're right about that tutorial, it does cover a lot of basic stuff - most of which I just gloss over, I don't need it. In that case the scikit-learn docs should be more than enough to get you up and running. Scikit-learn is an extensive and high quality library, and their documentation is really good.
|
# ? May 1, 2015 19:31 |
|
MorsAnima posted:Machine Learning in Python. I'm already fairly experienced with Python, and only mildly so in machine learning. Mix the two and improve at both, ideally. You're right about that tutorial, it does cover a lot of basic stuff - most of which I just gloss over, I don't need it. Machine Learning in Action and Machine Learning An Algorithmic Perspective and both useful books that use python.
|
# ? May 2, 2015 01:47 |
|
here is some code we got given that we can't change for an assignment:code:
code:
code:
code:
underage at the vape shop fucked around with this message at 16:43 on May 4, 2015 |
# ? May 4, 2015 16:40 |
|
It should be self.printsomething(filename)
|
# ? May 4, 2015 16:42 |
|
Suspicious Dish posted:It should be self.printsomething(filename) i wasn't clear. The second function is in a different class, the one that controls the ui.
|
# ? May 4, 2015 16:44 |
|
Suspicious Dish posted:It should be self.printsomething(filename) e: ^^^ OK, yeah, then what you need to do in that method is instantiate a TemperatureData, passing filename to its constructor, and then, if you want, call the instance method printsomething. Python code:
KICK BAMA KICK fucked around with this message at 16:48 on May 4, 2015 |
# ? May 4, 2015 16:46 |
|
KICK BAMA KICK posted:printsomething(self) doesn't look like it takes an argument, so I'm not even sure what's supposed to be happening there. Maybe load_file is supposed to be a class method, a factory for TemperatureData instances, upon which you would then call the printsomething method? Yay this worked. This assignment really sucks rear end, it's not clear what it wants and the lecture notes aren't very helpful at all. Thanks.
|
# ? May 4, 2015 16:51 |
|
I've been stumped on this next part for couple of hours, I actually started with this before moving on and doing the other parts but I've done as much as I can without this. The last question was actually building into this. Sorry if this is too much and I'll understand if you want me to go do my own assignments but this is the description of what we are supposed to do for this class: This is my code so far: I really have no idea how or what it wants me to actually do for the get data and get stations bit. I really have no idea how to do that with only self as an argument for both. In the example bit it has example inputs and outputs, this is what it says relating to those 2 methods code:
|
# ? May 4, 2015 17:24 |
|
To me it looks like you have to load your station objects on a dictionary that is a member of the class TemperatureData. Your get_data should be simple enough when you get to that, and if you are stumped on get_stations, you can call a function called dir on that dictionary, and that should give you some ideas.
|
# ? May 4, 2015 17:49 |
|
HardDisk posted:Your get_data should be simple enough when you get to that, and if you are stumped on get_stations, you can call a function called dir on that dictionary, and that should give you some ideas. That one actually mentions "in the order they were loaded", so you have to store them in a separate list, or use an OrderedDictionary. That is a pretty bullshit assignment. Save get_stations for last, then we can help you with that one.
|
# ? May 4, 2015 17:51 |
|
I'm the horror because I didn't even read the assignment Also, check the indentation of the __init__ method of the TemperaturePlotApp.
|
# ? May 4, 2015 17:59 |
|
Fixed that indentation. I'm not sure how I make the dictionary like they want, where get data will return that dictionary for all instances of the class. Do I make a blank dictionary in __init__ and have get data add to it?
|
# ? May 5, 2015 04:11 |
|
I can't figure this out in a way that keeps the methods in TemperatureData the way they described. If I make it inherit from Station (I showed station Init a few posts up) I can use the variables defined in its init to do my get_data. However, this means that: code:
code:
|
# ? May 5, 2015 06:01 |
|
A Saucy Bratwurst posted:I can't figure this out in a way that keeps the methods in TemperatureData the way they described. 1) load_data reads a file and puts data from that file into a dictionary. 2) get_data returns the entire dictionary 3) get_stations returns a list of stations that were inserted into the dictionary, in the order in which they were inserted So what does TemperatureData need to have? 1) a dictionary where the keys are station names and the values are Station objects 2) a list of station names Here's a constructor that contains these things: code:
|
# ? May 5, 2015 07:09 |
|
Thanks that works almost 100%. Typing out the way you look at making the classes actually helps a lot too, thats a good thought process rather than me making methods and trying to get init to work with that. Now i just need to figure out how to have the dictionary save across every instance of TemperatureData (and then do the same for the list) so it does the thing where it has every station that's been loaded so far. e: got it, but now theres nothing at all inside of __init__ but I don't think thats an issue is it? underage at the vape shop fucked around with this message at 08:55 on May 5, 2015 |
# ? May 5, 2015 08:46 |
|
|
# ? May 9, 2024 14:35 |
|
A Saucy Bratwurst posted:Now i just need to figure out how to have the dictionary save across every instance of TemperatureData (and then do the same for the list) so it does the thing where it has every station that's been loaded so far. I'm not sure why you have multiple instances of TemperatureData anyway, but okay. It seems like the assignment implies that you just need one TemperatureData instance quote:e: got it, but now theres nothing at all inside of __init__ but I don't think thats an issue is it? If your class has any variables, it's considered good form to declare them in your __init__ even if you just assign None to them. But Python will let you get away with not doing that
|
# ? May 5, 2015 09:45 |