« first day (4942 days earlier)   

5:22 AM
@Marco this is such a common issue with machine learning questions on the site. Often it's not possible to make an MRE for such complicated cases because it'd end up being hundreds of lines long. However it does seem that they detailed the API usage enough that someone might be able to check it against their own implementations to see whether it reports different values
I feel like there's a canonical on meta about why data science questions just don't work on SO somewhere but I've not had my morning cup of tea yet so I'll hunt it down shortly :)
 
5:40 AM
Huh, now I have started drinking my tea I see that it's really old and only has a "same here!" answer. Indeed it should be closed
 
6:24 AM
@Marco That's a new rep-25 user. First tell them what an MCVE is and that they need to add it (more "welcoming"), instead of just closing it without warning. I added a comment saying that.
@roganjosh Well anything where a full MCVE would need 20-1000 lines can be painful to generate MCVE for. Esp. in this case they're only asking about why the logging syntax seems to mismatch, not the model, parameters, accuracy etc. itself.
@roganjosh The power of tea ☕️. Douglas Adams would have approved.
 
 
6 hours later…
12:26 PM
any good intro to arrays in python?
i don't get this syntax:
listt = [1,2,3,4]
listt[2] = [8]
listt[2:2] = [7,7]
 
start by not calling them arrays but lists
 
i get that the second is inserting elements only, not the array itself, but doesn't seem intuitive ?
says array methods' in the docs
what do you mean @ThiefMaster?
 
but [...] creates a list. not an array from that particular module
 
are list and arrays different things in python ?
they seem the same in the docs
 
they are different things. the module from your link is something you'll almost never use
and you'll have an easier time understanding your code snipped from above if you look at the list after every step:
>>> listt = [1,2,3,4]
>>> listt
[1, 2, 3, 4]
>>> listt[2] = [8]
>>> listt
[1, 2, [8], 4]
>>> listt[2:2]
[]
>>> listt[2:2] = [7,7]
>>> listt
[1, 2, 7, 7, [8], 4]
foo[2] = ... assigns to a single element, so you end up with a nested list
 
12:32 PM
that's what i expected at each step thoguh
 
foo[2:2] is a slice containing the 3rd element, so now you replace a slice with another list -> you replace the (single-element) list that contains the 3rd element, with a new list containing [7, 7]
 
my point is just that i don't get why a[2:2]=[1,2] inserts the elements 1,2
 
see my last message ;)
 
yes but you are adding a bit which isn't very clear
i think the problem is that a[2:2] means something else when on the left or the right of the equal sign
 
Depends on how you look at it. You can certainly argue that it means two different things, but then a also means two different things depending on which side of the equal sign it's on
 
12:45 PM
i see
can you expand? I'm new to python
 
a on the left side of the equal sign means "store the value here". On the right side it means "get this value"
Same thing for lists. On the left side a[2:2] means "store the values between 2 and 2" and on the right side it means "give me the values between 2 and 2"
 
indeed, that's why we didn't agree with the other commentator
however that doesn't explain why the array is unpacked @Aran-Fey
 
What's unpacked where?
 
destructured
 
I don't know which line of code you're talking about
 
12:48 PM
a[2:2] = [2,3]
a[2] = [2,3]
one vs the other
a[2] = [2,3] result it's expected to me, but not the output of the other
 
2 refers to an index, while 2:2 refers to a slice/range/whatchamacallit
a[2] = [2,3] means "store the value [2,3] at index 2 in a"
 
so ? i doubt that explains the result
you'd expect [2,3] being stored in a slice of a
not in the whole a
 
a[2:2] = [2,3] means "store the values 2 and 3 between indices 2 and 2 in a"
 
so it's not slicing anything
 
@MahNeh What does that mean? How is that "the whole a"?
 
12:52 PM
no item from the original a is missing
also, when there is a slice here is for which items to remove, not which items to keep
 
What did you expect to happen?
 
so in the right of the equal sign `a[2:4]` means to get item at position 2 and 3

on the left of the equal sign `a[2:4]`, means to remove elements 2 and 3 and put whats on the RHS of the equal sign at position 2.
is this a correct interpretation ?
(i'm testing it as well)
 
Yes
 
now i can say what I don't get
which is that i'd expect the full array in the RHS at position 2
 
Alternatively, 2:4 refers to the slice between indices 2 and 4. On the right side of the equal sign it means "give the values there", and on the left side it means "overwrite the values there"
 
12:56 PM
not the elements of it
 
So there would be no difference between a[2] and a[2:2]?
 
no, exactly
only if the index is different, say a[2:3]
imho that's more intuitive, but i guess that's just not how it is
 
Nope. If you use a colon, you refer to a slice of the list. 2:2 means an empty slice
 
yeah, that's not the problem anyways, but why the overwrite goes differently
 
It's better this way. You know for a fact that the operation some_list[x:y] will return a list, and not just a single item, no matter what the values of x and y are
 

« first day (4942 days earlier)