This file contains 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 matplotlib.pyplot as plt | |
import numpy as np | |
# set seed for reproduceable | |
np.random.seed(123) | |
ind = np.arange(1, 40_001) | |
x = np.random.random(40_000) | |
y = np.random.random(40_000) | |
radius = (x**2 + y**2)**.5 |
This file contains 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 plotly.plotly as py | |
import plotly.graph_objs as go | |
import plotly.figure_factory as ff | |
import plotly.offline as offline | |
import pandas as pd | |
import dash | |
import dash_core_components as dcc | |
import dash_html_components as html | |
from dash.dependencies import Input, Output |
This file contains 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 pdf2image import convert_from_path | |
image = convert_from_path("path_to_pdf.pdf") |
This file contains 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 convert_to_datetime(df, columns): | |
return df[columns].apply(pd.to_datetime, axis=1) |
This file contains 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 google.cloud import storage | |
def list_blobs(bucket, prefix): | |
""" | |
Lists all the blobs in the bucket | |
make sure prefix ends with '/' | |
""" | |
storage_client = storage.Client() | |
bucket = storage_client.get_bucket(bucket) | |
This file contains 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 os | |
with open('../data/labels.csv','r') as labels: | |
lines = [line.split(',') for line in labels.readlines()][1:] | |
for line in lines: | |
image = line[0] | |
label = line[1].split('/')[-1].replace('\n','') | |
if not os.path.exists('../data/train/'+label): | |
os.mkdir('../data/train/'+label) | |
os.rename('../data/train/'+image+'.jpg', '../data/train/'+label+'/'+image+'.jpg') |
This file contains 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 folium | |
def plot_heatmap(data): | |
''' | |
Args: | |
takes a list of lists [[lat, long]] | |
Returns: | |
Folium map object with heatmap overlay | |
''' | |
heatmap = folium.Map(tiles="CartoDBpositron", prefer_canvas=True) |
This file contains 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 sys | |
!conda install --yes --prefix={sys.prefix} numpy |
This file contains 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
# For Windows users# Note: <> denotes changes to be made | |
#Create a conda environment | |
conda create --name <environment-name> python=<version:2.7/3.5> | |
#To create a requirements.txt file: | |
conda list #Gives you list of packages used for the environment | |
conda list -e > requirements.txt #Save all the info about packages to your folder |
This file contains 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
# This script is designed to work with ubuntu 16.04 LTS | |
# with keras 1.2.2 and the latest Pytorch with CUDA 8 support | |
########################################################################## | |
#This is used to install CUDA 8 driver for Tesla K80 | |
########################################################################## | |
#!/bin/bash | |
echo "Checking for CUDA and installing." | |
# Check for CUDA and try to install. | |
if ! dpkg-query -W cuda-8-0; then |
NewerOlder