Santiago Profile picture
19 Oct, 7 tweets, 1 min read
One of the most useful things you can learn:

Greedy algorithms, how they work, and how to solve problems using them.

Here is why they are fundamental: ↓
Greedy algorithms:

• Pretty intuitive to understand
• Easy to come up with them
• A great way to solve many problems

Optimization is the root of all evil. Many times, a greedy solution is all you need to solve a problem.
At each step, a greedy algorithm always makes the best optimal choice.

(Unfortunately, this approach is not always guaranteed to converge to the optimal solution. More about this later.)

Here is an example problem where you could use a greedy algorithm:
"Given a list of tasks and the time it takes to complete them, calculate the maximum number of tasks you can do in a day."

Here is how you could solve it:

1. Sort the list in increasing order.
2. Consecutively select a task until you can't fit another one in a day.
Greedy algorithms don't always find the optimal solution.

An example: Find the cheapest route between two cities on a map.

Always taking the cheapest next step from where you're at will not get you the optimal route.
There are problems for which greedy algorithms are perfect.

A couple of successful applications:

1. Dijkstra’s algorithm: Find the shortest path between two nodes in a weighted graph.

2. Huffman encoding: A method to compress data.
As a software engineer, understanding how to build greedy solutions is a critical skill.

I usually always start with a greedy solution as a baseline. I can always optimize further when necessary.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Santiago

Santiago Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @svpino

15 Oct
If you haven't looked into machine learning yet, you better start now.
I started looking seriously into machine learning around spring of 2015.

The field was very different back then.

Just to give you an idea, the top most popular deep learning frameworks didn't exist:

• TensorFlow was released at the end of 2015
• PyTorch in 2016
In just 5 - 6 years we have gone from "read my paper... it's cool" to "holly shit, look what my phone is doing!"

Machine learning has turned the industry upside down.

We have gone from "that's impossible" to "of course we can!" in record time.
Read 23 tweets
12 Oct
A big part of my work is to build computer vision models to recognize things.

It's usually ordinary stuff: An antenna, a fire extinguisher, a bag, a ladder.

Here is a trick I use to solve some of these problems.
The good news about having to recognize everyday objects:

There are a ton of pre-trained models that help with that. You can start with one of these models and get decent results out of the box.

This is important. I'll come back to it in a second.
Many of the use cases that I tackle are about "augmenting" the people who are working with machine learning.

Let's say you have a team looking at drone footage to find squirrels. Eight hours every day looking at images.

This sucks. I can help with that.
Read 19 tweets
11 Oct
Last week I trained a machine learning model using 100% of the data.

Then I used the model to predict the labels on the same dataset I used to train it.

I'm not kidding. Hear me out: ↓
Does this sound crazy?

Yes.

Would I be losing my shit if I heard that somebody did this?

Yes.

So what's going on?
I have a dataset with a single numerical feature and a binary target.

I need to know the threshold that better separates the positive samples from the negative ones.

I don't want a model to make predictions; I just need to know the threshold.
Read 10 tweets
8 Oct
I get asked about machine learning all the time.

Here are my answers to some of these questions: ↓
Q: Where do I start?

Start by learning how to program.

Take your time. Usually, a solid year of Python experience will set you up for success.

Kaggle has a great introductory tutorial to get you started with Python.
Q: I already have plenty of Python experience. Now what?

For most people, I recommend the "Machine Learning Crash Course" created by Google or the "Intro to Machine Learning" from Kaggle.

If you are feeling adventurous, take "Machine Learning" from @AndrewYNg on Coursera.
Read 15 tweets
7 Oct
More data is usually not the way to turn around a mediocre machine learning model.

I've heard too many times that deep learning's silver bullet is throwing more data at a problem.

That hasn't been my experience.

Good Data is better than Big Data.
More data, even with a moderate amount of mislabeled examples, will hurt your model.
Assuming the data is good, then more data is probably not going to be a problem.

Unfortunately, the quality of data is usually inversely proportional to the amount of it. More data is often mediocre data.

But if your data is good, no harm.
Read 4 tweets
6 Oct
Which one do you prefer? The code on the left, or the code on the right?

I'd love to hear why. ImageImage
I always was a “left” kind of programmer.

For quite some time now I’ve been forcing myself to use the right style.

Look at “EAFP vs LBYL”. Pretty interesting arguments.

- LBYL - Look Before You Leap. (Left)

- EAFP - Easier to Ask for Forgiveness than Permission. (Right)
Also, I love all of you, but it’s usually a good practice to answer the question using one of the two options instead of going with a third, imaginary option that you feel is better for your imaginary problem.

😋
Read 5 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(