|
You can pip install --user, or just normal pip install, but yeah you generally should not sudo pip install unless you intentionally set out to modify system python. It's almost always fine, until it randomly isn't, and it's just not worth the hassle of eventually having to deal with (especially if you don't particularly care about systems administration). I like pyenv for managing python installs. The usual workflow is that you: 1. Start a new python project by creating a new directory. 2. Place a .python-version file in the directory with the contents of the version this project should use. 3. Navigate to the directory and "pyenv install" to install whatever version of python that is. 4. Use python normally from now on. It probably doesn't work on windows, but I'd really suggest using WSL to do any sort of python development on windows anyway.
|
# ? Dec 30, 2020 21:24 |
|
|
# ? May 13, 2024 22:38 |
|
wolrah posted:I understand the use of virtualenvs and such for keeping different projects' dependencies isolated from the system and each other, but if I actually do want the latest version of something installed system-wide is sudo pip install actually the best way to go? Yeah, system wide pip is there for that reason, but you need to be very careful. The safer way to gain the convenience you desire is to create a venv and then modify your path to point to the python that lives in it QuarkJets fucked around with this message at 21:41 on Dec 30, 2020 |
# ? Dec 30, 2020 21:38 |
|
12 rats tied together posted:I like pyenv for managing python installs. The usual workflow is that you: quote:I'd really suggest using WSL to do any sort of python development on windows anyway.
|
# ? Dec 30, 2020 21:45 |
|
pyenv is nice because I can have a distinct env for each global package I need (CLI tools, not libs to use) very easily. I guess you can do this with conda, too? But I haven't really messed with it.
|
# ? Dec 31, 2020 00:45 |
|
Do any of y'all have experience distributing packages with Cython? I've been Googling about this as much as I can and have also tried reverse-engineering the Cythonizing components of packages such as pandas, all to no avail. Right now my folder structure is: code:
setup.py currently looks like this: code:
I noticed that other Cython-using packages have a variety of helper files like MANIFEST.in in the main directory, but none of the helper files seem to mention Cython, so ¯\_(ツ)_/¯ I've also tried this with the built .pyd extension in the cy/ folder, and the imports within __init__.py just fail. At this point, I've spent way more time on this than I care to think about. Help me Python thread Kenobi, you're my only hope. Zugzwang fucked around with this message at 04:47 on Dec 31, 2020 |
# ? Dec 31, 2020 04:09 |
|
Bad Munki posted:Similarly on OSX messing with system Python will wreck your poo poo, just absolutely don’t. Huh I replaced my default python files when I didn’t know better with anaconda and I never actually had a serious issue. Probably just lucky though, since I installed a shitload of common libraries before I edited the system files to all point to it.
|
# ? Jan 1, 2021 00:23 |
|
The Unreal Engine now has a Python 3 in there with an unreal package, but it's treated as a built-in. We can get PyCharm to use the appropriate Python environment that the engine is using... but obviously because this unreal package is a built-in like `time` or `shutil` (i.e. there is no `unreal.__file__` or file path we can access via introspection), PyCharm won't recognize it for IntelliSense purposes. So we can't browse its contents and whatnot for insight into what's available. Is there a way we can get PyCharm to recognize this built-in module for its custom Python version so that we can work on scripts separately in an IDE and have the benefit of IntelliSense?
|
# ? Jan 1, 2021 04:20 |
|
There are options for configuring the Python interpreter, including adding additional paths for libs, but I don't understand what you're attempting.
|
# ? Jan 1, 2021 06:42 |
|
Love Stole the Day posted:The Unreal Engine now has a Python 3 in there with an unreal package, but it's treated as a built-in. Is this what you're looking for? mystes fucked around with this message at 08:58 on Jan 1, 2021 |
# ? Jan 1, 2021 08:55 |
|
mystes posted:Some pages seem to indicate that unreal engine will generate an unreal.py file you can use. E.g. https://mycgdoc.com/Stub-File-in-PyCharm-269b748c0c3942aeb7bba4df568415f8 Following the backlink on that page, I found the "Stub File" section here on that backlinked page: https://mycgdoc.com/Python-Integration-22eef40f46c44f03aa25117ed939ecc6#269b748c0c3942aeb7bba4df568415f8 That one step was the missing piece! Thank you so much
|
# ? Jan 1, 2021 18:10 |
|
I'm absolutely losing my mind with a bug in python that i don't think should be possible hence the solution has got to be super simple the function in question is Python code:
example output: code:
|
# ? Jan 3, 2021 21:29 |
|
Each time that you append j to the list, you are actually appending a pointer to the data. That pointer is being modified to point to different data with each iteration of the loop, but the pointer itself is the same. So you wind up with a bunch of identical looking elements because all of the pointers are being updated to point to the same data (note how in the output list all of the elements look like the last data element in the input list; this is why). There are many ways to fix this You are actually modifying the entries in the input list with this function. If that's your intention, you can just eliminate the completed list entirely and instead print input_list
|
# ? Jan 3, 2021 21:55 |
|
QuarkJets posted:Each time that you append j to the list, you are actually appending a pointer to the data. That pointer is being modified to point to different data with each iteration of the loop, but the pointer itself is the same. So you wind up with a bunch of identical looking elements because all of the pointers are being updated to point to the same data (note how in the output list all of the elements look like the last data element in the input list; this is why). There are many ways to fix this That suddenly makes so much sense! thanks. I knew it would be something simple in the end. I want multiple copies of the input list, each with a value from imputed filled in so i'll work on a fix that achieves that.
|
# ? Jan 3, 2021 22:01 |
|
The general rule is that Python will not create a copy unless asked. Since you expect the output list to have all of the elements of the input list, except modified, you can copy it at the start of the function and then modify the elements in place.Python code:
|
# ? Jan 4, 2021 08:43 |
|
QuarkJets posted:The general rule is that Python will not create a copy unless asked. Since you expect the output list to have all of the elements of the input list, except modified, you can copy it at the start of the function and then modify the elements in place. This will just create a copy of the list instance, you might need to also copy the objects held by the list.
|
# ? Jan 4, 2021 16:48 |
|
copy.deepcopy(j)
|
# ? Jan 4, 2021 16:58 |
|
accipter posted:This will just create a copy of the list instance, you might need to also copy the objects held by the list. Oh right, that's true. Use a little list comprehension with deepcopy instead
|
# ? Jan 4, 2021 22:37 |
|
I've been playing around with some idea from my questions a few pages back, including a way of dynamically determining available model prediction classes. See the following code:code:
code:
(Also, how are ya'll able to do those Python code blocks?)
|
# ? Jan 4, 2021 23:51 |
|
It's not a direct subclass of Animal. You would need to recurse through each subclass and look at their subclasses, too.
|
# ? Jan 5, 2021 00:26 |
|
necrotic posted:It's not a direct subclass of Animal. You would need to recurse through each subclass and look at their subclasses, too. yaaaa I get this, but it seems kind of odd that that registration trick only works with direct subclasses. Like, so long as all the classes in the inheritance tree support the original ABC interface, wouldn't it be useful to crawl through them?
|
# ? Jan 5, 2021 03:19 |
|
Cyril Sneer posted:yaaaa I get this, but it seems kind of odd that that registration trick only works with direct subclasses. Like, so long as all the classes in the inheritance tree support the original ABC interface, wouldn't it be useful to crawl through them? On a case by case basis. Having the subclass method only return direct descendants makes the most sense, it would be a more common case than the entire set of children and grand-children and... All the way down. If you do need that whole hierarchy implementing recursion (or a queue) is simple enough.
|
# ? Jan 5, 2021 03:50 |
|
I'm running a Monte Carlo simulation with xgboost and sklearn.calibration.CalibratedClassifierCV. It works well except its way too slow. What are my options to make it faster?
|
# ? Jan 5, 2021 07:58 |
|
Profile it and find out what’s taking the most time, then optimise that part. Repeat until performance is acceptable. If you want more specific guidance you’ll need to post code and profiler output.
|
# ? Jan 5, 2021 11:00 |
|
DoctorTristan posted:Profile it and find out what’s taking the most time, then optimise that part. Repeat until performance is acceptable. If you could point me to some resources on how to perform profiling I'd be grateful. I think starting there would be the best course of action. My code is quite long and spaghetty so I'd rather not post it for now.
|
# ? Jan 5, 2021 12:01 |
|
Mursupitsku posted:If you could point me to some resources on how to perform profiling I'd be grateful. I think starting there would be the best course of action. My code is quite long and spaghetty so I'd rather not post it for now. Yea with a MC simulation, shaving 300ms over 5000 trials is a good win. I'm assuming the part that is taking too long is the simulation, not the training of the models. I'd start with using pythons built in timing in several places and figure out what is taking the most time and see if I can optimize it. Places I look first when using sklearn are: 1) for loops, particularly on dataframes...can I apply or map a function instead? Can I use numpy instead? 2) other python libraries/packages, for example if I am doing some image transformation using Pillow, how long does that take 3) The classifier itself, how long does it take to spit out a pred? Can I decrease the number of features in my model and see a big speedup without much accuracy loss? If you're still writing the code, don't run a bunch of trials. Code should run in 10 seconds during the initial write.
|
# ? Jan 5, 2021 14:51 |
|
CarForumPoster posted:Yea with a MC simulation, shaving 300ms over 5000 trials is a good win. 5000 trials? Let me tell you, I once ran a MC simulation with over a trillion trials during my Ph.D. work. Fortran, not python, but still an amusing memory. One of my dissertation reviewers asked if the number was a typo. During the course of the work I found a bug in the random number generator for a commonly used Fortran compiler (which I reported to the devs and they later corrected).
|
# ? Jan 5, 2021 15:42 |
|
CarForumPoster posted:Yea with a MC simulation, shaving 300ms over 5000 trials is a good win. Thank you for the tips. Its probably the classifier. When I ran the same simulation with a regular logistic regression as the classifier it ran maybe 3 times faster.
|
# ? Jan 5, 2021 21:06 |
|
I have a stupid python question. I'm working on some python Lambdas in AWS and I want to increment or decrement my autoscaling group based on events. Now, there are minimum and maximum sizes to my ASGs I need to take into account when altering the desired #s in the ASG so I want somehow build that into my ++ and -- functions. I was thinking of using range() but I'm not sure if that's the right way to go:code:
|
# ? Jan 6, 2021 15:11 |
|
Just a general process thing, if you can coerce your events into a time series metric, this integration is much easier to configure in AWS and has some prebuilt policies and triggers you can set: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-policy.html More specifically for your use case, I would suggest not mutating MaxSize. If you want to decrement or increment the number of instances in your asg, consider modifying desired only. Max can be left alone, managed manually, or set by some kind of ops team / billing team. The autoscaling service is smart enough in general to not launch 400 instances when you just want to temporarily scale from 22 to 23.
|
# ? Jan 6, 2021 19:40 |
|
Mursupitsku posted:Thank you for the tips. After running some tests it seems that the classifier is the only thing taking a significant amount of time to run. I haven't yet tested if dropping features would increase the performance. In any case there is only 17 features total and my gut tells I cant really drop any of them. Would just throwing more computing power at it work? Atm I'm running it on an semi old laptop. What are my options to optimize the classifier itself?
|
# ? Jan 10, 2021 16:22 |
|
Mursupitsku posted:After running some tests it seems that the classifier is the only thing taking a significant amount of time to run. I haven't yet tested if dropping features would increase the performance. In any case there is only 17 features total and my gut tells I cant really drop any of them. Part of the "eXremeness" of XGBoost is that it does scale pretty well with more hardware and threads. XGBoost is pretty well optimized already, but perhaps you are using an excessively-large model. 17 is a decent number of features and it could be worth actually doing some feature selection testing. You may also be using default hyperparameters that make a more-complex-than-necessary model and could reduce the tree depth, maximum number of trees, or number of boosting rounds.
|
# ? Jan 10, 2021 17:21 |
|
So, fair warning, this is homework related but I'm not looking for any hand-holding, just trying to understand my options and tools. If I wanted to crack a Scytale cipher string, in the format of a single uninterrupted string of text (think: xyxyxyxyxy) what would be the best approach? Is there a function in pandas to reformat the text and place parts into different cells out of an excel file? Ideally once reformatted, I could then reconstruct and print the string based on a key which would instruct how to transverse the reformatted string and pluck out of cells. I just don't know where to start reading up on this.
|
# ? Jan 11, 2021 15:57 |
|
Do you want me give you a hint to point you in the right direction or solve the whole thing for you? Assuming the former; you don’t need pandas for that. Just put the cipher text into a string and read the docs on string operations and python’s slicing syntax.
|
# ? Jan 11, 2021 18:52 |
|
DoctorTristan posted:Do you want me give you a hint to point you in the right direction or solve the whole thing for you? My code currently is attempting that, but I'm having issues with transversal. I need to slice, say, every third letter, and then once I hit the end of the string, loop back to the beginning of the string to finish the count and reslice. I could perhaps just duplicate the string many times over to achieve that, but that feels clunky as hell. My reasoning for pandas is that the manual way of decoding the cipher involves a grid, and a column/row format would serve that purpose. e. I've been messing with while loops and am just not quite there yet. Famethrowa fucked around with this message at 19:26 on Jan 11, 2021 |
# ? Jan 11, 2021 19:23 |
|
Famethrowa posted:My code currently is attempting that, but I'm having issues with transversal. I need to slice, say, every third letter, and then once I hit the end of the string, loop back to the beginning of the string to finish the count and reslice. I could perhaps just duplicate the string many times over to achieve that, but that feels clunky as hell. You could also use the notation for slicing something in steps that Doctor was, I assume, pointing you towards code:
|
# ? Jan 11, 2021 20:14 |
|
Famethrowa posted:My code currently is attempting that, but I'm having issues with transversal. I need to slice, say, every third letter, and then once I hit the end of the string, loop back to the beginning of the string to finish the count and reslice. I could perhaps just duplicate the string many times over to achieve that, but that feels clunky as hell. You said you didn't want hand holding, but you should use the slicing notation code:
I'm not the one marking your work, but if I were I would deduct marks if you used pandas for this - it really isn't the right tool for the job. I'd give a bonus point or two if you managed to solve it in one line.
|
# ? Jan 12, 2021 10:02 |
|
If you really want a column/row format, a 2D numpy array would be better than a pandas dataframe. But I don't think that's necessary. I feel like there may be a clever list comprehension that could give a fast, succinct solution but I'll be damned if I know how to implement it
|
# ? Jan 12, 2021 10:36 |
|
You shouldn’t use numpy either. QuarkJets posted:I feel like there may be a clever list comprehension that could give a fast, succinct solution Not posting it since OP wants to figure things out themselves, but there’s a one-line solution.
|
# ? Jan 12, 2021 11:17 |
|
DoctorTristan posted:Not posting it since OP wants to figure things out themselves, but there’s a one-line solution. I feel like whether that's relevant depends on the context of the class. If this is supposed to be a lesson about loops then solving it with a one line list comprehension isn't going to get you high marks. You definitely don't need anything outside of the standard library. QuarkJets posted:I feel like there may be a clever list comprehension that could give a fast, succinct solution but I'll be damned if I know how to implement it. Using the slicing notation and iterating over a range to offset the starting character for each slice probably does it.
|
# ? Jan 12, 2021 14:28 |
|
|
# ? May 13, 2024 22:38 |
|
Wallet posted:Using the slicing notation and iterating over a range to offset the starting character for each slice probably does it. Thank you for the feedback everyone. I was working on some other classes so this went on backburner. This is what I'm focusing on right now, just need to grok how to offset in a way that will output correctly for each key/cipher length tested. Thinking perhaps I hardcode a brute-force function to test a set of possible keys rather then use an input key. Should mention, this isn't for a programming class, my goal here is solely to solve this cipher. I could do it by hand, but I really wanted to get better at Python. Famethrowa fucked around with this message at 16:56 on Jan 12, 2021 |
# ? Jan 12, 2021 16:52 |