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 sklearn.datasets import load_iris | |
from sklearn.model_selection import ParameterGrid, StratifiedKFold | |
iris = load_iris() | |
param_grid = [{'kernel': ['rbf'], | |
'C': [0.01, 1], | |
'gamma': [0.1, 1]}, | |
{'kernel': ['linear'], | |
'C': [0.01, 1]}] | |
print("List of parameter grids:\n{}".format(param_grid)) |
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
version: '3' | |
services: | |
elasticsearch: | |
build: elasticsearch | |
container_name: elasticsearch | |
environment: | |
- discovery.type=single-node | |
- bootstrap.memory_lock=true | |
- "ES_JAVA_OPTS=-Xms256m -Xmx256m" | |
ulimits: |
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
{ | |
"btcjpy" : { | |
"aliases" : { }, | |
"mappings" : { | |
"properties" : { | |
"close" : { | |
"type" : "long" | |
}, | |
"timestamp" : { | |
"type" : "date", |
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
#!/usr/bin/python | |
import json | |
import time | |
import python_bitbankcc | |
from datetime import datetime | |
from elasticsearch import Elasticsearch | |
def get_ticker(pub): | |
ret = pub.get_ticker('btc_jpy') | |
return ret |
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
#!/usr/bin/python | |
import json | |
import time | |
from datetime import datetime | |
from elasticsearch import Elasticsearch | |
size = 5 | |
def print_search_stats(results): | |
print("=" * 80) |
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
# Build an image that can do training and inference in SageMaker | |
# This is a Python 3.7.3 image with pyenv that uses the nginx, gunicorn, flask stack | |
# for serving inferences in a stable way. | |
FROM python:3.7 | |
RUN apt-get -y update && apt-get install -y --no-install-recommends git wget nginx ca-certificates && \ | |
mkdir -p /opt/program && \ | |
rm -rf /var/lib/apt/lists/* | |
ADD requirements.txt ./ | |
RUN pip3 install --no-cache --upgrade pip & pip3 install -r ./requirements.txt |
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
# S3 prefix | |
prefix = 'sagemaker/scikit-iris' | |
import sagemaker | |
from sagemaker import get_execution_role | |
sagemaker_session = sagemaker.Session() | |
# Get a SageMaker-compatible role used by this Notebook Instance. | |
role = get_execution_role() |
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 argparse | |
import pandas as pd | |
import os | |
# GradientBoosting Classifier | |
from sklearn.ensemble import GradientBoostingClassifier | |
from sklearn.externals import joblib | |
# Pipeline and StandardScaler | |
from sklearn.preprocessing import StandardScaler |
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
def lambda_handler(event, context): | |
response = event | |
# Lambda event | |
if 'Records' in event: | |
for records in event['Records']: | |
if 's3' in records: | |
handle_s3_event(records['s3']) | |
else: | |
pass |
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
def handle_s3_event(s3): | |
print("s3=", s3) | |
bucket = s3['bucket']['name'] | |
print("bucket: ", bucket) | |
fn = s3['object']['key'] | |
print("fn: ", fn) | |
jobid = fn.split("/")[-3] | |
print("jobid=", jobid) | |
return deploy_model(jobid) |