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 | |
| def estimate_numpy_array_memory_size(shape, dtype): | |
| size = np.product(shape) | |
| return size * dtype.itemsize | |
| def estimate_coo_matrix_memory_size(shape, dtype, nnz): | |
| # each nonzero element has entries in data with corresponding dtype + entries in col and row | |
| row_count = shape[0] | |
| col_count = shape[1] if len(shape) > 1 else 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
| import numpy as np | |
| import scipy.constants | |
| # These can differ depending on the exact hardware and setting, but given that | |
| # we do approximation anyway - this shouldn't be a problem | |
| red_wavelength = 570 * 10 ** -9 | |
| green_wavelength = 540 * 10 ** -9 | |
| blue_wavelength = 430 * 10 ** -9 | |
| h = scipy.constants.Planck |
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 | |
| def sigmoid(x): | |
| return 1 / (1 + np.exp(-x)) | |
| def sigmoid_derivative(output): | |
| return output * (1 - output) |
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 max_floor_new2(eggs_count, trials): | |
| if trials == 1: | |
| return 1 | |
| elif eggs_count == 1: | |
| return trials | |
| elif eggs_count >= trials: | |
| return 2 ** trials - 1 | |
| else: | |
| binomial = 1 | |
| sum = 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 numpy as np | |
| from scipy.ndimage.interpolation import shift | |
| import time | |
| def max_floor_new(eggs_count, trials): | |
| if trials == 1: | |
| return 1 | |
| elif eggs_count == 1: | |
| return trials |
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 max_floor(eggs_count, trials): | |
| if trials == 1: | |
| return 1 | |
| elif eggs_count == 1: | |
| return trials | |
| else: | |
| return max_floor(eggs_count-1, trials-1) + max_floor(eggs_count, trials-1) + 1 | |
| print max_floor(eggs_count=2, trials=14) # 105 | |
| print max_floor(eggs_count=7, trials=20) # 137979 |
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
| C:\Users\templ\books\Scripts\python.exe C:/Users/templ/PycharmProjects/books/playground.py | |
| Fiction : 4746 | |
| Speculative fiction : 4313 | |
| Science Fiction : 2870 | |
| Novel : 2463 | |
| Fantasy : 2413 | |
| Children's literature : 2121 | |
| Mystery : 1396 | |
| Young adult literature : 825 | |
| Suspense : 765 |
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
| # coding=utf-8 | |
| inp = u'аослп' | |
| def anagram(inp): | |
| if len(inp) <= 1: | |
| return [inp] | |
| else: | |
| results = [] |
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 requests | |
| from HTMLParser import HTMLParser | |
| class MyHTMLParser(HTMLParser): | |
| def __init__(self): | |
| HTMLParser.__init__(self) | |
| self.cards = {} | |
| def reset_cards(self): |
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 os | |
| os.environ['DATAROBOT_ENDPOINT'] = 'http://localhost/api/v2' | |
| os.environ['DATAROBOT_USERNAME'] = 'test@test.ru' | |
| os.environ['DATAROBOT_PASSWORD'] = 'testing123' | |
| from datarobot_sdk import Project | |
| from time import sleep | |
| query_interval_in_seconds = 10 | |
| path_to_train_file = '/home/modintsov/workspace/shrink/tmp/mbtest-datasets/559a516366fca05b806c92bf/2006_2010_Draft_Tools_for_is50p_414x5.csv' | |
| def wait_for_project_queue_finished(project): |
NewerOlder