{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ✍️ Exercise: Intro to MLFlow - Part III\n", "\n", "Now that we have loged models into MLFlow it's time to learn how register them and deploy them to a production environment.\n", "\n", "\n", "- Load a regression dataset\n", "- Train a model\n", "- Log the model into MLFlow\n", "- Register the model\n", "- Stage the model into production/development\n", "- Deploy the model using MLFlow" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "from sklearn import datasets\n", "\n", "\n", "# Download dataset and convert to pandas dataframe\n", "diabetes_dataset = datasets.load_diabetes(as_frame=True)\n", "X = diabetes_dataset.data\n", "y = diabetes_dataset.target" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise I: Split the Data into Train and Test Sets\n", "\n", "💡 Remember that we need to split our data into train and test sets. We can use the [`train_test_split` function](https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html) from `sklearn.model_selection` to do this. We should store the split into `X_train`, `y_train`, `X_test`, `y_test`." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "from sklearn.model_selection import train_test_split\n", "\n", "\n", "RANDOM_STATE = 42\n", "TEST_SIZE = 0.2\n", "\n", "# 👇 Add the relevant code below to split the data into training and testing sets\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise II: Train a Linear Regression Model\n", "\n", "Then, train a [**linear regression model** using the scikit-learn library](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html).\n", "\n", "1. 👉 Initialize the model calling the `LinearRegression` class.\n", "2. 👉 Train the model using the `fit` method." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
LinearRegression()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
LinearRegression()