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 math | |
import statistics | |
import copy | |
centroids = [(2, 2), (-2, -2)] | |
data_points = [ \ | |
(-1.88, 2.05), \ | |
(-0.71, 0.42), \ | |
(2.41, -0.67), \ | |
(1.85, -3.80), \ |
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 asyncio, evdev | |
from mouse_handlers import left_mouse_down, left_mouse_up | |
from mouse_handlers import right_mouse_down, right_mouse_up | |
from evdev import ecodes | |
mouse_file = '/dev/input/event6' | |
keyboard_file = '/dev/input/event9' | |
down = 1 |
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
% Hidden Markov Model example | |
% The weather can be in state "sun" or "rain" initially | |
% with 0.5 probabilities for each state | |
0.5::start(weather, sun); | |
0.5::start(weather, rain). | |
% In a given moment in time, if today is sunny - "sun", | |
% tommorrow will be 0.6 sun or 0.4 rain | |
0.6::trans(weather, Moment_in_time, sun, sun); |
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 matplotlib.image as mpimg | |
import numpy as np | |
# Read in the image and print out some stats | |
# Note: in the previous example we were reading a .jpg | |
# Here we read a .png and convert to 0,255 bytescale | |
image = (mpimg.imread('test.png')*255).astype('uint8') | |
print('This image is: ',type(image), | |
'with dimensions:', image.shape) |
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
def longestPalindrome(self, s): | |
""" | |
:type s: str | |
:rtype: str | |
""" | |
best_palindrome_length = 1 | |
best_palindrome = s[0] | |
n = len(s) | |
for i in range(2 * n - 1): |
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
# Load pickled data | |
import pickle | |
import os.path | |
import os | |
import wget | |
import cv2 | |
import zipfile | |
import numpy as np | |
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
package config; | |
import java.io.File; | |
import java.io.IOException; | |
import org.junit.Test; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import org.openqa.selenium.chrome.ChromeDriverService; |
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
0.9::attribute_value(brown, brand). | |
0.9::attribute_value(brown, color). | |
0.9::attribute_value(tv, noun). | |
0.9::attribute_value(dress, clothing). | |
member(X, [Y|T]) :- X = Y; member(X, T). | |
item_prop(1, brown, brand). | |
item_prop(1, tv, noun). |
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 sys | |
signs_map = { | |
'>': 1, | |
'<': -1, | |
'_': 0 | |
} | |
reverse_signs_map = { | |
0: '_', |
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 tensorflow as tf | |
def tf_repeat(tensor, repeats, axis): | |
shape = tf.shape(tensor) | |
axis_range = tf.range(shape.shape[0].value) | |
ones = tf.ones_like(axis_range) | |
repeats_tiled = tf.fill(tf.shape(axis_range), repeats) | |
axis_tiled = tf.fill(tf.shape(axis_range), axis) | |
mask = tf.equal(axis_range, axis_tiled) |
OlderNewer