Skip to content

Instantly share code, notes, and snippets.

View ecdedios's full-sized avatar

Ednalyn C. De Dios ecdedios

View GitHub Profile
# load the data into a dataframe
df = pd.read_csv('trump_20200530_clean.csv')
# 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"
print("POST to url", service.scoring_uri)
print("label:", y_test[sample_index])
print("prediction:", resp.text)
resp = requests.post(service.scoring_uri, input_data, headers=headers)
sample_index = 68
input_data = '{"data": [' + str(list(X_test[sample_index])) + "]}"
headers = {"Content-Type": "application/json"}
%%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
# 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
# register the model
model_uri = "runs:/{}/model".format(run.info.run_id)
model = mlflow.register_model(model_uri, "credit_card_model")
# 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)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=493)