Python Environment Setup for Machine Learning

James Briggs · Beginner ·🧠 Large Language Models ·5y ago
Skills: ML Pipelines80%

Key Takeaways

This video teaches how to set up a Python environment for Machine Learning and Data Science

Full Transcript

hello and welcome to this video on how to set up a python environment specifically for machine learning so this is often an overlooked part of machine learning and there's not that many tutorials out there on how to do this properly so i thought it'd be a good idea to just go through this and explain exactly how i set up my environment so you can see here we have jupiter and first thing you might notice is that i have these different environments you have the default python 3 base environment and then i also have this gcp which i use for the cloud and then i also have this one which is my machine learning environment now the difference between each of these is the machine learning environment specifically has packages in python for machine learning like tensorflow pytorch transformers pandas numpy it has all of those packages but nothing else so there's no excess baggage if you like so i wanted to just go through and explain how to actually set this up so we're going to close this jupiter notebook i'm going to open this new anaconda prompt here so i'm assuming that you have already installed python and that you are using the anaconda distribution so if you are not using this you can download it over from here you can head over to anaconda.com and you just click on products and individual edition over here and just download okay so the installation for anaconda is pretty simple if you're on windows it's a little different if you're on linux and i i don't know how it is on mac but generally it's it's pretty straightforward and if you do need any help with it you can just you can find out quite quickly so once we have that installed we want to go over to our anaconda prompt and to make sure that we have installed it correctly we just want to type python v and this will show us the version of python uh that we have so i'm at the moment using python 3.8.3 just make that a little bigger and okay if that works that's good so at the moment we're using the core based environment that you can see here and that is just the default environment that gets installed whenever you install the anaconda distribution but what we want to do is actually create a new environment which is our machine learning environment to do that we use the syntax like this so we condo create conda is just referring to anaconda or name so you can also write this as name or again with n and then you want to enter your environment name here and then you would also write python and your python version and at the end of that you would also type anaconda so for us i'm going to use a [Music] environment name of mln like that and i also want to be installing python 3.8 and that should be everything so we'll just enter and now python will work through and actually install that so i've already installed a mlm before but i uninstalled it so it's coming up this warning saying it already exists but i'm going to continue creating the environment because i want to reinstall it so put yes you shouldn't see that on yours and then this will take a little bit of time just to get everything together okay so now we are just showing a list all the packages that will be installed um so we just want to accept that so press yes and enter now we'll go ahead and install all of those okay so everything is set up now we can switch over to our new environment so at the moment we're in base we can switch over to our new environment with conda activate and the environment name which in our case is mln so let's go ahead and do that and now you can see that the name here is switched to mln which is our new environment now we just need to install our machine learning packages so we're going to go ahead and install the basics so we have pandas and map plotlib we're going to install both of those with a condensole so we have two options here we have conda or pip to install our packages generally conda will most likely integrate with your environment better so it's usually a good idea to try it at first if that doesn't work then try pip install so we'll go ahead and condense soul we're gonna do pandas and matplotlib then add anything else here that you feel that you might also need but this is all we're gonna go with so it's a good point noting that we also need numpy but numpy is included as a dependency of pandas so we don't need to explicitly mention numpy here and that will go ahead and ask us for permission to install the packages that it finds we click yes and then we go ahead with the installation again now we can go ahead and install tensorflow transformers and pi torch which are all machine learning frameworks so tensorflow we can install it quite easily all we need to do is click on the install tensorflow okay so now we have the yes or no from tensorflow okay so tensorflow is now installed so we can now go ahead and install transformers so transformers we are going to use pip because condor doesn't recognize the most recent versions of the transformers library at the time of recording at least so we have to use pip to get the most recent versions so we pip install transformers there we go and finally we have pie torch which is slightly more complex but we make it quite easy by just taking a look at the pie torch start locally guide which you can find here so pytorch.org gets started locally and all we do is we come down to the start locally bit we select our pytorch build so this is the stable release and this is like a beta release which gets released more often but it's more like to have bugs on errors in so i think most people will probably want to avoid this you can choose your os so for me to windows package manager so that is condo you can also use pip but i would recommend that conda because it will install the dependencies we need as well we're using python and then this bottom one here refers to cuda so we used cuda as the gpu acceleration library so essentially with this if you have a nvidia gpu cuda lets you use it speed up any machine learning tests that you have um in either pi touch or tensorflow so you can read tensorflow's gpu setup guide if you do have a gpu this is quite useful so you just you head on down to the bottom here or if you if you're on linux as this guide is always quite useful and then we have the windows setup here so all you need to do is install all of these which is reasonably straightforward but there are a lot a lot of good guides out there if you do need help with it and then you just head on down and set your paths so that tensorflow slash pi touch you can actually see cuda another useful guide as well is this nvidia cuda installation guide which can be quite useful as well now i would recommend using cuda 10.2 at the time recording so unless you are using the latest rtx 30 series so that is the nvidia geforce rtx 390 3080 and i think it's 30 70. so the support flows is a little bit sketchy at the moment and you will actually need cuda 11 alongside the nightly builds of pytorch and tensorflow so this is what i mentioned over over here that's a little bit more difficult and i'm i'm not going to be covering that here but again there are a lot of good guides out there if you do need help with it so if you don't have a gpu or you just don't care about gpu acceleration you just click none and it will change the command down here which we'll be using for our installation so i'll be using this command here so we're doing a conda install and then we have a few packages not just pi torch here pie torch torch vision torch audio cuda toolkit and first we are using a 10.2 and then we it's our channel to pi torch as well now we go ahead and install that so just select yes again and now that is our environment completely set up so all we need to do now is actually add this environment to jupiter so remember at the salt we had that little box and we had python 3 gcp and ml so we're going to add a new one called ml environment so to do that we need to install ipad kernel and with that ipi kernel we are going to install our new environment so we do that by specifying the name of it here mln and then we also want to set the display name so this is the name that we will see when we enter into jupiter lab and we can have that box so this can be anything you want so for me i'm just going to put ml environment let me just run that again okay so that is ready and now we can just go ahead switch back to our base environment which is our default environment and now just open up jupiter lab and we can see here we now have this other ml environment and this is the one that we just created so that is it for this short video i hope it's been useful and i will see you again in the next one thanks for watching bye

Original Description

Everything you need for a Python environment set up for Machine Learning and Data Science! 📕 Article: https://towardsdatascience.com/how-to-setup-python-for-machine-learning-173cb25f0206 🤖 70% Discount on the NLP With Transformers in Python course: https://bit.ly/3DFvvY5 Thumbnail background by Christian Wiediger on Unsplash https://unsplash.com/@christianw
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from James Briggs · James Briggs · 9 of 60

1 Stoic Philosophy Text Generation with TensorFlow
Stoic Philosophy Text Generation with TensorFlow
James Briggs
2 How to Build TensorFlow Pipelines with tf.data.Dataset
How to Build TensorFlow Pipelines with tf.data.Dataset
James Briggs
3 Every New Feature in Python 3.10.0a2
Every New Feature in Python 3.10.0a2
James Briggs
4 How-to Build a Transformer for Language Classification in TensorFlow
How-to Build a Transformer for Language Classification in TensorFlow
James Briggs
5 How-to use the Kaggle API in Python
How-to use the Kaggle API in Python
James Briggs
6 Language Generation with OpenAI's GPT-2 in Python
Language Generation with OpenAI's GPT-2 in Python
James Briggs
7 Text Summarization with Google AI's T5 in Python
Text Summarization with Google AI's T5 in Python
James Briggs
8 How-to do Sentiment Analysis with Flair in Python
How-to do Sentiment Analysis with Flair in Python
James Briggs
Python Environment Setup for Machine Learning
Python Environment Setup for Machine Learning
James Briggs
10 Sequential Model - TensorFlow Essentials #1
Sequential Model - TensorFlow Essentials #1
James Briggs
11 Functional API - TensorFlow Essentials #2
Functional API - TensorFlow Essentials #2
James Briggs
12 Training Parameters - TensorFlow Essentials #3
Training Parameters - TensorFlow Essentials #3
James Briggs
13 Input Data Pipelines - TensorFlow Essentials #4
Input Data Pipelines - TensorFlow Essentials #4
James Briggs
14 6 of Python's Newest and Best Features (3.7-3.9)
6 of Python's Newest and Best Features (3.7-3.9)
James Briggs
15 Novice to Advanced RegEx in Less-than 30 Minutes + Python
Novice to Advanced RegEx in Less-than 30 Minutes + Python
James Briggs
16 Building a PlotLy $GME Chart in Python
Building a PlotLy $GME Chart in Python
James Briggs
17 How-to Use The Reddit API in Python
How-to Use The Reddit API in Python
James Briggs
18 How to Build Custom Q&A Transformer Models in Python
How to Build Custom Q&A Transformer Models in Python
James Briggs
19 How to Build Q&A Models in Python (Transformers)
How to Build Q&A Models in Python (Transformers)
James Briggs
20 How-to Decode Outputs From NLP Models (Python)
How-to Decode Outputs From NLP Models (Python)
James Briggs
21 Identify Stocks on Reddit with SpaCy (NER in Python)
Identify Stocks on Reddit with SpaCy (NER in Python)
James Briggs
22 Sentiment Analysis on ANY Length of Text With Transformers (Python)
Sentiment Analysis on ANY Length of Text With Transformers (Python)
James Briggs
23 Unicode Normalization for NLP in Python
Unicode Normalization for NLP in Python
James Briggs
24 The NEW Match-Case Statement in Python 3.10
The NEW Match-Case Statement in Python 3.10
James Briggs
25 Multi-Class Language Classification With BERT in TensorFlow
Multi-Class Language Classification With BERT in TensorFlow
James Briggs
26 How to Build Python Packages for Pip
How to Build Python Packages for Pip
James Briggs
27 How-to Structure a Q&A ML App
How-to Structure a Q&A ML App
James Briggs
28 How to Index Q&A Data With Haystack and Elasticsearch
How to Index Q&A Data With Haystack and Elasticsearch
James Briggs
29 Q&A Document Retrieval With DPR
Q&A Document Retrieval With DPR
James Briggs
30 How to Use Type Annotations in Python
How to Use Type Annotations in Python
James Briggs
31 Extractive Q&A With Haystack and FastAPI in Python
Extractive Q&A With Haystack and FastAPI in Python
James Briggs
32 Sentence Similarity With Sentence-Transformers in Python
Sentence Similarity With Sentence-Transformers in Python
James Briggs
33 Sentence Similarity With Transformers and PyTorch (Python)
Sentence Similarity With Transformers and PyTorch (Python)
James Briggs
34 NER With Transformers and spaCy (Python)
NER With Transformers and spaCy (Python)
James Briggs
35 Training BERT #1 - Masked-Language Modeling (MLM)
Training BERT #1 - Masked-Language Modeling (MLM)
James Briggs
36 Training BERT #2 - Train With Masked-Language Modeling (MLM)
Training BERT #2 - Train With Masked-Language Modeling (MLM)
James Briggs
37 Training BERT #3 - Next Sentence Prediction (NSP)
Training BERT #3 - Next Sentence Prediction (NSP)
James Briggs
38 Training BERT #4 - Train With Next Sentence Prediction (NSP)
Training BERT #4 - Train With Next Sentence Prediction (NSP)
James Briggs
39 FREE 11 Hour NLP Transformers Course (Next 3 Days Only)
FREE 11 Hour NLP Transformers Course (Next 3 Days Only)
James Briggs
40 New Features in Python 3.10
New Features in Python 3.10
James Briggs
41 Training BERT #5 - Training With BertForPretraining
Training BERT #5 - Training With BertForPretraining
James Briggs
42 How-to Use HuggingFace's Datasets - Transformers From Scratch #1
How-to Use HuggingFace's Datasets - Transformers From Scratch #1
James Briggs
43 Build a Custom Transformer Tokenizer - Transformers From Scratch #2
Build a Custom Transformer Tokenizer - Transformers From Scratch #2
James Briggs
44 3 Traditional Methods for Similarity Search (Jaccard, w-shingling, Levenshtein)
3 Traditional Methods for Similarity Search (Jaccard, w-shingling, Levenshtein)
James Briggs
45 3 Vector-based Methods for Similarity Search (TF-IDF, BM25, SBERT)
3 Vector-based Methods for Similarity Search (TF-IDF, BM25, SBERT)
James Briggs
46 Building MLM Training Input Pipeline - Transformers From Scratch #3
Building MLM Training Input Pipeline - Transformers From Scratch #3
James Briggs
47 Training and Testing an Italian BERT - Transformers From Scratch #4
Training and Testing an Italian BERT - Transformers From Scratch #4
James Briggs
48 Faiss - Introduction to Similarity Search
Faiss - Introduction to Similarity Search
James Briggs
49 Angular App Setup With Material - Stoic Q&A #5
Angular App Setup With Material - Stoic Q&A #5
James Briggs
50 Why are there so many Tokenization methods in HF Transformers?
Why are there so many Tokenization methods in HF Transformers?
James Briggs
51 Choosing Indexes for Similarity Search (Faiss in Python)
Choosing Indexes for Similarity Search (Faiss in Python)
James Briggs
52 Locality Sensitive Hashing (LSH) for Search with Shingling + MinHashing (Python)
Locality Sensitive Hashing (LSH) for Search with Shingling + MinHashing (Python)
James Briggs
53 How LSH Random Projection works in search (+Python)
How LSH Random Projection works in search (+Python)
James Briggs
54 IndexLSH for Fast Similarity Search in Faiss
IndexLSH for Fast Similarity Search in Faiss
James Briggs
55 Faiss - Vector Compression with PQ and IVFPQ (in Python)
Faiss - Vector Compression with PQ and IVFPQ (in Python)
James Briggs
56 Product Quantization for Vector Similarity Search (+ Python)
Product Quantization for Vector Similarity Search (+ Python)
James Briggs
57 How to Build a Bert WordPiece Tokenizer in Python and HuggingFace
How to Build a Bert WordPiece Tokenizer in Python and HuggingFace
James Briggs
58 Metadata Filtering for Vector Search + Latest Filter Tech
Metadata Filtering for Vector Search + Latest Filter Tech
James Briggs
59 Build NLP Pipelines with HuggingFace Datasets
Build NLP Pipelines with HuggingFace Datasets
James Briggs
60 Composite Indexes and the Faiss Index Factory
Composite Indexes and the Faiss Index Factory
James Briggs

Related Reads

📰
Top AI Papers on Hugging Face - 2026-07-15
Explore the top AI papers on Hugging Face, focusing on agent longevity, robotics, and efficient model training methods
Dev.to AI
📰
Integrating Open-Weight LLMs as Drop-In API Replacements: A Practical Guide
Learn to integrate open-weight LLMs as drop-in API replacements for a vendor-locked-in free solution
Dev.to AI
📰
Build a Bounded JSON Repair Loop for LLM Output in Python
Learn to build a bounded JSON repair loop for LLM output in Python to separate syntax, shape, and semantic errors
Dev.to · Alex Chen
📰
How I Built a Multi-Page AI Website Generator for Nigerian SMBs — Architecture, LLM Prompting, and Lessons Learned
Learn how to build a multi-page AI website generator for small businesses using LLM prompting and key architectural decisions
Dev.to · Innocent Oyebode
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch →