« first day (3620 days earlier)      last day (1329 days later) » 

3:36 AM
cbg, the reason I got when I asked when is setattr and getattr used in a code was "it is for highly dynamic code", can anyone tell me what is highly dynamic code?
 
 
4 hours later…
7:54 AM
@python_learner code where you want to access attributes whose name you don't know at the time of writing the code
Normally you know the attr names so you just use obj.attr in your code
 
 
1 hour later…
8:59 AM
cbg folks. I hope all are well
 
long time no see :)
 
Indeed. Cbg piR, I hope you're well
 
Doing well. Covid has just messed up so many things and I haven't been coding much and have kinda forgotten my python family )-:. I was working on a project that I started searching for answers and I thought I'd pop on and say hi.
 
9:30 AM
it is indeed topsy-turvy but you can't forget about the python family; that's when they strike :)
 
10:17 AM
I want to close this as a typo but I can't test. I can't see how it doesn't throw an error one way or another. Am I missing something?
 
With SQL_Use being undefined that looks like a "no mcve" to me
 
I'm gonna go with that. I'm relatively convinced that it will be shouting errors at them by passing 3 arguments and not a tuple of parameters
 
I bet their real code has except: pass
Ah, no
cursor.execute(operation, params=None, multi=False)
probably a dupe
 
Sure, but then the query string won't have enough parameters, so it's still going to error
There's 2 placeholders in the query
 
Ah, good catch
are those valid placeholders?
 
10:29 AM
That's the bit I can't test :( For MySQL I think they are
 
execute() returns an iterator if multi is True.
too lazy perhaps?
 
It can't be lazy because they commit()
 
OK, I give up :D
 
:P We've just lived out my mental quandary
I guess I should download MySQL at some point. I could do with another server thingy running on this laptop
 
@roganjosh go for Maria if you're going to go down the MySQL route :)
 
10:40 AM
@JonClements or, both! My port address book still has a couple of entries left :P
 
postgres ftw though :)
 
Obvs
 
I thought cool kids used nosql
 
I best grab redis and mongo while I'm at it, then
I don't want to be un-cool
 
@AndrasDeak nah... cool kids now use graph databases - get with the times! :p
(mind you - they're awesome - but generally misused for things)
I still wouldn't use one for main DB storage - that'd still be an RDMS, coupled with redis for some other bits and cache and all that... but they're nice
(sometimes throw into the stack some elastic and a graph DB - lovely jubbly)
(keeping everything in sync. is a right pain though but...)
 
11:03 AM
on a side note @roganjosh - redis' GIS stuff is pretty darn fast
 
I've missed a trick then because I didn't know it existed
I'm looking at this but it's not real-road, right?
 
well I suppose it depends what you need to do - I've got the UK postcodes stored for instance with lat/lon (central) and the GEO functions from redis.io/commands work great
(for what I need anyway)
 
Ah, yeah, it's not useful for my work unless it considers the road network, but that's not to say it won't be useful in the future, thanks
 
so in terms of general GIS stuff it's nice, for other stuff, like routing - it's probably not that helpful
 
You just have to add every street corner as a node, right? With some metadata about one-way streets and such :P
 
11:10 AM
OSRM is blazingly fast if you want road networks. I think I've declared my love for it multiple times. I still think it's magic
 
@AndrasDeak sounds like a graph to me :)
 
directed and cyclic, the best kind
 
and cypher's not a too hard to understand instruction language
"I want to go from Node A to Node B - give me the shortest path or give me N shortest paths" kind of thing
(and you can also add in a bit of logic to evaluate the "weight" of each edge between nodes etc...)
 
@JonClements wait, what do you use for postcodes there? I've actually struggled more than I'd like with translating postcode to lat/long
 
@roganjosh huh?
 
11:20 AM
I'm not sure how you're translating postcodes to lat/lng from what you linked. You must have loaded a database?
Ok, I think I've got myself confused. It's not redis that knows the coordinates, you loaded it from something. I'm curious about what that source is
I've tried a few different libraries and I've got to the point of biting a bullet and using the Google maps API in something I'm working on. The translation of postcodes to lat/long has been, frankly, crap with the libraries I've found
 
well... I have from a client that has a licence for the PAF that's updated weekly which I can access, but obviously can't share that, but there's a few not too shabby online sources... gimme two ticks and I'll look those up
 
 
2 hours later…
1:11 PM
howdy
 
hello
 
really bored of stack overflow questions.
 
take some rest
 
I've been really bored of them for many months.
 
Try some other language then
 
1:22 PM
well, I am checking Java, Python, C...
Python is nice in that if your program is not correctly indented it doesn't run. Alas, that's not true for C and Java :D
 
Every language has its pros and cons.
 
@PrashinJeevaganth in the case that you might re-post; wrong room
 
1:47 PM
Sequel to Harlan Ellison horror story: I have no skill and I must code.
 
@AnttiHaapala What's worse is when your code is indented properly but you left out the braces. It still runs, but not in the way you wanted.
if (some condition)
    log("about to do something"); // added for debugging
    do something;
(^^ Java, from actual experience)
 
indentation error..haha
sorry syntax
 
That's why people insist on adding braces in if-then or for loops, even when the enclosed body is a single line. This was in the mid-90's (the scars have yet to fully fade), perhaps modern IDE's would have helped catch this.
The other curse of braces is the "where do you put them?" debates. I was on a team that spent two weeks debating this. I was so happy to see that Python didn't need them, makes that whole fruitless discussion moot.
 
so True...Agreed
 
Usually the debates are between these two styles:
if (some condition) {
    do something;
}

vs

if (some condition)
{
    do something;
}
 
1:56 PM
if (some condition) {do something;}
 
Ironically, our team settled on this style, which I've only seen a couple of times since, and which, also ironically, in retrospect actually looks kind of Pythonic:
if (some condition)
    {
    do something;
    }
I think this was for coding in PL/1, which was really a nice language to work in. Kind of like a verbose C, with exceptions (predated C++ and Java, so this was a big forward step).
Unfortunately, PL/1 was a sort of "everything but the kitchen sink" language. Bloat included features that were pretty niche, so if you ever used them, everyone in the code review said, "I've never seen that keyword before," with the predictable added maintenance problems ("um, I think this might be the problem, but I have to look up that keyword again" - plus no Google at that time, remember). Maybe a cautionary tale for Python.
 
<gasp>
 
2:52 PM
@AnttiHaapala Well indentation is not so tough ...After some practice you can do it very well.
 
 
1 hour later…
3:59 PM
What is a good way to learn PyQt5? Is there a place I can find several worked examples? I've been reading the docs and some tutorials but i'm having a hard time understanding how it works. They seem be bundled together and all with class inheritance and I get confused on their precedences and all
 
4:12 PM
The docs are comprehensive in doc.qt.io/qtforpython/PySide2 but it seems it will take me ages to get even familiar with all the functionality and their relationships to each other
 
5:03 PM
class foo(object): is an old way of defining a class right? If I only plan to use for python 3 and above I can just do it class foo:
 
@Pherdindy yes
can and should
although class names should be capitalized, usually
 
@AndrasDeak Right thanks first time seeing a class with the object parameter might as well remove it
 
Yes. Explicitly inheriting from object was only necessary to define "new style classes" in python 2. In python 3 there are only new style classes.
 
Yeah that makes sense thanks
 
@AndrasDeak Yes it;s a convention to capitalize class names :)
 
5:18 PM
good to know
 
Not sure if anyone here is working on image recognition but what are usually the limitations to it? Data is usually messy with quite a few rows that are not significant to the analysis so it can be usually screened by looking at a photograph. But the issue with photographs are that they are noisy as well so I don't think programs can screen accurately. Currently I am using manual labor to actually screen thousands of rows 1 by 1 based on an image so it is definitely a lot of resources
I've came across some "learning" of a program when it gets fed images and it learns to distinguish over time but how accurate and accessible is the technology to individuals?
 
There are various ready-to-use frameworks available, google should be able to give you a list. Image recognition should have little trouble with noise, but rather with biases. E.g. if your images of pythons are much more noisy than your images of anacondas, then image recognition might associate noise itself with pythons.
 
And there's normally a step of noise reduction where you try to remove what you know is irrelevant to the problem
for instance if you are looking for something blue you might clear other colour channels to make the computer's job easier
 
I'll take a look but I don't really know how they look exactly since the colors/shape/background of the photos vary widely
It can be something like a coffee maker photograph in amazon that comes in a wide variety
And there's no classification to begin with
 
e.g. in stackoverflow.com/questions/24731810/… you can see how the images are cleaned step by step to come up with something segmentable
 
5:33 PM
@AndrasDeak Looks good, but I think image recognition is going to be a very hard program to make properly :/ will probably hold this for last
For now manual labor is probably the way lol
Just seeing the code to do that is a lot of work
 
yes, the more your input varies the harder it is to automate it
Incidentally the guy who wrote that answer is an image processing and computer vision expert. So yeah, it's not trivial.
 
Yeah probably not practical at all
 
Why to create an image recognition program from scratch?
There are already many. Just modify it as per your requirement
 
@Karthik I like that reasoning. Many websites have been implemented in django. Why write your own then? :)
 
@Karthik not planning to create from scratch but trying to see the limits to how it performs generally (the existing libraries)
 
5:37 PM
Finding the right one and knowing what to modify needs the same domain knowledge. Unless you have a standard problem, like OCR.
@Pherdindy in the hands of an expert existing libraries are awesome. Depends on what you have to do. If you want it to recognize that there's a coffee maker in the image it's harder (needs classification). If you just want to segment "the one photo" in a larger photo it's easier.
 
@Andreas Deak ya thats true though domain knowledge is required but not rework
 
Side note: it's Andras, not Andreas
 
Appologies..
 
it's alright
 
Yeahh I get it I wasn't really having high hopes on getting any image recognition for my needs. I am currently paying someone to screen thousands of rows day by day but it's probably the thing i'm going to stick with for a while
The human brain is still the best hah
 
5:40 PM
@Pherdindy the alternative is probably paying an expert to write the equivalent code. Compare the amount of money they'd ask to do it with what you're paying to the human.
 
May I ask what the application is?
 
ya as a beginner or medival 3rd party would be much better
 
@roganjosh manipulating e-commerce sales, no doubt
 
I'm making requests to get e-commerce data
So the photos are just like you see in amazon
I'm making the request volume just really low and they seem to allow it
 
doesn't the data come in other ways? If your requests are loading inage data, doesnt it come with a product description?
 
The product description is also noisy since people tend to spam keywords in the platform i'm using
The chinese don't speak english well
 
lol..yaa
 
I'm being abstract with "data" but presumably you're not just requesting photos
I'd still put money on product descriptions being easier than image detection
 
@roganjosh yeah perhaps it's the only chance I got i'll take a look at it
 
raf
6:14 PM
Hi, can you kindly tell me how to improve this following function.
 
6:33 PM
"Improve" how?
 
raf
text_tokens = word_tokenize(text)
tokens_without_sw = [word for word in text_tokens if not word in stopwords.words()]
filtered_sentence = (" ").join(tokens_without_sw)
text = filtered_sentence
this section is really slow while compiling the huge dataframe with 179108 length
 
Calling stopwords.words() hundreds of thousands of times probably isn't a great idea
 
raf
@Aran-Fey what can I do?
 
Call it once and store the result in a variable
 
Create a set prior to the list comprehension
 
6:53 PM
cbg
 
@raf please start hosting this off-site, as per the room rules
 
raf
Sorry
Where can I discuss it?
 
In any case, is stop_words a set now?
 
You can discuss it here, just don't post such massive blocks of code in chat
 
raf
@roganjosh No, it's a list now. @Aran-Fey suggested that I should call it once by a variable
@Aran-Fey oh okay! I am sorry again.
 
7:00 PM
I cantmove messages on a phone without spamming chat more :/
 
I don't want to move the first one due to context
 
Thanks:)
 
Hmm, though I guess the first block of code wasn't referenced much, just the second small one
 
Currently I'm trying to build Caffe which is a python wrapper around a large deep learning framework. I noticed in the instructions it mentions being able to install all the dependencies in apt using the flag build-dep but " it requires a deb-src line in your sources.list". I'm confused since those instructions are literally the entirety of instructions about that.
 
@Skyler seen things like askubuntu.com/questions/324845/… yet to see what build-dep does?
Sounds like they're suggesting to let apt install every dependency for you (without installing the actual package via apt). For which, presumably, you need deb-src in your /etc/apt/sources.list which defines what repos are used by apt
 
7:15 PM
yea, when i started reading about deb src on the debian website the examples it gave seemed were limited, is deb src like a repo you reference in sources.list that then you pass your library (like caffe) to and then it builds the dependency list and sends instructions back
wiki.debian.org/SourcesList what I'd been reading earlier
 
they probably just mean having your own distro's appropriate deb-src line in the sources.list, which might be there by default
 
when I was looking at my sources.list there were on order of 10 different deb-src lines commented out
is the assumption that you just uncomment one of these lines
 
Probably yes. But you should probably understand the exact consequences before meddling with your sources.list (I don't). And always make a backup of the original file first.
 
7:34 PM
Hi. Is there anybody who knows machine learning?
 
its quite a broad topic, what are you trying to do
@AndrasDeak backups are always good
 
I want to how to write multiple linear regression. I mean, if I have for an example three or four features in train vector how can I mathematically count the prediction?
or just give me an example of such a model in code. I will check it on my own.
Cuz I can't even google it
 
I'm not familiar with the exact domain you're asking, but from personal experience with related (non-ML) problems I'd try figuring out two-dimensional cases.
 
Count the prediction?
 
By which I mean regression on z(x,y) datasets. That you can visualise and it's probably easier to generalise from there.
 
7:37 PM
Yes. I mean if we write the fitting line in such equation: y = kx + b, and this is only for one X, then how to do it for 3-4 Xs?
 
you might want to read up a little on the "generalized linear model" as it will cover that question
 
I can't imagine more than 3-D dimension with (3+ independent variables)
 
@entithat you have to imagine the 2 independent variables case, look at the math, and see what changed compared to the univariate regression case
 
You don't have to; computers can do that.i still don't follow what you're asking us
 
it even covers the case where sometimes you are not explicitly dealing with functions proportional to x (like in your case its k times x is related to y) and instead it deals more broadly with the meaning of linear that underlies linear algebra. Linear is a bit of an overloaded term and what you've described so far is actually a "Simple linear regression"
 
7:41 PM
above 3 dimensions intuition starts to fail and you only have mathematics to guide you
 
this is a case where I think you should read up on the math a bit more and then come back before trying to implement code. online.stat.psu.edu/stat504/node/216
 
I'm sick of my phone removing spaces after a period. I thought I could live with it, but I can't:/
 
@Skyler thanks. I'm gonna read about it.
 
the link i sent may be too technical but if so google "generalized linear model" and there are lots of less technical intros around
 
ok, it's even better
 
8:29 PM
Why are f strings case-insensitive in the grammar? I may be getting over-hyped by this but it seems to fly in the face of "there is only one way"
(apart from the fact that there's at least 3 ways of doing string formatting)
 
You mean F'asdf'?
You probably have to ask why B'asdf', U'asdf' and R'asdf' work
 
It also matters because I just looked a fool with F'{1+1}' working. I thought the lowercase f was important
 

« first day (3620 days earlier)      last day (1329 days later) »