Skip to content

Instantly share code, notes, and snippets.

View gr33ndata's full-sized avatar

Tarek Amr gr33ndata

View GitHub Profile
@aparrish
aparrish / spacy_intro.ipynb
Last active August 9, 2023 01:41
NLP Concepts with spaCy. Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bzamecnik
bzamecnik / simples_lstm_softmax_classifier_keras.py
Created December 24, 2016 07:11
Simplest sequence classifier with LSTM & softmax in Keras
"""
Classifies sequences of length 10 with 20 features into 2 classes
with a single LSTM layer with 32 neurons.
See also a more involved example:
https://gist.github.com/bzamecnik/dccc1c4fdcf1c7a31757168b19c827a7
"""
from keras.layers import Input, LSTM, Dense
@adamwlev
adamwlev / monitor.py
Last active April 25, 2017 15:13
Make a Monitor Function to Train a Gradient Booster from Sklearn with automated early stopping
## Makes a monitor where the mean of last x oob improvements
## are used to determine early stopping. This can be ammended
## to any stopping criteria one sees as fit - consecutive x
## negatives, more negatives than positives in last x, etc.
def make_monitor(running_mean_len):
def monitor(i,self,args):
if np.mean(self.oob_improvement_[max(0,i-running_mean_len+1):i+1])<0:
return True
else:
@aessam
aessam / image2ascii.py
Last active December 24, 2016 04:18
The scripts convert images to ascii art, it count pixels for character and use it as base for color density.
"""
The basic idea is that I loop through all characters and count the number of
pixels and make <Hashtable number of pixels as a key and character as value>
The table will not have 255 value so to cover this I had to calculate the
slope of change as a base step for the colors.
example, if we have 50 value and we need 255 value, then each 255/50 = 5.1
Then with each gray color we will devied by 5 so we have index to
be fetched from the keys of the pixels table
@pudo
pudo / afriregex.py
Created August 28, 2014 19:08
Is something mentioning Africa?
import re
AFRICA = [u"Africa", u"Algeria", u"Angola", u"Benin", u"Botswana",
u"Burkina Faso", u"Burundi", u"Cameroon", u"Cape Verde",
u"Central African Republic", u"Chad", u"Comoros", u"Congo",
u"Djibouti", u"Egypt", u"Equatorial Guinea", u"Eritrea",
u"Ethiopia", u"Gabon", u"Gambia", u"Ghana", u"Guinea",
u"Guinea-Bissau", u"Ivory Coast", u"Kenya", u"Lesotho",
u"Liberia", u"Libya", u"Madagascar", u"Malawi", u"Mali",
u"Mauritania", u"Mauritius", u"Morocco", u"Mozambique",
@pudo
pudo / lookup.py
Created January 2, 2014 19:26
Lookup script to traverse Google Contacts and search keys on the MIT GPG key server.
import os
import gdata
import atom
import gdata.contacts
import gdata.contacts.service
import dataset
import requests
from lxml import html
from urlparse import urljoin, parse_qs
@widged
widged / d3lib.md
Created October 4, 2013 03:29
d3 libraries

chartFactory

/affini-tech/ChartFactory

Based on D3.JS and Dimple, ChartFactory provide the ability to build quickly D3.JS charts without coding any lines of javascript. Just define your dashboard in a JSON and voila !

charts: [
        {id:'chart1',
         width:800,height:250,

xAxis:{type:'Category',field: "Month",orderRule:'Date'},

@mbostock
mbostock / .block
Last active December 6, 2019 22:05
Icicle
license: gpl-3.0
redirect: https://observablehq.com/@d3/icicle
@hrldcpr
hrldcpr / tree.md
Last active May 1, 2024 00:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!