<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Versioning Example (Part 3/3)
In part 2, we trained and logged a problematic model, and then reverted the commit to restore a good version.
Now we'll train an even better model—one that can also classify tweets in German—but this time using a separate branch and merge, instead of committing directly to master.
This workflow requires verta&gt;=0.14.4 and spaCy&gt;=2.0.0.
Setup
Instead of spaCy's English model, we'll be building off of a multilingual model.
Step1:  Then, as before, import libraries we'll need...
Step2:  ...and instantiate Verta's ModelDB Client.
Step3:  Prepare Data
Again, things are a little different.
Our multilingual model needs German training data to classify German tweet, so we'll download two datasets from S3.
Before, we trained a model on just english-tweets.csv. Now, we're going to also train with german-tweets.csv.
Step4:  Capture and Version Model Ingredients
As with before, we'll capture and log our model ingredients. Note that now we're logging both of our datasets from S3.
Step5:  But instead of committing directly to master, we'll checkout and commit to a separate branch.
Step6:  You may verify through the Web App that this commit—on branch multilingual—updates the dataset, as well as the Notebook.
Train and Log Model
Again as before, we'll train the model and log it along with the commit to an Experiment Run.
Step7:  Merge Commit
Our model seems to be handling our multilingual data just fine, so we'll merge our improvements into master.
<ASSISTANT_TASK:>
Python Code:
!python -m spacy download xx_ent_wiki_sm
Explanation: Versioning Example (Part 3/3)
In part 2, we trained and logged a problematic model, and then reverted the commit to restore a good version.
Now we'll train an even better model—one that can also classify tweets in German—but this time using a separate branch and merge, instead of committing directly to master.
This workflow requires verta&gt;=0.14.4 and spaCy&gt;=2.0.0.
Setup
Instead of spaCy's English model, we'll be building off of a multilingual model.
End of explanation
from __future__ import unicode_literals, print_function
import boto3
import json
import numpy as np
import pandas as pd
import spacy
Explanation: Then, as before, import libraries we'll need...
End of explanation
from verta import Client
client = Client('http://localhost:3000/')
proj = client.set_project('Tweet Classification')
expt = client.set_experiment('SpaCy')
Explanation: ...and instantiate Verta's ModelDB Client.
End of explanation
S3_BUCKET = "verta-starter"
EN_S3_KEY = "english-tweets.csv"
EN_FILENAME = EN_S3_KEY
DE_S3_KEY = "german-tweets.csv"
DE_FILENAME = DE_S3_KEY
boto3.client('s3').download_file(S3_BUCKET, EN_S3_KEY, EN_FILENAME)
boto3.client('s3').download_file(S3_BUCKET, DE_S3_KEY, DE_FILENAME)
import utils
en_data = pd.read_csv(EN_FILENAME)
de_data = pd.read_csv(DE_FILENAME)
data = pd.concat([en_data, de_data], axis=0)
data = data.sample(frac=1).reset_index(drop=True)
utils.clean_data(data)
data.head()
Explanation: Prepare Data
Again, things are a little different.
Our multilingual model needs German training data to classify German tweet, so we'll download two datasets from S3.
Before, we trained a model on just english-tweets.csv. Now, we're going to also train with german-tweets.csv.
End of explanation
from verta.code import Notebook
from verta.configuration import Hyperparameters
from verta.dataset import S3
from verta.environment import Python
code_ver = Notebook()  # Notebook & git environment
config_ver = Hyperparameters({'n_iter': 20})
dataset_ver = S3([
    "s3://{}/{}".format(S3_BUCKET, EN_S3_KEY),
    "s3://{}/{}".format(S3_BUCKET, DE_S3_KEY),
])
env_ver = Python(Python.read_pip_environment())  # pip environment and Python version
Explanation: Capture and Version Model Ingredients
As with before, we'll capture and log our model ingredients. Note that now we're logging both of our datasets from S3.
End of explanation
repo = client.set_repository('Tweet Classification')
commit = repo.get_commit(branch='master').new_branch('multilingual')
commit.update("notebooks/tweet-analysis", code_ver)
commit.update("config/hyperparams", config_ver)
commit.update("data/tweets", dataset_ver)
commit.update("env/python", env_ver)
commit.save("Support German tweets")
commit
Explanation: But instead of committing directly to master, we'll checkout and commit to a separate branch.
End of explanation
nlp = spacy.load('xx_ent_wiki_sm')
import training
training.train(nlp, data, n_iter=20)
run = client.set_experiment_run()
run.log_model(nlp)
run.log_commit(
    commit,
    {
        'notebook': "notebooks/tweet-analysis",
        'hyperparameters': "config/hyperparams",
        'training_data': "data/tweets",
        'python_env': "env/python",
    },
)
Explanation: You may verify through the Web App that this commit—on branch multilingual—updates the dataset, as well as the Notebook.
Train and Log Model
Again as before, we'll train the model and log it along with the commit to an Experiment Run.
End of explanation
commit
master = repo.get_commit(branch="master")
master
master.merge(commit)
master
Explanation: Merge Commit
Our model seems to be handling our multilingual data just fine, so we'll merge our improvements into master.
End of explanation
<END_TASK>