Skip to content

Feat(docs): Improve python course section 1.1 #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 57 additions & 11 deletions docs/1. Initializing/1.1. Python.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
description: Understand why Python is the preferred language for AI/ML projects and learn how to choose the right Python version and install it for your development environment.
---

# 1.1. Python
# 🐍 1.1. Python

## What is Python?
## What is Python?

[Python](https://www.python.org/) is a dynamic, high-level programming language known for its ease of learning and readability, making it a favorite among developers across various disciplines, including web development, automation, data science, and machine learning. It stands out for its simplicity and the vast ecosystem of third-party packages, allowing developers to build applications quickly and efficiently. Given its popularity, reflected in rankings such as the [Tiobe Index](https://www.tiobe.com/tiobe-index/) and [IEEE Spectrum Annual Ranking](https://spectrum.ieee.org/the-top-programming-languages-2023), Python is a staple in the programming world. For beginners and seasoned developers alike, Python offers a balance of readability and power, supported by a rich standard library and an extensive array of packages for diverse application needs.

Expand All @@ -13,27 +13,73 @@ description: Understand why Python is the preferred language for AI/ML projects
<figcaption>Python(<a href="https://xkcd.com/353/">source</a>)</figcaption>
</figure>

## Why is Python preferred for AI/ML projects?
## 🤖 Why is Python preferred for AI/ML projects?

Python's preeminence in AI and machine learning is attributed to its comprehensive selection of libraries and frameworks tailored for these fields, such as [Pandas](https://pandas.pydata.org/) for data handling, [Scikit-Learn](https://scikit-learn.org/) for machine learning algorithms, and [PyTorch](https://pytorch.org/) and [TensorFlow](https://www.tensorflow.org) for advanced deep learning projects. Its user-friendly syntax supports rapid prototyping and iterative development, essential in the AI/ML workflow. Additionally, Python's interoperability with high-performance languages like C and C++ enables developers to optimize computational efficiency without sacrificing development speed or ease of use, making it the go-to language for AI/ML endeavors.
Python's dominance in AI and machine learning is no accident. It stems from a powerful combination of a simple, readable syntax and an unparalleled ecosystem of specialized libraries. This allows developers to move quickly from idea to implementation, a crucial advantage in the fast-paced world of AI/ML.

## Is Python a good language for MLOps?
Here are some of the key reasons for Python's popularity:

- **Vast Ecosystem of Libraries**: Python boasts a rich collection of open-source libraries that cover the entire AI/ML workflow, from data manipulation to model deployment.
- **Ease of Use and Readability**: Python's clean syntax makes it easy to learn and read, which helps in collaborative projects and reduces the cost of maintenance.
- **Flexibility**: Python is a general-purpose language, which means it can be used for a wide range of tasks, including web development, automation, and data analysis, making it a versatile tool for any MLOps professional.
- **Strong Community Support**: Python has a large and active community, which means you can easily find help, tutorials, and documentation.

Here's a quick look at some of the most popular AI/ML libraries in the Python ecosystem:

| Library | Category | Description |
| --------------------------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| [NumPy](https://numpy.org/) | Numerical Computing | The fundamental package for scientific computing with Python, providing support for large, multi-dimensional arrays and matrices. |
| [Pandas](https://pandas.pydata.org/) | Data Manipulation | A powerful library for data analysis and manipulation, offering data structures like DataFrames that are essential for cleaning and preparing data. |
| [Scikit-learn](https://scikit-learn.org/) | Machine Learning | A comprehensive library for classical machine learning algorithms, including classification, regression, clustering, and dimensionality reduction. |
| [TensorFlow](https://www.tensorflow.org/) | Deep Learning | An end-to-end open-source platform for machine learning, developed by Google. |
| [PyTorch](https://pytorch.org/) | Deep Learning | An open-source machine learning library developed by Facebook's AI Research lab, known for its flexibility and ease of use. |
| [Matplotlib](https://matplotlib.org/) & [Seaborn](https://seaborn.pydata.org/) | Data Visualization | Libraries for creating static, animated, and interactive visualizations in Python. |

Its user-friendly syntax supports rapid prototyping and iterative development, essential in the AI/ML workflow. Additionally, Python's interoperability with high-performance languages like C and C++ enables developers to optimize computational efficiency without sacrificing development speed or ease of use, making it the go-to language for AI/ML endeavors.

## 🛠️ Is Python a good language for MLOps?

Python excels in the MLOps domain, offering a blend of simplicity for algorithm development and the robustness required for operational workflows. The key to maximizing Python's benefits in MLOps lies in adopting best practices for code quality and maintainability. This course covers strategies for effective Python code structuring and validation, ensuring that Python's flexibility and extensive toolkit can be leveraged effectively within MLOps pipelines.

## Can you use other languages for AI/ML?
## 🔄 Can you use other languages for AI/ML?

While Python dominates the AI/ML landscape, other languages like [R](https://www.r-project.org/) or [Julia](https://julialang.org/) also provide capabilities for statistical analysis and machine learning. Each of these languages brings unique strengths, whether in performance, syntax, or domain specificity. Transitioning to or incorporating these languages in AI/ML projects is possible but requires careful consideration of their ecosystems and how they fit into the broader project goals.

## Which Python version should you use?
## 📦 Which Python version should you use?

Choosing the right Python version is a critical step in setting up your project. While it's tempting to always use the latest version, compatibility with key libraries and your production environment is more important.

As a general rule, it's best to **use the latest stable version of Python that is supported by your project's key dependencies**. For most AI/ML projects, this means **Python 3.9 or newer**.

Here's a simple process for choosing a version:

1. **Check your project's dependencies**: Look at the `pyproject.toml` or `requirements.txt` file to see if a specific Python version is required.
2. **Check library compatibility**: If you're starting a new project, check the documentation for your key libraries (like TensorFlow or PyTorch) to see which Python versions they support.
3. **Consult the Python release schedule**: Check the [official Python developer's guide](https://devguide.python.org/versions/) to see the support status of different versions. Avoid using versions that are no longer supported.

For this course, we recommend using **Python 3.11**, as it is widely supported by the AI/ML ecosystem and offers a good balance of new features and stability.

## 🚀 How to install Python for this course?

For this course, we recommend using [`uv`](https://docs.astral.sh/uv/) to install and manage Python versions. `uv` is a modern, fast, and unified toolchain that can handle both Python installation and package management. It's a great replacement for tools like `pyenv` and `pip`.

Here's how you can install a specific Python version using `uv`:

```bash
# Install Python 3.11
uv python install 3.11
```

For new projects, [the latest Python version](https://www.python.org/downloads/) is recommended to take advantage of current features and improvements. However, the choice may be influenced by the compatibility needs of significant libraries or production environment constraints. It's vital to avoid [unsupported Python versions](https://devguide.python.org/versions/) to ensure your projects remain secure and efficient. Regularly checking the official Python website for version updates and support status is a good practice.
This command will download and install Python 3.11, making it available for you to use in your projects. You can then create a virtual environment with this version using `uv venv --python 3.11`. This approach provides the flexibility to switch between Python versions on a per-project basis, which is essential for modern MLOps workflows.

## How to install Python for this course?
## 🔑 Key Takeaways

[`pyenv`](https://github.com/pyenv/pyenv) is recommended for managing Python installations during development, offering the flexibility to switch between Python versions on a per-project basis. This approach is preferable to using system package managers or Anaconda, which may limit version flexibility. In production, using the system's default Python version can help avoid compatibility issues. For containerized deployments, you have the freedom to specify any Python version, aligning your development and production environments closely.
- **Python is the leading language for AI/ML** due to its simplicity, flexibility, and vast ecosystem of libraries.
- **Choosing the right Python version is crucial**. For this course, we recommend **Python 3.11**.
- **Use `uv` to install and manage Python versions**. It's a modern, fast, and unified tool that simplifies the development workflow.
- **Mastering Python is a key skill for any MLOps professional**. A solid understanding of the language and its ecosystem is essential for building robust and maintainable AI/ML systems.

## Python additional resources
## 📚 Python additional resources

- [Python Website](https://www.python.org/)
- [Planet Python](https://planetpython.org/)
Expand Down