Skip to content

Instantly share code, notes, and snippets.

./data_viz_easy/raw/tut1.ipynb: "![tut1_plots_you_make](https://i.imgur.com/54BoIBW.png)\n",
./data_viz_easy/raw/tut1.ipynb: "![tut1_spotify_head](https://i.imgur.com/GAGf6Td.png)\n",
./data_viz_easy/raw/tut1.ipynb: "![tut1_read_csv](https://i.imgur.com/18LKa03.png)\n",
./data_viz_easy/raw/tut3.ipynb: "![tut3_insurance](https://i.imgur.com/1nmy2YO.png)\n",
./data_viz_easy/raw/ex2.ipynb: "![ex2_ign](https://i.imgur.com/Oh06Fu1.png)\n",
./data_viz_easy/raw/ex6.ipynb: "![ex6_search_dataset](https://i.imgur.com/QDEKwYp.png)\n",
./data_viz_easy/raw/ex6.ipynb: "![ex6_dataset_added](https://i.imgur.com/oVlEBPx.png)\n",
./data_viz_easy/raw/ex6.ipynb: "![ex6_dataset_dropdown](https://i.imgur.com/4gpFw71.png)\n",
./data_viz_easy/raw/ex6.ipynb: "![ex6_filepath](https://i.imgur.com/pWe0sVb.png)\n",
./data_viz_easy/raw/tut7.ipynb: "![tut7_new_kernel](https://i.imgur.com/ZqW6V2X.png)\n",
import os
import re
import requests
import shutil
def get_url_and_fname(line):
if 'i.imgur.com/' in line:
regex = r"(https?://i.imgur.com/(.*.png))"
@dansbecker
dansbecker / predict_from_text.py
Created July 19, 2017 16:07 — forked from tyarkoni/predict_from_text.py
simple example predicting binary outcome from text features with sklearn
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline
import pandas as pd
import numpy as np
# Grab just two categories from the 20 newsgroups dataset
categories=['sci.space', 'rec.autos']
@dansbecker
dansbecker / predict_from_text.py
Last active July 19, 2017 16:29 — forked from tyarkoni/predict_from_text.py
simple example predicting binary outcome from text features with sklearn (with extra comments for Alon)
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
# A pipeline "stitches together" the various steps of a modeling process into a single piece. You should either try to get a separate explanation of this, or try to do without it.
# In general pipelines are pretty cool. But, one more thing to learn.
from sklearn.pipeline import Pipeline
import pandas as pd
import numpy as np
@dansbecker
dansbecker / featurize.py
Last active April 28, 2017 20:55
Use a pretrained network to featurize data for cats vs dogs
from keras.applications.resnet50 import ResNet50, preprocess_input
from keras.preprocessing.image import load_img, img_to_array
import numpy as np
from os import listdir
from os.path import join
import pandas as pd
def featurize(fpath, model, img_size):
'''Use trained model to convert image to vector describing content
Determining if the function dgettext exists failed with the following output:
Change Dir: /home/powersju/Madeline_2.0_PDE/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make.exe" "cmTC_872e9/fast"
/usr/bin/make -f CMakeFiles/cmTC_872e9.dir/build.make CMakeFiles/cmTC_872e9.dir/build
make[1]: Entering directory '/home/powersju/Madeline_2.0_PDE/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_872e9.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=dgettext -o CMakeFiles/cmTC_872e9.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.6.2/Modules/CheckFunctionExists.c
<command-line>:0:23: warning: conflicting types for built-in function ‘dgettext’
/usr/share/cmake-3.6.2/Modules/CheckFunctionExists.c:7:3: note: in expansion of macro ‘CHECK_FUNCTION_EXISTS’
$ cat CMakeFiles/CMakeOutput.log
The system is: CYGWIN - 2.6.0(0.304/5/3) - x86_64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /usr/bin/cc
Build flags:
Id flags:
The output was:
0
@dansbecker
dansbecker / keras_round_trip_model_saving.py
Created May 23, 2016 20:32
Gist showing a weird caveat in model saving and model loading in keras. Uncommenting lines 25-26 causes an error.
from keras.layers import Input, Dense, merge, Flatten
from keras.layers.convolutional import Convolution2D
from keras.models import Model, model_from_json
from keras import backend as K
def make_model(img_edge_size):
img_shape = (3, img_edge_size, img_edge_size)
mask_shape = (1, img_edge_size, img_edge_size)
@dansbecker
dansbecker / readme.md
Created May 16, 2016 06:17 — forked from baraldilorenzo/readme.md
VGG-16 pre-trained model for Keras

##VGG16 model for Keras

This is the Keras model of the 16-layer network used by the VGG team in the ILSVRC-2014 competition.

It has been obtained by directly converting the Caffe model provived by the authors.

Details about the network architecture can be found in the following arXiv paper:

Very Deep Convolutional Networks for Large-Scale Image Recognition

K. Simonyan, A. Zisserman

@dansbecker
dansbecker / autoencoder.py
Created April 14, 2016 23:22
Non-functioning autoencoder, with an error that surprises me.
import numpy as np
from keras.models import Model
from keras.layers import Input, Dense
input_size = 1000
n_obs = 200
encoding_size = 50
x = Input(shape=(input_size,))
z = Dense(encoding_size, activation='sigmoid', name='z')(x)