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
| articles = [ | |
| { | |
| "article_id1": "123", | |
| "description": "Some description", | |
| "order_units": ["PCS"] | |
| }, | |
| { | |
| "article_id1": "456", | |
| "description": "Language does not matter", | |
| "order_units": ["KG"] |
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 pandas as pd | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| import numpy as np | |
| from sklearn.datasets import load_breast_cancer | |
| sns.set() | |
| data = load_breast_cancer() | |
| breast_cancer_df = pd.DataFrame(data['data']) | |
| breast_cancer_df.columns = data['feature_names'] | |
| breast_cancer_df['target'] = data['target'] |
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 pandas as pd | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| import numpy as np | |
| from sklearn.datasets import load_breast_cancer | |
| sns.set() | |
| data = load_breast_cancer() | |
| breast_cancer_df = pd.DataFrame(data['data']) | |
| breast_cancer_df.columns = data['feature_names'] | |
| breast_cancer_df['target'] = data['target'] |
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
| <img src="http://localhost:5000/plots/breast_cancer_data/correlation_matrix" /> |
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 flask import Flask, send_file, make_response, | |
| from plot import do_plot | |
| app = Flask(__name__) | |
| @app.route('/plots/breast_cancer_data/correlation_matrix', methods=['GET']) | |
| def correlation_matrix(): | |
| bytes_obj = do_plot() | |
| return send_file(bytes_obj, | |
| attachment_filename='plot.png', |
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 pandas as pd | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| import numpy as np | |
| import io | |
| from sklearn.datasets import load_breast_cancer | |
| def do_plot(): | |
| # Loading | |
| data = load_breast_cancer() | |
| breast_cancer_df = pd.DataFrame(data['data']) |
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
| # install terraform e.g. for mac | |
| brew install terraform | |
| # build environment | |
| terraform init | |
| terraform apply \ | |
| -var 'project='<your_gcp_project_id>` \ | |
| -var 'region=europe-west1-d' |
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
| #!/bin/bash | |
| echo "Checking for CUDA and installing." | |
| # Check for CUDA and try to install. | |
| if ! dpkg-query -W cuda-9-0; then | |
| # The 16.04 installer works with 16.10. | |
| curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb | |
| dpkg -i ./cuda-repo-ubuntu1604_9.0.176-1_amd64.deb | |
| apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub | |
| apt-get update | |
| apt-get install cuda-9-0 -y |
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
| resource "google_compute_instance" "gpu-vm" { | |
| count = 1 | |
| name = "gpu-vm" | |
| machine_type = "n1-standard-4" // 1 CPU 16 Gig of RAM | |
| zone = "${var.region}" // Call it from variable "region" | |
| tags = ["http"] | |
| boot_disk { | |
| initialize_params { | |
| image = "ubuntu-os-cloud/ubuntu-1604-lts" | |
| size = 50 // 50 GB Storage |
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
| gcloud projects create <your>-dl --enable-cloud-apis | |
| gcloud config set project <your>-dl | |
| gcloud services enable compute.googleapis.com | |
| gcloud iam service-accounts create gcp-terraform-dl --display-name gcp-terraform-dl | |
| gcloud projects add-iam-policy-binding <your>-dl \ | |
| --member='serviceAccount:gcp-terraform-dl@ <your>-dl.iam.gserviceaccount.com' --role='roles/owner' | |
| gcloud iam service-accounts keys create 'credentials.json' --iam-account='gcp-terraform-dl@<your>-dl.iam.gserviceaccount.com' |
NewerOlder