Skip to content

Instantly share code, notes, and snippets.

View bananemure's full-sized avatar

Stef Enigmatik bananemure

View GitHub Profile
language: en
pipeline:
- name: WhitespaceTokenizer
- name: CountVectorsFeaturizer
- name: EmbeddingIntentClassifier
policies:
- name: EmbeddingPolicy
max_history: 10
epochs: 100
batch_size:
@bananemure
bananemure / custom.css
Last active March 3, 2020 02:49
css for jupyter-lab
div#notebook p, div#notebook{
font-size: 100%;
line-height: 125%;
}.rendered_html pre, .rendered_html table{
font-size:85%;
line-height: 125%;
}.CodeMirror, .CodeMirror pre, .CodeMirror-dialog, .CodeMirror-dialog .CodeMirror-search-field, .terminal-app .terminal {
font-size: 130%;
line-height: 125%;
}
@bananemure
bananemure / lambda_function.py
Created September 25, 2018 20:52 — forked from fermayo/lambda_function.py
Lambda function to trigger a one-off ECS Fargate task
# Adapted from https://lobster1234.github.io/2017/12/03/run-tasks-with-aws-fargate-and-lambda/
import boto3
import os
def lambda_handler(event,context):
client = boto3.client('ecs')
response = client.run_task(
cluster=os.getenv('CLUSTER'),
launchType=os.getenv('LAUNCH_TYPE', 'FARGATE'),
@bananemure
bananemure / AttentionWithContext.py
Created July 5, 2018 22:03 — forked from cbaziotis/AttentionWithContext.py
Keras Layer that implements an Attention mechanism, with a context/query vector, for temporal data. Supports Masking. Follows the work of Yang et al. [https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf] "Hierarchical Attention Networks for Document Classification"
def dot_product(x, kernel):
"""
Wrapper for dot product operation, in order to be compatible with both
Theano and Tensorflow
Args:
x (): input
kernel (): weights
Returns:
"""
if K.backend() == 'tensorflow':
# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!
@bananemure
bananemure / faster_toPandas.py
Created April 21, 2018 15:12 — forked from joshlk/faster_toPandas.py
PySpark faster toPandas using mapPartitions
import pandas as pd
def _map_to_pandas(rdds):
""" Needs to be here due to pickling issues """
return [pd.DataFrame(list(rdds))]
def toPandas(df, n_partitions=None):
"""
Returns the contents of `df` as a local `pandas.DataFrame` in a speedy fashion. The DataFrame is
repartitioned if `n_partitions` is passed.
@bananemure
bananemure / automobile.ipynb
Created March 4, 2018 02:35 — forked from martinwicke/automobile.ipynb
Estimator demo using Automobile dataset
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bananemure
bananemure / compiling_building_c_cpp_notes.md
Created November 13, 2017 21:21 — forked from gubatron/compiling_building_c_cpp_notes.md
Things to remember when compiling and linking C/C++ programs

Things to remember when compiling/linking C/C++ software

by Angel Leon. March 17, 2015.

Include Paths

On the compilation phase, you will usually need to specify the different include paths so that the interfaces (.h, .hpp) which define structs, classes, constans, and functions can be found.

With gcc and llvm include paths are passed with -I/path/to/includes, you can pass as many -I as you need.

In Windows, cl.exe takes include paths with the following syntax: /I"c:\path\to\includes\ you can also pass as many as you need.

@bananemure
bananemure / geonames-org-wrapper.py
Created October 25, 2017 14:31 — forked from Markbnj/geonames-org-wrapper.py
A simple geonames.org wrapper in python
import requests
import json
# For information on endpoints and arguments see the geonames
# API documentation at:
#
# http://www.geonames.org/export/web-services.html
class Geonames(object):
@bananemure
bananemure / fasttext_similarity.py
Created October 16, 2017 05:01 — forked from bittlingmayer/fasttext_similarity.py
Similarity for two files output by fastText print-word-vectors or print-sentence-vectors
"""
Takes two files produced by fastText's print-word-vectors or print-sentence-vectors and compares the vectors by similarity.
(See https://github.com/facebookresearch/fastText.)
This can be useful for benchmarking output or even generating benchmark data.
For example: