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
# load the data into a dataframe | |
df = pd.read_csv('trump_20200530_clean.csv') |
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
# PyCaret's NLP module | |
from pycaret.nlp import * | |
# for working with dataframes | |
import pandas as pd | |
# to print out all the outputs | |
from IPython.core.interactiveshell import InteractiveShell | |
InteractiveShell.ast_node_interactivity = "all" |
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
print("POST to url", service.scoring_uri) | |
print("label:", y_test[sample_index]) | |
print("prediction:", resp.text) |
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
resp = requests.post(service.scoring_uri, input_data, headers=headers) |
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
sample_index = 68 | |
input_data = '{"data": [' + str(list(X_test[sample_index])) + "]}" | |
headers = {"Content-Type": "application/json"} | |
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
%%time | |
import uuid | |
from azureml.core.model import InferenceConfig | |
from azureml.core.environment import Environment | |
from azureml.core.model import Model | |
# get the registered model | |
model = Model(ws, "credit_card_model") | |
# create an inference config i.e. the scoring script and environment |
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
# create environment for the deploy | |
from azureml.core.environment import Environment | |
from azureml.core.conda_dependencies import CondaDependencies | |
from azureml.core.webservice import AciWebservice | |
# get a curated environment | |
env = Environment.get( | |
workspace=ws, | |
name="AzureML-sklearn-1.0-ubuntu20.04-py38-cpu", | |
version=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
# register the model | |
model_uri = "runs:/{}/model".format(run.info.run_id) | |
model = mlflow.register_model(model_uri, "credit_card_model") |
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
# set up the Logistic regression model | |
reg = 0.5 | |
clf = LogisticRegression( | |
C=1.0 / reg, solver="liblinear", multi_class="auto", random_state=42 | |
) | |
# train the model | |
with mlflow.start_run() as run: | |
clf.fit(X_train, y_train) |
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
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=493) |