-
In confronting complex situations, no single model can capture everything. Thus, we need to bring several of models to bear, not just one
-
as powerful as models may be, they’re only guides to thinking. We have to maintain contact with reality.
-
Simple Graph
-
Undirected
-
has no loops
-
no more than one edge between any two different vertices
-
Regular Graph
- each vertex has the same number of neighbors
-
Complete Graph
-
each pair of vertices has an edge connecting them
- different functions with the same growth rate may be represented using the same O notation.
- If f(x) is a sum of several terms, the one with the largest growth rate is kept, and all others omitted.
- If f(x) is a product of several factors, any constants (terms in the product that do not depend on x) are omitted.
- stable sorting algorithms maintain the relative order of records with equal keys
- A comparison sort examines the data only by comparing two elements with a comparison operator
- Many integer sorting algorithms are based on the assumption that the key size "n" is large enough that all entries have unique key values, and hence that n << 2k, where << means "much less than."
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
"""This would outputs | |
x | |
True | |
__main__ | |
False | |
""" | |
import x | |
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 random | |
import math | |
import csv | |
def hypothesis(params, features): | |
z = sum(p * f for p, f in zip(params, features)) | |
return 1 / (1 + math.e ** -z) | |
def logistic_regression(learning_rate, samples): |
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 plac | |
import random | |
@plac.annotations(name="your name") | |
def hello(name): | |
"Greet you half of the time, and otherwise * you" | |
if random.randint(0, 10) > 5: | |
print "Hello %s" % name | |
else: | |
print "Screw you. I'm ... going ... home~" |
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
"""Compute mean and variance to normalize data""" | |
import dpark | |
import plac | |
import math | |
def prepare(s): | |
return [float(i.strip()) for i in s.split(",")] | |
def add_squared_list(vals): | |
squared_vals = [v * v for v in vals] |
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
"""Compute mean and variance to normalize data""" | |
import dpark | |
import plac | |
import numpy as np | |
def prepare(s): | |
return np.array([float(i.strip()) for i in s.split(",")]) | |
def main(filename): | |
lines = dpark.textFile(filename) |
Pony is an object-relational mapper. The most interesting feature of Pony is its ability to write queries to the database using generator expressions. Pony works with entities which are mapped to a SQL database. Using generator syntax for writing queries allows the user to formulate very eloquent queries. It increases the level of abstraction and allows a programmer to concentrate on the business logic of the application. For this purpose Pony analyzes the abstract syntax tree of a generator and translates it to its SQL equivalent.
Following is an example of a query in Pony:
select(p for p in Product if p.name.startswith('A') and p.cost <= 1000)
OlderNewer