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
| from itertools import combinations | |
| import matplotlib.pyplot as plt | |
| import networkx as nx | |
| import numpy as np | |
| from sklearn.datasets import load_iris | |
| from sklearn.manifold import Isomap | |
| X,y = load_iris(return_X_y=True) | |
| pca = Isomap(n_components=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
| from itertools import combinations | |
| import matplotlib.pyplot as plt | |
| import networkx as nx | |
| import numpy as np | |
| X = np.random.normal(size=1000).reshape((500,2)) | |
| pos = {i:X[i] for i in range(X.shape[0])} | |
| g = nx.Graph() |
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 | |
| from scipy.odr import * | |
| import pandas as pd | |
| n = 10000 | |
| true_X = np.concatenate(tuple([np.eye(3)]*n)) | |
| true_X[:,0] = 1.0 | |
| true_beta = np.array([3, 5, 7]) | |
| true_y = np.matmul(true_X, true_beta) |
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 matplotlib.pyplot as plt | |
| import numpy as np | |
| import pandas as pd | |
| import seaborn as sns | |
| x = np.random.uniform(-10,10,size=10000) | |
| y = x**2 | |
| dydx = np.exp(x) / (1 + np.exp(-x)) ** 2 | |
| d = {'x':x, 'y':y, 'dydx':dydx} | |
| df = pd.DataFrame(d) |
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
| from graphviz import Digraph | |
| def brack_depth_map(file, bracks=('{', '}')): | |
| open_brack, close_brack = bracks | |
| d = {} | |
| depth = 0 | |
| with open(source_path) as f: | |
| for line_index, line in enumerate(f): | |
| d[line] = depth | |
| if open_brack in line: |
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 | |
| import sympy as sp | |
| from sympy.abc import a, x, y, z | |
| def reflect(exp): | |
| for symbol in exp.free_symbols: | |
| exp = exp.subs(symbol, -symbol) | |
| return exp |
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 | |
| import matplotlib.pyplot as plt | |
| import keras | |
| from keras.models import Sequential | |
| from keras.layers import Dense | |
| from keras.optimizers import SGD | |
| X = np.array([[0,0],[0,1],[1,0],[1,1]], "float32") | |
| y = np.array([[0],[1],[1],[0]], "float32") |
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 matplotlib.pyplot as plt | |
| from sympy import cos, pi, sin | |
| from sympy.abc import phi, theta | |
| from sympy.plotting.plot import plot3d_parametric_surface | |
| plt.rcParams['figure.figsize'] = 10,10 | |
| p1 = plot3d_parametric_surface(sin(phi) * cos(theta), sin(phi) * sin(theta), cos(phi), | |
| (phi, 0, pi), (theta, 0, 2 * pi)) |
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
| from itertools import combinations, chain, product | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| def full_frame(width=19.20, height=10.80): | |
| import matplotlib as mpl | |
| mpl.rcParams['savefig.pad_inches'] = 0 | |
| figsize = None if width is None else (width, height) | |
| fig = plt.figure(figsize=figsize) | |
| ax = plt.axes([0,0,1,1], frameon=False) |
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 | |
| import matplotlib.pyplot as plt | |
| shape=(1080, 1920, 3) | |
| img = np.zeros(shape) | |
| for i in range(1, shape[0]): | |
| for j in range(1, shape[1]): | |
| img[i,j,0] = i%j | |
| img[i,j,1] = j%i |