<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Tochukwu Nwoke</title>
    <description>The latest articles on Forem by Tochukwu Nwoke (@tobiee).</description>
    <link>https://forem.com/tobiee</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F926310%2F86c0d4f2-29bb-469d-98f8-75638636095b.jpeg</url>
      <title>Forem: Tochukwu Nwoke</title>
      <link>https://forem.com/tobiee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/tobiee"/>
    <language>en</language>
    <item>
      <title>ML experiment tracking with DagsHub, MLFlow, and DVC</title>
      <dc:creator>Tochukwu Nwoke</dc:creator>
      <pubDate>Thu, 12 Jan 2023 10:43:27 +0000</pubDate>
      <link>https://forem.com/hackmamba/ml-experiment-tracking-with-dagshub-mlflow-and-dvc-7j4</link>
      <guid>https://forem.com/hackmamba/ml-experiment-tracking-with-dagshub-mlflow-and-dvc-7j4</guid>
      <description>&lt;p&gt;This blog is a two-part series introducing experiment tracking in machine learning (ML). Here, we cover the practical implementation of experiment tracking using a platform-based tool.&lt;/p&gt;

&lt;p&gt;In practice, having some infrastructural setup, which can be referred to as a “&lt;strong&gt;workbench&lt;/strong&gt;,” within the development pipeline is the way to go. It structures the workflow, but this is easier said than done. Although some cloud platforms have provided various out-of-the-box workbench platforms/services (like &lt;a href="https://cloud.google.com/vertex-ai-workbench" rel="noopener noreferrer"&gt;Vertex AI&lt;/a&gt;, &lt;a href="https://aws.amazon.com/sagemaker/" rel="noopener noreferrer"&gt;Sagemaker&lt;/a&gt;, &lt;a href="https://docs.microsoft.com/en-us/azure/machine-learning/overview-what-is-azure-machine-learning" rel="noopener noreferrer"&gt;AzureML&lt;/a&gt;) ready for use, it doesn’t always cover all the use cases. &lt;/p&gt;

&lt;p&gt;This often requires engineers to design and build an architecture for the workbench that best suits their workflow with external and in-house tools—which is outside the scope of this article. However, a typical workflow for this development stage will demonstrate how a specific problem might affect the workflow design and how the solution would play out with an out-of-the-box workbench.&lt;/p&gt;

&lt;p&gt;Here, we’ll implement the experimentation workflow using &lt;a href="https://dagshub.com/" rel="noopener noreferrer"&gt;D&lt;/a&gt;&lt;a href="https://dagshub.com/" rel="noopener noreferrer"&gt;ag&lt;/a&gt;&lt;a href="https://dagshub.com/" rel="noopener noreferrer"&gt;sHub&lt;/a&gt;, &lt;a href="https://colab.research.google.com/?utm_source=scs-index" rel="noopener noreferrer"&gt;Google Colab&lt;/a&gt;, &lt;a href="https://mlflow.org/" rel="noopener noreferrer"&gt;MLflow&lt;/a&gt;, and &lt;a href="https://dvc.org/" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://dvc.org/" rel="noopener noreferrer"&gt;d&lt;/a&gt;&lt;a href="https://dvc.org/" rel="noopener noreferrer"&gt;ata version control (DVC&lt;/a&gt;). We’ll focus on how to do this without diving deep into the technicalities of building or designing a workbench from scratch. Going that route might increase the complexity involved, especially if you are in the early stages of understanding ML workflows, just working on a small project, or trying to implement a proof of concept. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt;&lt;br&gt;
The following are required to follow along with this article comfortably:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A basic understanding of ML&lt;/li&gt;
&lt;li&gt;A DagsHub account&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You will need to connect your GitHub repository to DagsHub. Suppose you don’t know how this &lt;a href="https://dagshub.com/blog/introducing-dagshub-connect-the-complete-github-integration-is-here/" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://dagshub.com/blog/introducing-dagshub-connect-the-complete-github-integration-is-here/" rel="noopener noreferrer"&gt;&lt;strong&gt;blog&lt;/strong&gt;&lt;/a&gt; will show you. This makes it possible to seamlessly version control your workflows with both GitHub and DagsHub, giving you the extra capabilities DagsHub provides and are necessary for ML workflows. &lt;/p&gt;

&lt;p&gt;You can find the code for this project in this &lt;a href="https://github.com/Tob-iee/Data-Experiment_Tracking" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://github.com/Tob-iee/experiment-tracking" rel="noopener noreferrer"&gt;&lt;strong&gt;repository&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this article, you will:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use DagYard to set up remote environments on Google Colab&lt;/li&gt;
&lt;li&gt;Version data with DVC and store in DagsHub storage&lt;/li&gt;
&lt;li&gt;Train and track model experiments with MLflow on Google Colab&lt;/li&gt;
&lt;li&gt;Understand how use cases drive the ML development process&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Case study&lt;/strong&gt;: Train a model to translate alphabets to sign languages
&lt;/h2&gt;

&lt;p&gt;As a young research student, you decide to work on a simple side project that classifies all the letters of the alphabet for sign language. You cannot train this model on your local machine because the computational cost of training is expensive (the kernel or runtime keeps crashing). You must figure out an easy way to train the computer vision model without incurring financial costs or worrying about infrastructure setup.&lt;/p&gt;

&lt;p&gt;Unfortunately, the allocated grant won’t cover this project. So, you can’t afford to use cloud services (like virtual machines (VMs), workbench, etc.), and other experienced engineering colleagues that might be able to help brainstorm for this hiccup in setup (workbench) are too occupied with work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Case study requirements
&lt;/h2&gt;

&lt;p&gt;Have a remote workbench setup with better computing power to enable faster and easier training. You should also be able to track your experiments as you optimize for the best model and where different versions of the data will persist.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: There is a rich option of tools to pick from for every step in this article. The individual functionality and integration of these tools/platforms made implementing this use case easy.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The workflow architecture for the out-of-the-box workbench looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh4.googleusercontent.com%2FAJNnLR5B722uOezsDNx5FTY30lyw16-Tz5CkOlFC3z28Wx23J4sTP7-kfb-tkv9wqF0SaCouNfBlQV6aHCJZtCKSbAi7vUht6py_BAzh_1aexaTZosocEfOmE2fmcPMjRPs_x84W3N7QGj7XE1Z1rPX2qYZ3r39Xl7eEJeLIN3xoEZ0B_guhtNPqeQ" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh4.googleusercontent.com%2FAJNnLR5B722uOezsDNx5FTY30lyw16-Tz5CkOlFC3z28Wx23J4sTP7-kfb-tkv9wqF0SaCouNfBlQV6aHCJZtCKSbAi7vUht6py_BAzh_1aexaTZosocEfOmE2fmcPMjRPs_x84W3N7QGj7XE1Z1rPX2qYZ3r39Xl7eEJeLIN3xoEZ0B_guhtNPqeQ" alt="Workbench architecture" width="800" height="464"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;What&lt;/strong&gt; is DagYard?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://colab.research.google.com/drive/1XLP2Ouxk-k6y9yOxc4Grp-Aq6aGcbhuj?usp=sharing" rel="noopener noreferrer"&gt;Dag&lt;/a&gt;&lt;a href="https://colab.research.google.com/drive/1XLP2Ouxk-k6y9yOxc4Grp-Aq6aGcbhuj?usp=sharing" rel="noopener noreferrer"&gt;Y&lt;/a&gt;&lt;a href="https://colab.research.google.com/drive/1XLP2Ouxk-k6y9yOxc4Grp-Aq6aGcbhuj?usp=sharing" rel="noopener noreferrer"&gt;ard&lt;/a&gt; is a configuration tool in the form of a notebook for DagsHub. It brings the DagsHub environment runtime of any “hosted” project to Google Colab by pulling all the components remotely and having them run on the Google Colab runtime while having direct access to all DagHub features. &lt;/p&gt;

&lt;p&gt;This way, you don’t always have to worry about uploading or reloading data paths from Google Drive each time the kernel dies during training. You also won’t have to worry about the source code because you can now have everything in one place—plus you can now completely take advantage of Google Colab’s free computing power privileges.&lt;/p&gt;

&lt;p&gt;You must have all the correct parameters and environment variables set at the beginning of the notebook. The authentication and configurations process is as straightforward as checking a few boxes from the list of available options and filling out the credentials—based on what you want to configure directly from DagsHub. VOILA!!! It’s all set for action.&lt;/p&gt;

&lt;p&gt;DagYard is used to configure the environment for this demonstration. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpgv02c3e3pnw3qqce08t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpgv02c3e3pnw3qqce08t.png" alt="Notebook Configuration" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff3vxkrz0vtt21ljwc3t5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff3vxkrz0vtt21ljwc3t5.png" alt="DagsHub configuration" width="800" height="269"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwjylksjv1v9hdh01jau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwjylksjv1v9hdh01jau.png" alt="GitHub and DagsHub authentication" width="800" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After setting up the &lt;a href="https://colab.research.google.com/github/Tob-iee/experiment-tracking/blob/main/Notebooks/run_experiment_workflows.ipynb#scrollTo=_ult64024ro8" rel="noopener noreferrer"&gt;project&lt;/a&gt;. Run the “help function” and “black magic” blocks to pull the project from DagsHub into the Colab directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7dy0zq2nh708ubgfxphh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7dy0zq2nh708ubgfxphh.png" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Version&lt;/strong&gt; &lt;strong&gt;a&lt;/strong&gt;&lt;strong&gt;nd&lt;/strong&gt; &lt;strong&gt;s&lt;/strong&gt;&lt;strong&gt;tore&lt;/strong&gt; &lt;strong&gt;t&lt;/strong&gt;&lt;strong&gt;he&lt;/strong&gt; &lt;strong&gt;d&lt;/strong&gt;&lt;strong&gt;ata&lt;/strong&gt; &lt;strong&gt;w&lt;/strong&gt;&lt;strong&gt;ith DVC&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;About the Data&lt;/strong&gt;&lt;br&gt;
You will be working with image data. The file structure from the &lt;a href="https://public.roboflow.com/object-detection/american-sign-language-letters/1" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://public.roboflow.com/object-detection/american-sign-language-letters/1" rel="noopener noreferrer"&gt;&lt;strong&gt;data source&lt;/strong&gt;&lt;/a&gt; contains all the images and a CSV file with the image features for each image (i.e., annotation, labels, etc.). The image folder structure has train, test, and validation set splits.&lt;/p&gt;

&lt;p&gt;The data will be converted to a TFRecord format and recorded as a new data version. This preprocessing step reduces the data size and will make the training process easier since you are using TensorFlow. The &lt;a href="https://dagshub.com/Nwoke/data_model_experiment-tracking/src/main/src/data_preprocessor.py" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://dagshub.com/Nwoke/data_model_experiment-tracking/src/main/src/data_preprocessor.py" rel="noopener noreferrer"&gt;&lt;strong&gt;src/data_preprocessing.py&lt;/strong&gt;&lt;/a&gt; script performs this makeover.&lt;/p&gt;

&lt;p&gt;Understand that you are working with the idea that data that comes from the data source can change at any time — which is what happens in practice. That is why you have chosen to version the data after preprocessing. Ideally, this represents the &lt;a href="http://databricks.com/glossary/extract-transform-load" rel="noopener noreferrer"&gt;e&lt;/a&gt;&lt;a href="http://databricks.com/glossary/extract-transform-load" rel="noopener noreferrer"&gt;xtract&lt;/a&gt; &lt;a href="http://databricks.com/glossary/extract-transform-load" rel="noopener noreferrer"&gt;t&lt;/a&gt;&lt;a href="http://databricks.com/glossary/extract-transform-load" rel="noopener noreferrer"&gt;ransform&lt;/a&gt; &lt;a href="http://databricks.com/glossary/extract-transform-load" rel="noopener noreferrer"&gt;l&lt;/a&gt;&lt;a href="http://databricks.com/glossary/extract-transform-load" rel="noopener noreferrer"&gt;oad&lt;/a&gt; &lt;a href="http://databricks.com/glossary/extract-transform-load" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="http://databricks.com/glossary/extract-transform-load" rel="noopener noreferrer"&gt;(ETL)&lt;/a&gt; process.&lt;/p&gt;

&lt;p&gt;DVC tracks data and uses a remote storage location to store the data. It supports a variety of remote storage locations like (s3 bucket, Google Drive, Azure blob storage, Google storage buckets, etc.). Although these are all excellent options, they might require a lot of configuration to set up or cost more because they are better suited for more complex workflows or robust solutions with scalability. If you’re thinking, “Google Drive is free and easy to configure,” you are correct, but it limits your abilities when tracking training. You will get to understand this better in a bit.&lt;/p&gt;

&lt;p&gt;Fortunately, DagsHub provides free remote storage with 10GB of space by default for every project (repository) that DVC supports. &lt;/p&gt;

&lt;p&gt;Thanks to DagYard, it has already been configured as the remote storage location — but the &lt;a href="https://dagshub.com/Nwoke/experiment-tracking/src/main/data_store/data" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://dagshub.com/Nwoke/experiment-tracking/src/main/data_store/data" rel="noopener noreferrer"&gt;&lt;strong&gt;data_store/data&lt;/strong&gt;&lt;/a&gt; directory will serve as your feature store for the processed data.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Using&lt;/strong&gt; MLflow for model experiments
&lt;/h2&gt;

&lt;p&gt;As established earlier, it’s not uncommon to run many experiments in ML. It is essential to log all information from each set of experiments. The roadmap to arriving at a particular model becomes easier to trace.&lt;/p&gt;

&lt;p&gt;You will make use of MLflow to manage the training information. Usually, it would require initializing and configuring a server to run on your local or remote machine. Its integration with DagHub allows us to use it just as you would when working on a &lt;a href="https://www.mlflow.org/docs/latest/tracking.html#id32" rel="noopener noreferrer"&gt;proxied server&lt;/a&gt;. Select the MLflow option from the notebook configuration cell on the Dagyard to configure access to the MLflow tracking server (URI). This way, the tracking server is automatically running on DagsHub’s backend server.&lt;/p&gt;

&lt;p&gt;Although this setup might not give complete control over MLFlow because you don’t have direct access to the management/running of the server or backend store (database), you can always use the MLflow client API to communicate with the tracking server. These are the kind of trade-offs that you might come across when building your solution with different tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Run&lt;/strong&gt; experiment workflow
&lt;/h2&gt;

&lt;p&gt;Since you have the project runtime on Colab, you can efficiently run the training with the paths to the source code and data. The &lt;code&gt;train.py&lt;/code&gt; script has all you need to set, train, and log all the information required from an experiment.&lt;/p&gt;

&lt;p&gt;The teeny-tiny issue is that on the free Google Colab plan, there isn’t access to a terminal console. Not to worry: you can use the good old hack of accessing the terminal from your notebook to run your experiments. You will also push and commit your change within a configured notebook (DagYard).&lt;/p&gt;

&lt;p&gt;With the help of a pipeline, processes/workflows like this can be streamlined, seamless, and repeatable. A DVC pipeline executes the entire workflow—from data ingestion and preprocessing to model training.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/Tob-iee/7b950a34de5d55a36db972cb91c8d984" rel="noopener noreferrer"&gt;https://gist.github.com/Tob-iee/7b950a34de5d55a36db972cb91c8d984&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; Ideally, this is not good practice, but in this case, it gets the job done and demonstrates the workflow concept. Running &lt;a href="https://dagshub.com/Nwoke/experiment-tracking/src/main/Notebooks/run_experiment_workflows.ipynb" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://dagshub.com/Nwoke/experiment-tracking/src/main/Notebooks/run_experiment_workflows.ipynb" rel="noopener noreferrer"&gt;&lt;strong&gt;Notebooks/run_experiment_workflows.ipynb&lt;/strong&gt;&lt;/a&gt; ****will spin up the entire pipeline process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fufivpntimd8h8dqwpcrp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fufivpntimd8h8dqwpcrp.png" alt="run_experiment_workflow.ipynb" width="800" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also find two other notebooks (local_runtime.ipynb and colab_runtime.ipynb) in the &lt;strong&gt;Notebooks&lt;/strong&gt; directory for local runtime training and Google Colab runtime training, respectively. Just for context, and if you would like to understand the above approach better, feel free to run them.&lt;/p&gt;

&lt;p&gt;After the training process is complete, push the changes. Go back to the DagsHub interface, and you can see the workflow dags from the pipeline.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqg85kcntax59x75rnmv1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqg85kcntax59x75rnmv1.png" alt="Workflow Dags" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All MLflow experiments can then be seen and used from the MLflow UI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F60wqffxl22ah2mu3ulna.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F60wqffxl22ah2mu3ulna.png" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn80tgxcoj589t15v1074.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn80tgxcoj589t15v1074.png" alt="MLflow UI" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Congratulations on making it this far! You have successfully learned the concept of experiment tracking and the thought process behind building and designing workflows to best suit your problem or use case.&lt;/p&gt;

&lt;p&gt;In practice, the approaches to providing ML solutions are often unique across businesses. This equips you or your teammates to implement this MLOps workflow better and offer more value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
The ASL dataset used for the project* &lt;a href="https://roboflow.com/" rel="noopener noreferrer"&gt;Roboflow&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>How to Track and Analyze Experiments in Machine Learning: A Beginner's Guide</title>
      <dc:creator>Tochukwu Nwoke</dc:creator>
      <pubDate>Tue, 10 Jan 2023 14:51:35 +0000</pubDate>
      <link>https://forem.com/hackmamba/how-to-track-and-analyze-experiments-in-machine-learning-a-beginners-guide-5d0h</link>
      <guid>https://forem.com/hackmamba/how-to-track-and-analyze-experiments-in-machine-learning-a-beginners-guide-5d0h</guid>
      <description>&lt;p&gt;This article was originally posted on &lt;a href="https://hackmamba.io/blog/2022/12/how-to-track-and-analyze-experiments-in-machine-learning-a-beginner-s-guide/" rel="noopener noreferrer"&gt;Hackmamba&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a machine learning (ML) practitioner, you must work simultaneously with code, data, and models. With the rapid evolution of these factors during development, keeping up with their interaction becomes even more demanding.&lt;/p&gt;

&lt;p&gt;This article enables you to understand the concept of experiment tracking.&lt;/p&gt;

&lt;p&gt;Practices in ML are becoming more streamlined, structured, and defined with the recent adoption of &lt;a href="https://arxiv.org/abs/2205.02302" rel="noopener noreferrer"&gt;Machine learning operations (MLOps)&lt;/a&gt;. MLOps workflows have different phases, and this article focuses on data and model experiment tracking in the model management phase. It provides better solutions for ML-driven development, but solutions always have trade-offs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.kdnuggets.com/2022/07/machine-learning-model-management.html" rel="noopener noreferrer"&gt;Model management&lt;/a&gt; is a crucial part of the MLOps lifecycle because this is where many rapid changes happen. From running a series of experiments to making little tweaks in the programs in a “needle in a haystack” fashion to figure out what works best quickly.&lt;/p&gt;

&lt;p&gt;Why experiment tracking?&lt;/p&gt;

&lt;p&gt;The early stages of developing ML solutions feel like a series of experiments with no direction. The critical question then becomes, “how can you conduct the experimentation fast, reproducible, and scalable way and simultaneously provide business value?”&lt;/p&gt;

&lt;p&gt;The idea is to combine science (experimentation) and engineering workflows since you will work primarily with code, data, and models. Code is usually static, which we consider as the engineering aspect of the workflow, whereas data and models are dynamic and scientific. This engineering vs. scientific gap is where the concept of experiment tracking comes to play.&lt;/p&gt;

&lt;p&gt;Experiment tracking in research&lt;/p&gt;

&lt;p&gt;As with any research process, the scientist runs a series of experiments under certain conditions and variables before, hopefully, arriving at an optimal result for a particular problem. In the case of ML, the experiments would be the different times model training was carried out. The conditions and variables during an experiment would be the model’s hyperparameters, data features, etc.&lt;/p&gt;

&lt;p&gt;Also, let’s not forget that by the end of the research, there is always this little book where the scientist records the final observations, findings, and discoveries — which engineers, other researchers, and other researchers use in the future. This is precisely what happens at the model development stage of ML development.&lt;/p&gt;

&lt;p&gt;The focus is on recording all the reactions occurring during the training process by logging the training metrics, parameters, and artifacts for further analysis and understanding of the model’s performance for each experiment. With this, you can gain insights from experimentation. That knowledge equips us with the right tools to investigate the entire process and make better deductions on what step to take next.&lt;/p&gt;

&lt;p&gt;The need to capture your data in ML experiments&lt;/p&gt;

&lt;p&gt;Data tracking is an extension of the research process in ML; it entails keeping a proper record of the data that is used for training. It captures data in the form of versions in a feature store or database store for further investigation.&lt;/p&gt;

&lt;p&gt;The data versions are driven mainly by the data preprocessing steps. These data preprocessing steps are processes/tasks that primarily structure the data for the type of model you are building. Different forms of data then morph into an acceptable form when passing them as input into the model.&lt;/p&gt;

&lt;p&gt;It also entails feature engineering to a large extent in ML/data science because, as the famous data science saying goes, “the model is only as good as the data.” Versioning makes whatever preprocessing steps you have taken on the data easily traceable across preprocessing pipelines, just as code versions are tracked using Git.&lt;/p&gt;

&lt;p&gt;Who conducts experiment tracking in ML?&lt;/p&gt;

&lt;p&gt;The responsibility of keeping track of the experiments carried out when developing an ML model is the job of any individual directly training the model. Typically, this is a data scientist (DS) or an ML engineer (MLE).&lt;/p&gt;

&lt;p&gt;DSs/MLEs curate all the information gathered during model training to easily compare differences across experiments. They create a high-level summary of all the training information in a way that makes sense to them and other technical personnel. This represents a form of documentation that allows communication and understanding of what goes on in their development environment (usually a Jupyter notebook) on a higher level.&lt;/p&gt;

&lt;p&gt;By drawing hypotheses from previous experiments, DSs/MLEs can deduce the next promising strategy to apply to the data, model, or code when trying to arrive at an optimal ML solution. It also makes it easy to share experiments with other technical people or stakeholders in a way they can understand.&lt;/p&gt;

&lt;p&gt;The tools for experiment tracking&lt;/p&gt;

&lt;p&gt;Many tools have been developed for tracking experiments, such as MLflow, weights&amp;amp;biases, Neptune.ai, etc. The core purpose of these tools is to enable a central point of reporting during the model training process. Managing model development workflows become more accessible because all the findings during the experimentation phase will be populated at a single point, irrespective of where you run the experiment (i.e., either locally or virtually, on different machines) or who ran the experiment (i.e., having other engineers running experiments in parallel),&lt;/p&gt;

&lt;p&gt;However, there are trade-offs between the numerous experiment tracking tools that exist. These trade-offs influence your decision when picking the perfect tool for your ML development stack and workflows based on the components, features, and integration they support.&lt;/p&gt;

&lt;p&gt;How should experiment tracking be carried out&lt;/p&gt;

&lt;p&gt;In a nutshell, the processes involved in tracking, recording, and carrying out experiments depend on the type of data, use cases, and the recording method of the tool. Data vary from structured to unstructured, and use cases could be computer vision, natural language processing (NLP), reinforcement learning, etc. It’s also quite common for the methods that tracking tools usually use to fall within the options of a spreadsheet method (like MS Excel), a version control method (like Git), or a software package/platform (like MLflow).&lt;/p&gt;

&lt;p&gt;Nonetheless, manual methods like spreadsheet and version control tend to be more tedious, time-consuming, and less intuitive because you have to manually record your metrics, logs, hyper-parameters, etc. On the other hand, software packages/platforms have a robust structure that enables seamless traceability and reproducibility when running experiments. They can seamlessly support and integrate with frameworks like TensorFlow, SKlearn, and PyTorch; as such, they can intuitively take a record of the experiment runs — and even store models and artifacts in remote locations.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;This article provides a good overview of what it entails to implement experiment tracking in ML. To learn more about experiment tracking, check out the following resources:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://neptune.ai/blog/best-ml-experiment-tracking-tools" rel="noopener noreferrer"&gt;15 Best Tools for ML Experiment Tracking&lt;/a&gt;&lt;br&gt;
&lt;a href="https://neptune.ai/blog/ml-experiment-tracking" rel="noopener noreferrer"&gt;ML Experiment Tracking: What It Is, Why It Matters, and How to Implement It&lt;/a&gt;&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
  </channel>
</rss>
