Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import urllib2 | |
import copy | |
from random import seed | |
from random import randrange | |
from math import sqrt | |
''' |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import urllib2 | |
import numpy as np | |
def load_simple_data(): | |
features = ([ | |
[1. , 2.1] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import urllib2 | |
from numpy import mat, eye, nonzero, mean, var, shape, inf, sum, power, ones, linalg, \ | |
corrcoef, zeros | |
def createDataSet(url): | |
''' | |
创建数据集,最后一列为目标变量 |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import nltk | |
def generate_model(cfd, word, num=15): | |
''' | |
给定条件概率分布和一个随机的词,生成一段文字 | |
''' | |
for i in range(num): |
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
function ssh_tunnel() { | |
host="[email protected]" | |
for port in "$@"; do | |
echo "> listen to port ${port}..." | |
# kill existing tunnel | |
lsof -i:"${port}" \ | |
| awk '$0~/^ssh/{print $2}' \ | |
| sort -u \ | |
| xargs kill | |
# establish new tunnel |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import urllib2 | |
from numpy import mat, ones, shape, exp, array, arange | |
import matplotlib.pyplot as plt | |
def createDataSet(): | |
features = [] | |
labels = [] |
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
#!/usr/bin/env python | |
import re | |
from numpy import ones, log | |
def createDataSet(): | |
docs = [ | |
['my', 'dog', 'has', 'flea', 'problem', 'help', 'please'], | |
['maybe', 'not', 'take', 'him', 'to', 'dog', 'park', 'stupid'], | |
['my', 'dalmation', 'is', 'so', 'cute', 'I', 'love', 'him'], |
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
#!/usr/bin/env python | |
from math import log | |
import operator | |
import urllib2 | |
def createDataSet(): | |
''' | |
prepare data: the last column is the label | |
dataSet is like: |