Skip to content

Instantly share code, notes, and snippets.

@lakshmanok
lakshmanok / mlops2.md
Last active September 18, 2022 13:38
Challenge Automation solution Keep It Simple Solution
Training-Serving Skew, where differences crop up between training and serving stacks Feature Store Transform Pattern
Clients are interested in a capability that involves multiple steps, only one of which is the ML model ML Pipelines Stateless Serving Function
The incoming data changes characteristics Continuous evaluation Scheduled evaluation
The correct answer changes over time Continuous traini
Challenge Automation solution
Training-Serving Skew, where differences crop up between training and serving stacks Feature Store
Clients are interested in a capability that involves multiple steps, only one of which is the ML model ML Pipelines
The incoming data changes characteristics Continuous evaluation
The correct answer changes over time Continuous training
Model fairness issues arise Mumbo Jumbo
Parts of the system aren’t changed when new code
Challenge Automation solution Keep It Simple Solution Complexity needed if …
Training-Serving Skew, where differences crop up between training and serving stacks Feature Store Transform Pattern Features injected server-side
Clients are interested in a capability that involves multiple steps, only one of which is the ML model ML Pipelines Stateless Serving Function Cascade of ML models
The incoming data changes characteristics Continuous evaluation Scheduled evaluat
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
def _draw_as_table(df, pagesize):
alternating_colors = [['white'] * len(df.columns), ['lightgray'] * len(df.columns)] * len(df)
alternating_colors = alternating_colors[:len(df)]
fig, ax = plt.subplots(figsize=pagesize)
ax.axis('tight')
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@lakshmanok
lakshmanok / era5_nyc_config
Last active January 13, 2022 06:55
Downloading ERA5 temperature and precipitation
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
CREATE OR REPLACE TABLE publicdata.us_tracts AS
WITH populated_areas AS (
SELECT
bounds, population_density
FROM `ai-analytics-solutions`.publicdata.popdensity_sedac_rectangles
WHERE
year = 2020 AND
(tile = 'gpw_v4_population_density_rev11_2020_30_sec_1.asc' OR
tile = 'gpw_v4_population_density_rev11_2020_30_sec_2.asc'
) AND
PROJECT='ai-analytics-solutions'
BUCKET='ai-analytics-solutions-kfpdemo'
REGION='us-central1'
from datetime import datetime
import apache_beam as beam
def parse_nlp_result(response):
return [
# response, # entire string
def create_geo(LATRES, LONRES, ORIGIN_LAT, ORIGIN_LON, rowno, startcol, endcol):
# represent each rectangle by a polygon of its corners
top = ORIGIN_LAT - rowno * LATRES
bot = ORIGIN_LAT - (rowno+1) * LATRES
left = ORIGIN_LON + startcol * LONRES
right = ORIGIN_LON + endcol * LONRES
poly = json.dumps({
def create_rectangle_geo(LATRES, LONRES, ORIGIN_LAT, ORIGIN_LON, rowno, startcol, linedata):
# find a rectangle of pixels with the same value, and represent that pixel instead
endcol = startcol
while (endcol < len(linedata)) and (linedata[endcol] == linedata[startcol]):
endcol = endcol + 1
return create_geo(LATRES, LONRES, ORIGIN_LAT, ORIGIN_LON, rowno, startcol, endcol)