This file contains hidden or 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
%%writefile sentiment_analysis_service.py | |
# Now let's modify our service to use prometheus to measure custom metrics | |
import bentoml | |
from bentoml.frameworks.sklearn import SklearnModelArtifact | |
from bentoml.service.artifacts.common import PickleArtifact | |
from bentoml.adapters import JsonInput | |
import sentry_sdk |
This file contains hidden or 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
%%writefile sentiment_analysis_service.py | |
# Now let's modify our service to use prometheus to measure latency | |
import bentoml | |
from bentoml.frameworks.sklearn import SklearnModelArtifact | |
from bentoml.service.artifacts.common import PickleArtifact | |
from bentoml.adapters import JsonInput | |
import sentry_sdk |
This file contains hidden or 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
%%writefile sentiment_analysis_service.py | |
# Now let's modify our service to use sentry | |
import bentoml | |
from bentoml.frameworks.sklearn import SklearnModelArtifact | |
from bentoml.service.artifacts.common import PickleArtifact | |
from bentoml.adapters import JsonInput | |
# Edit 1: Import sentry |
This file contains hidden or 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
# 1) import the custom BentoService defined above | |
from sentiment_analysis_service import SKSentimentAnalysis | |
# 2) `pack` it with required artifacts, i.e. the trained model from step 1 | |
bento_service = SKSentimentAnalysis() | |
bento_service.pack('model', sentiment_lr) | |
# 3) save your BentoSerivce to file archive | |
saved_path = bento_service.save() |
This file contains hidden or 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
%%writefile sentiment_analysis_service.py | |
import bentoml | |
from bentoml.frameworks.sklearn import SklearnModelArtifact | |
from bentoml.service.artifacts.common import PickleArtifact | |
from bentoml.adapters import JsonInput | |
@bentoml.artifacts([PickleArtifact('model')]) # picke your trained model so that it can run on the server | |
@bentoml.env(pip_packages=["scikit-learn", "pandas"]) # specify the packages that your model depends on |
This file contains hidden or 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 numpy as np | |
import pandas as pd | |
from sklearn.feature_extraction.text import CountVectorizer | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.metrics import classification_report, roc_auc_score, roc_curve | |
from sklearn.pipeline import Pipeline | |
%%bash |
This file contains hidden or 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
from scipy import stats | |
""" | |
Imagining a programming language where basic types are represented as a Gaussian distribution. Would make for some pretty interesting (read: hair-pulling) programming experience, lol. | |
. The default assumptions in Deep Learning these days. But in a way, this may be how we should model the world around us. There are no statics or constants, everything is a probability distribution function. | |
""" | |
class GaussianFloat(object): | |
def __init__(self, val, scale=None): |
This file contains hidden or 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
BOARD = dict() | |
EMPTY_CHAR = "*" | |
WIN_CHAR = "@" | |
# Store all possible win combinations | |
WIN_COMBOS = [ | |
(1, 2, 3), | |
(4, 5, 6), | |
(7, 8, 9), | |
(1, 4, 7), |