This file contains hidden or 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 | |
------------ | |
rate : float | |
Learning rate (ranging from 0.0 to 1.0) | |
number_of_iteration : int |
This file contains hidden or 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
""" | |
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
BSD License | |
""" | |
import numpy as np | |
# data I/O | |
data = open('input.txt', 'r').read() # should be simple plain text file | |
chars = list(set(data)) | |
data_size, vocab_size = len(data), len(chars) |
This file contains hidden or 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
% my training data. | |
% so if x > 3 || x < 7, y = 1, otherwise y = 0. | |
x = 1:100; | |
y = [0, 0, 0, 1, 1, 1, 1, zeros(1, 93)]; | |
% instead of theta' * x, I'm trying to create | |
% a non-linear decision boundary. | |
% So instead of y = theta_0 + theta_1 * x, I use: | |
function result = h(x, theta) | |
result = sigmoid(theta(1) + theta(2) * x + theta(3) * ((x - theta(4))^2)); |
This file contains hidden or 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
% data | |
x = [1, 2, 3, 4, 5, 6]; | |
y = [0, 0, 0, 1, 1, 1]; | |
% function to calculate the predicted value | |
function result = h(x, t0, t1) | |
result = sigmoid(t0 + t1 * x); | |
end | |
% sigmoid function |
This file contains hidden or 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 | |
------------ | |
rate : float | |
Learning rate (ranging from 0.0 to 1.0) | |
number_of_iteration : int |
This file contains hidden or 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 urllib2 | |
from lxml import html | |
from bs4 import BeautifulSoup | |
import re | |
from pymongo import MongoClient | |
from pymongo.errors import ConnectionFailure, DuplicateKeyError | |
import datetime | |
import time | |
DB_NAME = 'news_aggregator' |
This file contains hidden or 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 argparse | |
import re | |
from multiprocessing.pool import ThreadPool as Pool | |
import requests | |
import bs4 | |
root_url = 'http://pyvideo.org' | |
index_url = root_url + '/category/50/pycon-us-2014' | |