0% found this document useful (0 votes)
10 views22 pages

TP 01

Uploaded by

walidbourmel44
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views22 pages

TP 01

Uploaded by

walidbourmel44
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

TP 01 Machine

Learning
Introduction
Objective: Setting Up a Machine Learning Environment
What is Machine Learning?

In fact, Arthur Samuel, one of the pioneers of machine learning,


defined machine learning as a “Field of study that gives computers
the ability to learn without being explicitly programmed.
Some MachineLearning applications:

Healthcare, diagnosis and Disease Prediction: ML


algorithms can analyze patient data to predict the likelihood of
diseases such as cancer, diabetes, and heart disease.

Climate Prediction: ML models predict weather patterns,


climate change impacts, and natural disasters like hurricanes or
floods.

Chatbots and Virtual Assistants: AI-powered chatbots (e.g.,


Alexa, Google Assistant, Siri) use ML for understanding speech
and providing relevant responses.
What is Python?

Python was created by Guido van Rossum, and released in 1991.


It’s one of the most popular and most practical programming
languages. It’s very useful for Rapid Application Development due to:
• its simple and easy syntax.
• its support and compatibility to modules and packages.

Here are some of Python’s other features:

• High-level programming language


• Dynamically-typed
• Interpreted language
Python Installation with
Anaconda

There are several ways to install Python. Let's take a look at the most
efficient way:
Installing anaconda for windows, macOS & Linux.

Note that Anaconda is a free and open-source distribution of


Python. https://www.anaconda.com/
https://www.anaconda.com/
download
Creating and Managing
Environments

>> Anaconda prompt


A Conda environment is an
isolated directory that contains conda --version
its own dependencies and
libraries. conda env list
conda create -n MyEnv
Why use environments? Different
python=3.8
ML projects might require activate MyEnv
different versions of libraries.
Installing Packages

Package is a collection of modules (Python files) that provides specific


functionality.

• NumPy: It offers a large collection of


high-level mathematical functions to
operate on large and multi-dimensional
arrays like matrices.
• Pandas: It offers high-performance, easy-
to-use data structures and data analysis
tools.
• Matplotlib and Seaborn: Are 2D
plotting libraries that produce quality
figures. We will use them for data
visualization.
• Scikit.learn: It offers various
Installing Packages

>> Anaconda prompt


conda list
conda install numpy

This command installs the latest available version of NumPy, according


to the channels configured in Conda.
Conda will automatically resolve dependencies to ensure compatibility,
but it will always try to install the most up-to-date version unless
constraints (like other package versions) prevent it.
Installing Packages

To check the version of a package

>> Anaconda prompt


conda list
conda list numpy
Installing Packages

You can directly install the desired version of NumPy, and Conda
will replace the current version
>> Anaconda prompt
conda remove numpy (optional
step)
conda install numpy=1.19
This command installs version 1.19 of the NumPy package.
This is useful when:
•You need to ensure compatibility with other packages or projects that
require a specific version of NumPy.
•You want to work with a stable or known version that you've already tested.
Conda channel
Conda channel
Conda, a channel is a location where packages are stored and
from which Conda installs those packages. Each channel can
host various packages, and they can be managed and accessed
when you use Conda commands.

The default channel is the package


repository that comes with the Anaconda
distribution.
• Stability
• Simplicity
• Limited Packages
Conda-forge is a community-driven channel that provides
a wide range of packages for Conda.

• Community Maintained
• Cross-platform Compatibility
• Better dependency resolution

>> Anaconda prompt


conda install numpy -c conda-forge
PyPI is the official repository for Python packages, where
developers can publish and share their libraries.

•Vast Library of Packages


•Latest Versions

>> Anaconda prompt


pip install numpy
Accessing old environnement
revisions
>> Anaconda prompt
Conda list --revisions

>> Anaconda prompt


Conda install –-revision=24
Sharing an environment

>> Anaconda prompt


Activate MyEnv
conda env export > MyEnvFile.yml

>> Anaconda prompt


conda env create –f MyEnvFile.yml –n MyNewEnv
Integrated Development
Environment (IDE)
We'll now need an Integrated Development
Environment (IDE) for writing, running, and debugging
our Python code.

Here are some popular IDEs that are commonly used for
Python and machine learning development:
• PyCharm
• Jupyter Notebook
• VS Code (Visual Studio Code)
• Spyder
Integrated Development
Environment (IDE)
Spyder IDE built specifically for data science and
scientific computing, included in Anaconda by
default.
•Why Use It:
• Integrated with Anaconda, so it works seamlessly with Conda
environments.
• Great for data science with built-in plotting and variable explorer.
• Ideal for interactive coding and experimenting with machine
>> Anaconda
learning code. prompt
conda install -c conda-forge spyder
spyder
>> Anaconda prompt Install tf gpu package
conda install tensorflow-gpu=2.3
tensorflow=2.3=mkl_py38h1fcfbd6_0
>> Python
tf.config.list_physical_devices('GPU')

>> Anaconda prompt


conda remove -n MyEnv --all Remove
environment
>> PythonCheck package version in
python
import numpy
print(numpy.__version__)
Practical Exercise : Setting Up a Machine Learning Environment
-Create a Conda environment and install the necessary packages for machine learning.
-Check the installed packages in your environment.
-Run a Python script to verify if TensorFlow can access the GPU (if applicable).

Python 3.8
Spyder 5.4.3

Install Required Packages using Conda:


•numpy
•pandas
•matplotlib
•seaborn
•scikit-learn
•tensorflow-gpu (if using a GPU) or tensorflow (for CPU)
•keras

You might also like