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
len(mlp.coefs_[0]) |
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 numpy as np | |
class Perceptron(object): | |
"""Perceptron classifier. | |
Parameters | |
------------ | |
eta : float | |
Learning rate (between 0.0 and 1.0) | |
n_iter : int |
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
# 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) |
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 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!" |
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
$ dask-ec2 up --keyname mykey --keypair ~/.ssh/mykey.pem --nprocs 8 --type m4.2xlarge |
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
stocks_df.plot(kind='line', grid=True, title='GOOG, FB, AMZN Adjusted Closes, May 2012').vlines(x='May 18, 2012', ymin=0, ymax=350) |
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 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) |
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
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? |
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
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? |
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
words = nltk.word_tokenize(sample) | |
print(words) |
OlderNewer