Blog #machine-learning #devops

Machine Learning Best Practices For Your Company

Machine Learning best practices and guidelines, tools to be used, while you're a developer. It applies to Data Analysts, Data Engineers, Machine Learning Engineers, Data Scientists or any research team in general

Published
Updated
Reading
2 min

Git and GitHub/GitLab Essentials

  • Introduction to Git & GitHub/GitLab: For newcomers, I recommend the Udacity course “Version Control with Git”.
  • Configuring Git: Ensure your Git client is set up with your email and linked to your GitHub/GitLab account. This ties your commits to your account.
  • Using Repositories: Use git-based repositories for all coding tasks. Ensure you have access to your company’s GitLab or GitHub groups to create and manage repositories.
  • Branching Strategy: Avoid direct pushes to the master or main branch. Use feature branches, tags, and pull requests (PRs) for code reviews and merges.
  • Pull Requests & Code Reviews: Always create Pull Requests for code reviews. If working solo, review your own PRs critically.
  • Tools: Use GitHub Desktop if you want a GUI, and GitHub CLI and Hub CLI on the command line.

.gitignore Practices

  • Ignoring Files: Exclude unnecessary files like dependencies, build artifacts, and large files from Git tracking.
  • Template for .gitignore: If unsure about what to ignore, use gitignore.io to generate a suitable .gitignore file for your project.

Commit Message Guidelines

Handling Secret Keys

  • Keep Secrets Out of Git: Never commit sensitive data like API keys or passwords. Use .env files for environment variables and ensure they are listed in .gitignore.
  • In Case of Exposure: If you accidentally commit sensitive data, inform your senior immediately and follow the steps to remove it from the repository.

README.md

Git Hooks

  • Automate with Git Hooks: Use Git hooks for automated scripts that run during events like commit, push, and receive. Learn more at Githooks.

Data Management

  • Data Version Control (DVC): Integrate DVC with Git to version data and model files without bloating the Git repository.

Machine Learning Best Practices

Jupyter Notebook Standards

  • Reproducibility and Clean Code: Ensure notebooks are clean, modular, and reproducible. Favor JupyterLab over traditional notebooks and use templates for common tasks.
  • Code Organization and TDD: Organize code in separate files and classes, and adopt Test-Driven Development (TDD) for your ML models. Read more about ML and TDD.

Experiment Tracking

  • ML Flow for Experiment Management: Use tools like ML Flow to document, track, and compare experiments. Start with their tutorials.

Modernizing ML Operations (MLOps)

  • Use LLMs in Your Workflow: Use Large Language Models (LLMs) like GPT-4 for automated code reviews, documentation, and first drafts of code templates.
  • AI-Assisted Coding: Tools like GitHub Copilot suggest code snippets as you type.
  • Deep Learning in CI/CD Pipelines: Add deep learning models to your CI/CD pipelines so they get tested and deployed like the rest of your code.
  • MLOps Best Practices: Read “ML Ops: Machine Learning as an Engineering Discipline”.

Related work

Production ML context

See how this topic connects to production ML systems, infrastructure, and inference.