For a long time, I didn't understand how to use Virtual Environments in Python šŸ.

If this is just, let's end it here and now: šŸ§µšŸ‘‡

[2] Virtual Environments let you deal with the dependencies that your code has with external Python libraries.

It avoids having conflicts when your projects depend on different versions of the same library.

šŸ‘‡
[3] Let's imagine that you are building your first Python project and you install the "requests" library:

pip install requests

You get version 2.24.0 installed in your system.

šŸ‘‡
[4] A month later, you decide to work on your second project. It also needs the "requests" library.

But the latest version is not 2.24.0 anymore.

Now version 3 is available, and that's the one you want to use!

šŸ‘‡
[5] You could upgrade your entire system to version 3, but then you'll be potentially breaking the first project you built that depends on 2.24.0!

Can you imagine this happening on a server with many more applications running?

šŸ‘‡
[6] Virtual environments solve this problem.

The first step for every new project is to create a virtual environment for it.

Some people have a central location where they store all environments. I prefer to keep them inside the project folder.

šŸ‘‡
[7] You can create a new virtual environment with Python 3 using the following command:

python3 -m venv .myvenv

Then, you can use "source" to activate the environment.

At this point, you'll have full isolation for your project.

šŸ‘‡
[8] If you install any libraries within a virtual environment, they will never mess with the libraries installed at the system level or other virtual environments.

And this is great!

Here is a @realpython's article covering virtual environments: https://t.co/lgXqJDUlKw
[9] The built-in "venv" module is not the only way to create virtual environments. Here are other options:

- conda
- pipenv
- virtualenv

What's your choice?

More from Santiago

You gotta think about this one carefully!

Imagine you go to the doctor and get tested for a rare disease (only 1 in 10,000 people get it.)

The test is 99% effective in detecting both sick and healthy people.

Your test comes back positive.

Are you really sick? Explain below šŸ‘‡

The most complete answer from every reply so far is from Dr. Lena. Thanks for taking the time and going through


You can get the answer using Bayes' theorem, but let's try to come up with it in a different —maybe more intuitive— way.

šŸ‘‡


Here is what we know:

- Out of 10,000 people, 1 is sick
- Out of 100 sick people, 99 test positive
- Out of 100 healthy people, 99 test negative

Assuming 1 million people take the test (including you):

- 100 of them are sick
- 999,900 of them are healthy

šŸ‘‡

Let's now test both groups, starting with the 100 people sick:

ā–«ļø 99 of them will be diagnosed (correctly) as sick (99%)

ā–«ļø 1 of them is going to be diagnosed (incorrectly) as healthy (1%)

šŸ‘‡

More from Machine learning

This is a Twitter series on #FoundationsOfML.

ā“ Today, I want to start discussing the different types of Machine Learning flavors we can find.

This is a very high-level overview. In later threads, we'll dive deeper into each paradigm... šŸ‘‡šŸ§µ

Last time we talked about how Machine Learning works.

Basically, it's about having some source of experience E for solving a given task T, that allows us to find a program P which is (hopefully) optimal w.r.t. some metric


According to the nature of that experience, we can define different formulations, or flavors, of the learning process.

A useful distinction is whether we have an explicit goal or desired output, which gives rise to the definitions of 1ļøāƒ£ Supervised and 2ļøāƒ£ Unsupervised Learning šŸ‘‡

1ļøāƒ£ Supervised Learning

In this formulation, the experience E is a collection of input/output pairs, and the task T is defined as a function that produces the right output for any given input.

šŸ‘‰ The underlying assumption is that there is some correlation (or, in general, a computable relation) between the structure of an input and its corresponding output and that it is possible to infer that function or mapping from a sufficiently large number of examples.

You May Also Like

Great article from @AsheSchow. I lived thru the 'Satanic Panic' of the 1980's/early 1990's asking myself "Has eveyrbody lost their GODDAMN MINDS?!"


The 3 big things that made the 1980's/early 1990's surreal for me.

1) Satanic Panic - satanism in the day cares ahhhh!

2) "Repressed memory" syndrome

3) Facilitated Communication [FC]

All 3 led to massive abuse.

"Therapists" -and I use the term to describe these quacks loosely - would hypnotize people & convince they they were 'reliving' past memories of Mom & Dad killing babies in Satanic rituals in the basement while they were growing up.

Other 'therapists' would badger kids until they invented stories about watching alligators eat babies dropped into a lake from a hot air balloon. Kids would deny anything happened for hours until the therapist 'broke through' and 'found' the 'truth'.

FC was a movement that started with the claim severely handicapped individuals were able to 'type' legible sentences & communicate if a 'helper' guided their hands over a keyboard.