Skip to content

Instantly share code, notes, and snippets.

View korkridake's full-sized avatar
💙
print("Hello World!")

Korkrid Kyle Akepanidtaworn korkridake

💙
print("Hello World!")
View GitHub Profile
@korkridake
korkridake / githubprofile-analytics.md
Created June 30, 2021 04:09
GitHub Profile - Analytics
@korkridake
korkridake / mlops-evaluate.py
Created June 5, 2020 07:11
MLOps Ep.4 Productionizing Evaluation and Deployment Script
import numpy as np
import matplotlib.pyplot as plt
import azureml.core
# Display the core SDK version number
print("Azure ML SDK Version: ", azureml.core.VERSION)
# Define an environment
from azureml.core.environment import Environment
from azureml.core.conda_dependencies import CondaDependencies
@korkridake
korkridake / mlops-evaluate.py
Created June 5, 2020 07:11
MLOps Ep.4 Productionizing Evaluation and Deployment Script
import numpy as np
import matplotlib.pyplot as plt
import azureml.core
# Display the core SDK version number
print("Azure ML SDK Version: ", azureml.core.VERSION)
# Define an environment
from azureml.core.environment import Environment
from azureml.core.conda_dependencies import CondaDependencies
@korkridake
korkridake / score.py
Created June 5, 2020 07:08
MLOps Ep.4 Productionizing Scoring Script
%%writefile score.py
import json
import numpy as np
import os
import pickle
import joblib
def init():
global model
##################################################################################################
@korkridake
korkridake / mlops-score.py
Created June 5, 2020 07:06
MLOps Ep.4 Productionizing Scoring Script
# Import libraries
import json
import numpy as np
from azureml.core.model import Model
import joblib
# Load model
model_path = Model.get_model_path(model_name="sklearn_regression_model.pkl")
model = joblib.load(model_path)
@korkridake
korkridake / mlops-train-run-ml.py
Created June 5, 2020 06:57
MLOps Ep.4 Productionizing Training Script (Train, Validate, and Save Models)
# Get hold of the current run
run = Run.get_context()
# Experiment parameters
args = {
"n_estimators": 120
}
reg_model = RandomForestRegressor(**args)
reg_model.fit(data["train"]["X"], data["train"]["y"])
@korkridake
korkridake / mlops-train-load-and-preprocess-data.py
Created June 5, 2020 06:49
MLOps Ep.4 Productionizing Training Script (Load and preprocess data)
# Load data in Pandas
df = dataset.to_pandas_dataframe()
print(df.shape)
df.head()
# Preprocess data
df = df.drop_duplicates()
df = df.drop(["dateCrawled","dateCreated","lastSeen", "seller", "name", "postalCode"] , axis = 1)
df["notRepairedDamage"] = df["notRepairedDamage"].fillna("nein")
df["fuelType"] = df["fuelType"].fillna("benzin")
@korkridake
korkridake / automl-h20-simple-flow.R
Created June 3, 2020 08:41
Automated machine learning H20.ai in R
# Install H2O packages
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) }
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") }
pkgs <- c("RCurl","jsonlite")
for (pkg in pkgs) {
if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) }
}
install.packages("h2o", type="source", repos=(c("http://h2o-release.s3.amazonaws.com/h2o/latest_stable_R")))
library(h2o)
localH2O = h2o.init()
@korkridake
korkridake / mlops-train-register-dataset.py
Created May 29, 2020 13:13
MLOps Ep.4 Productionizing Training Script (Register a dataset in Azure Machine Learning Datastore)
# Get the datastore to upload prepared data
datastore = ws.get_default_datastore()
# Upload the local file from src_dir to the target_path in datastore
datastore.upload(src_dir='../aml-kaggle/datasets/', target_path='ds_regression')
# Create a dataset referencing the cloud location
dataset = Dataset.Tabular.from_delimited_files(datastore.path('ds_regression/autos.csv'))
# Register a dataset
@korkridake
korkridake / mlops-train-experiment-compute.py
Created May 29, 2020 13:06
MLOps Ep.4 Productionizing Training Script (Create an experiment and validate if AMLCompute is already provisioned)
# Create an experiment
experiment_name = 'experiment-regression'
experiment = Experiment(workspace = ws, name = experiment_name)
# Choose a name for your CPU cluster
cpu_cluster_name = "kyledevpc1"
# Verify that cluster does not exist already
try:
cpu_cluster = ComputeTarget(workspace=ws, name=cpu_cluster_name)