This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def matmul(mat1, mat2, mat3): | |
r""" Function to multiply mat1 and mat2 | |
returns mat3 | |
Parameters | |
--------- | |
mat1: np.array, matrix A | |
mat2: np.array, matrix B | |
mat3: np.array, empty matrix C | |
Return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
# define a block where the tweet can be written | |
text = st.text_input("Insert tweet here") | |
# codify the input text in a compatible SageMaker json | |
input_df = pd.DataFrame({"text":text}, index=[0]).to_json(orient="split") | |
# here we are printing out results | |
st.subheader("Sentiment:") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import json | |
import boto3 | |
# app name and region are global variables | |
global app_name | |
global region | |
app_name = 'NaiveBayesTest' | |
region = "eu-west-1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mlflow | |
import os | |
# PARSE YOUR MLFLOW INFO | |
# image build and push by mlflow | |
image_uri = "230178520806.dkr.ecr.eu-west-1.amazonaws.com/mlflow-pyfunc:1.28.0" | |
# the model uri | |
model_uri = "models:/SageMaker1/Staging" | |
# your region |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mlflow | |
run_id= "ade1040e1fd94a74b1da5ec0583fba63" | |
artifact_name = "model" | |
model_name = "NAME OF YOU MODEL" | |
mlflow.register_model(f"runs:/{run_id}/{artifact_name}", model_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Submit NB with CountVectorizer" | |
venv/bin/python multiple_models.py --run_name "naivebayes" --exp_name "sentiment_comparison" --model "naivebayes" --vectorizer "countvectorizer" | |
echo "Submit NB with TFIDF" | |
venv/bin/python multiple_models.py --run_name "naivebayes_tfidf" --exp_name "sentiment_comparison" --model "naivebayes" --vectorizer "tfidf" | |
echo "Submit LogReg with CountVectorizer" | |
venv/bin/python multiple_models.py --run_name "logreg" --exp_name "sentiment_comparison" --model "logreg" --vectorizer "countvectorizer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mlflow | |
from mlflow.tracking.client import MlflowClient | |
# CLASS AND PIPELINE | |
# MAIN | |
# argparse ... | |
# set up the tracking and define the input arguments | |
mlflow_client = MlflowClient(tracking_uri=mlflow_tracking_uri) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
# MAIN | |
parser = argparse.ArgumentParser(description='Input arguments for MLflow testing in general') | |
parser.add_argument('--run_name', type=str, | |
help='Name of the run within the experiment family') | |
parser.add_argument('--exp_name', type=str, | |
help='Name of the family experiment') | |
parser.add_argument('--model', type=str, | |
help='Model to be used: naivebayes, logreg, randomforest') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def training_process(model:str, | |
vectorizer:str): | |
r""" Function to create the training pipeline with cleaner and model | |
Parameters | |
---------- | |
model: str, type of model we want to run, see get_model function | |
vectorizer: str, type of vectorizer, `countvectorizer` or `tfidf` | |
Return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mlflow | |
# all imports | |
# PREPROCESSING FUNCTION | |
# input dataframe | |
# clean dataframe | |
# set up train and test | |
# count vectorizer |