Skip to content

Instantly share code, notes, and snippets.

len(mlp.coefs_[0])
import numpy as np
class Perceptron(object):
"""Perceptron classifier.
Parameters
------------
eta : float
Learning rate (between 0.0 and 1.0)
n_iter : int
# Partial portion of the "fit" function
for xi, target in zip(X, y):
update = self.eta * (target - self.predict(xi))
self.w_[1:] += update * xi
self.w_[0] += update
errors += int(update != 0.0)
def run():
data = faqs.keys()
print "FAQ data received. Finding features."
feats = make_feats(data)
with open('faq_feats.pkl', 'wb') as f:
pickle.dump(feats, f)
print "FAQ features found!"
$ dask-ec2 up --keyname mykey --keypair ~/.ssh/mykey.pem --nprocs 8 --type m4.2xlarge
stocks_df.plot(kind='line', grid=True, title='GOOG, FB, AMZN Adjusted Closes, May 2012').vlines(x='May 18, 2012', ymin=0, ymax=350)
def stem_and_lemmatize(words):
stems = stem_words(words)
lemmas = lemmatize_verbs(words)
return stems, lemmas
stems, lemmas = stem_and_lemmatize(words)
print('Stemmed:\n', stems)
print('\nLemmatized:\n', lemmas)
sample = """Title Goes Here
Bolded Text
Italicized Text
But this will still be here!
I run. He ran. She is running. Will they stop running?
I talked. She was talking. They talked to them about running. Who ran to the talking runner?
sample = """<h1>Title Goes Here</h1>
<b>Bolded Text</b>
<i>Italicized Text</i>
<img src="this should all be gone"/>
<a href="this will be gone, too">But this will still be here!</a>
I run. He ran. She is running. Will they stop running?
words = nltk.word_tokenize(sample)
print(words)