Following up from my previous thread, let's continue taking a look at some additional itertools methods
Some of them, as you will see, have very similar built-in versions but the key here is: itertools works on iterables and generators that are lazy evaluated collections
1/14🧵
One example is the method islice. It does slicing but for iterables (potentially endless collections). The main difference is that it doesn't accept negative indexes like regular slicing.
If you know a little bit of SQL, you know about the GROUP BY statement. Itertools has a similar function but with some caveats!
word = 'aabbbnnnaa'
it.groupby(word)
>>> a ['a','a']
>>> b ['b', 'b','b']
>>> a ['a','a']
11/14🧵
💡: The main difference between itertools version from the SQL version is that it won't group elements if they are out of order. It will create different groups instead.
12/14🧵
I've talked about some other itertools methods here:
Machine learning goes beyond Deep Learning and Neural Networks
Sometimes a simpler technique might give you better results and be easier to understand
A very versatile algorithm is the Decision Forest
🌴🌲🌳?
What is it and how does it work?
Let me tell you..
[7 min]
1/10🧵
Before understanding a Forest, let's start by what's a Tree
Imagine you have a table of data of characteristics of Felines. With features like size, weight, color, habitat and a column with the labels like lion, tiger, house cat, lynx and so on.
2/10🧵
With some time, you could write a code based on if/else statements that could, for each a row in the table, decide which feline it is
This is exactly what a Decision Tree does
During its training it creates the if/elses