query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Vehicle Miles Traveled (Trips per vehicle X miles per trip)
def calculate_vht_dynamically(meta_data, interval, **kwargs): flow_data = meta_data.get('flow') speed_data = meta_data.get('speed') missing_data = kwargs.get('missing_data', cfg.MISSING_VALUE) vd = moe_helper.VIRTUAL_RNODE_DISTANCE seconds_per_hour = 3600 vht_data = [] for flow, speed in zip...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trafficJam(lanes,miles):\n\n\n feet = miles * 5280 #Feet in a mile\n total_feet = feet * lanes #Total feet in all lanes\n cars = total_feet / 15 #Average feet a car takes\n\n return cars", "def test_get_miles(self):\n miles = location_util.vincenty(COORDINATES_PARIS,\n ...
[ "0.6453263", "0.5916066", "0.5779557", "0.577009", "0.57544905", "0.5743861", "0.5491067", "0.5485611", "0.54791665", "0.53125626", "0.5312528", "0.52798194", "0.5251859", "0.52304333", "0.5122987", "0.51183033", "0.51022637", "0.50925875", "0.509046", "0.5081807", "0.5075941...
0.0
-1
Load status code table.
def load_status_table():
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_data():\n try:\n loader.download()\n load_table_data()\n status = 'loaded'\n except Exception as ex:\n log.log_traceback(ex)\n status = 'failed'\n return flask.jsonify({'status': status})", "def load_status(sec_status):\n with open(sec_status, 'r') as infil...
[ "0.6304792", "0.6128468", "0.6098472", "0.5995203", "0.55925363", "0.55922043", "0.55655104", "0.55066717", "0.54105455", "0.53784657", "0.5279865", "0.52605635", "0.51376367", "0.5121974", "0.5121277", "0.51052105", "0.5081247", "0.50530696", "0.5048871", "0.5047821", "0.504...
0.8231332
0
Sample 'Nsamples' points from the posterior distribution.
def sample_posterior( rng_key: random.PRNGKey, model, data: np.ndarray, Nsamples: int = 1000, alpha: float = 1, sigma: float = 0, T: int = 10, gibbs_fn=None, gibbs_sites=None): if gibbs_fn is None or gibbs_sites is None: return sample_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def posterior_sampler(self, nsamples, seed=0, verbose=True):\n\n import random\n\n random.seed(seed)\n sample = self.get_chain()[-self.get_tune:]\n sample = sample.reshape(-1, sample.shape[-1])\n sample = random.choices(sample, k=nsamples)\n\n return sample", "def sample_parameters_posterior(se...
[ "0.77720845", "0.7699922", "0.7486653", "0.73114294", "0.7251321", "0.72014636", "0.71816784", "0.71629894", "0.7017441", "0.6927576", "0.6925858", "0.69242823", "0.69242823", "0.68736494", "0.68268055", "0.6809603", "0.67950916", "0.67018616", "0.6695109", "0.66541606", "0.6...
0.0
-1
Receive an answer from the daemon and return the response.
def receive_data(socket): answer = b"" while True: packet = socket.recv(4096) if not packet: break answer += packet response = pickle.loads(answer) socket.close() return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def receive_response(self):\n return self.socket.receive()", "def receive_response(self, private_key, responder_id, msg_tag, response):\n return self._handle_response(private_key, responder_id, msg_tag, response)", "async def recv(self):\n return await self.receptor.response_queue.get()", ...
[ "0.60401213", "0.59346366", "0.57792765", "0.56736755", "0.5629071", "0.5618967", "0.5585548", "0.55596626", "0.55558836", "0.55464935", "0.5528463", "0.55242884", "0.5516146", "0.5492562", "0.54331195", "0.5410309", "0.54007417", "0.5396902", "0.5392102", "0.53897995", "0.53...
0.0
-1
Print a response message and exit with 1, if the response wasn't a success.
def process_response(response): # Print it and exit with 1 if operation wasn't successful print(response['message']) if response['status'] != 'success': sys.exit(1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_ok(msg):\n print('OK - %s' % (msg))\n sys.exit(0)", "def check_response(rv):\n if rv != 'OK':\n print \"No message found\"\n return False\n return True", "def _is_successful(response) -> bool:\n return response.status_code == 200", "def exit_success(message: Optional[st...
[ "0.7340724", "0.69758445", "0.67532015", "0.67513496", "0.66959393", "0.66255456", "0.65675175", "0.6507938", "0.64950174", "0.649325", "0.6481977", "0.6443774", "0.6417801", "0.64016646", "0.6399089", "0.63857675", "0.6373736", "0.6370738", "0.634704", "0.6334164", "0.632734...
0.81670505
0
Connect to a daemon's socket.
def connect_socket(root_dir): # Get config directory where the daemon socket is located config_dir = os.path.join(root_dir, '.config/pueue') # Create Socket and exit with 1, if socket can't be created try: client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) socket_path = os.path....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _connect_socket(self):\n self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n self.sock.connect((self.ip, self.port))\n print(\"Connected to %s at port %d\" % (self.ip, self.port))", "def __connect():\n # Create socket\n sock = socket.socket(socket.AF_INET, socket.SOCK_S...
[ "0.7152145", "0.7110767", "0.69015676", "0.68839574", "0.6861228", "0.68268406", "0.68084097", "0.6778838", "0.67785", "0.67722744", "0.67408895", "0.6712054", "0.66876894", "0.6654631", "0.6639277", "0.66327703", "0.6606217", "0.6582687", "0.65193504", "0.64702415", "0.64390...
0.76585114
0
Solve x^2 Dy^2 = 1
def solve_D(D): sdr = math.sqrt(D) sdi = int(sdr) if sdi == sdr : return None y = 1 while True : xr = math.sqrt(y*y*D+1) xi = int(xr) if xr == xi : return xi y += 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def d2(x0,y0,x1,y1):\n return (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1)", "def DirectSolve(self, y):\n if y >= -self.R:\n a1 = self.apath[y+1]\n if y == -2:\n a2 = 0\n else:\n a2 = self.apath[y+2] \n def constraints(a)...
[ "0.68067557", "0.6691289", "0.65991104", "0.63777244", "0.6326121", "0.63033235", "0.6270462", "0.6249652", "0.62165457", "0.61716276", "0.61288655", "0.6075027", "0.6069478", "0.60646653", "0.6061647", "0.60577327", "0.60004056", "0.5963938", "0.5960648", "0.59581274", "0.59...
0.63733596
4
Area of the shape.
def area(self) -> float: raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def area(self):\n return self._ned_shape.area", "def area(self):\n return self.length*self.length", "def area(self):\n area = self.__size * self.__size\n return area", "def area(self):\n area = self.__size * self.__size\n return(area)", "def area(self):\n ar...
[ "0.859661", "0.8539494", "0.8486993", "0.84419984", "0.8439382", "0.8387308", "0.83254606", "0.8314752", "0.8312584", "0.8241274", "0.8237015", "0.8232725", "0.821546", "0.821546", "0.821546", "0.8212535", "0.8212535", "0.8206858", "0.8191822", "0.8187152", "0.8187152", "0....
0.853149
2
Check if the point is inside the shape. Support semantics like `if point in shape`
def __contains__(self, point: Point2D) -> bool: raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isInside(point_x, point_y, area_left, area_top, area_width, area_height):\n return (area_left <= point_x < area_left + area_width) and (area_top <= point_y < area_top + area_height)", "def point_in_poly(x_point: float, y_point: float) -> bool:\n\n # Semi-F47 extended states all devices should be able t...
[ "0.7572516", "0.75540507", "0.7464582", "0.7464582", "0.74356055", "0.74341583", "0.73613477", "0.73446983", "0.732574", "0.732574", "0.72910684", "0.72736067", "0.721901", "0.7183408", "0.7174966", "0.7172073", "0.7092216", "0.7086525", "0.7081146", "0.7063076", "0.70347816"...
0.6834352
40
Get string representation of the shape.
def __str__(self) -> str: raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shape(shape):\n print shape_str(shape)", "def shape_str(shape):\n return '\\n'.join(''.join(map({'X': 'X', None: 'O'}.get, line))\n for line in shape)", "def shape2str(x):\n return \"[\" + \" x \".join([str(x) for x in x.shape]) + \"]\"", "def __str__(self):\n return 'Type...
[ "0.8021077", "0.7999233", "0.77616286", "0.7733696", "0.7653659", "0.741345", "0.7397373", "0.7232627", "0.7196523", "0.7184904", "0.7127414", "0.7106067", "0.6909982", "0.68698555", "0.68658304", "0.68586445", "0.6852846", "0.6846274", "0.6837171", "0.68368703", "0.68325347"...
0.0
-1
reads the config file, which passes the full path names for the source and destination files
def readConf(confFile): with open(confFile) as json_data_file: configData = json.load(json_data_file) return configData
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_config(self, config_filename):", "def process_config(self, filename):\n \n self.log_message(\"processing config file: \"+filename)\n parser = SafeConfigParser()\n parser.optionxform = str\n parser.read(filename)\n self.source_files[filename] = parser\n \n...
[ "0.73588794", "0.6609339", "0.6605063", "0.64606553", "0.64132637", "0.6266823", "0.62592244", "0.6249302", "0.621985", "0.61848795", "0.6154891", "0.61509305", "0.60969436", "0.6065688", "0.60582817", "0.60545635", "0.60386914", "0.6036724", "0.6027614", "0.6019661", "0.6017...
0.0
-1
takes the config data and calls the moveFile function
def parseConf(confData): groupNames = confData.keys() for group in groupNames: logger.info("processing {0}".format(confData[group]["group_name"])) logger.info("source: {0}".format(confData[group]["source"])) sourcePath = confData[group]["source"] logger.info("destination: {0}".format(confData[group]["destinat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_file(self, ctx):\n pass", "def move_from_temp_directory(self):", "def on_moved(self, event):\n print(\"Moved\")\n time.sleep(5)\n self.moveFile(event.dest_path)", "def act_move_file(self, file_source, file_target):\n try:\n if not os.path.isfile(file_sou...
[ "0.68956894", "0.62802804", "0.6229746", "0.62043524", "0.6184494", "0.6134909", "0.6030467", "0.60047734", "0.59891856", "0.5984465", "0.59631", "0.59522945", "0.59437495", "0.59367484", "0.5934672", "0.5874775", "0.5864976", "0.58420366", "0.5731938", "0.57225734", "0.57017...
0.5333043
52
experimental function to configure logging
def logConfigure(logFileName, debugFlag=False): logPath = '../log/' logFile = '{0}{1}'.format(logPath, logFileName) logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) # create file handler which logs even debug messages fh = logging.FileHandler(logFile) fh.setLevel(logging.DEBUG) # create c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _configure_logging(self):\n pass", "def __setup_logging(self):\n\n loglevel = logging.INFO\n if self.config[\"verbose\"]:\n loglevel = logging.DEBUG\n\n FORMAT = '[%(asctime)s %(filename)s:%(lineno)s %(levelname)s] %(message)s'\n if self.config[\"log\"]:\n ...
[ "0.8682738", "0.7844487", "0.782434", "0.7785766", "0.7695341", "0.76718855", "0.7670273", "0.7550738", "0.7525644", "0.75252914", "0.7519401", "0.74901396", "0.7472518", "0.74642056", "0.74499345", "0.74477077", "0.7439869", "0.74364644", "0.7401072", "0.73922217", "0.738454...
0.0
-1
Moves a given file from one directory to another, if the target file exists in that directory then the target is coppied as .bak
def moveFile(src, dest, bak="bak"): message = "processing: {0} -> {1}".format(src, dest) logger.info(message) #compare the source and destination, if the files are the same do nothing if os.path.exists(src) and os.path.exists(dest): message = "file {0} found, comparing to {1}".format(src, dest) logger.info(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def act_move_file(self, file_source, file_target):\n try:\n if not os.path.isfile(file_source):\n return\n path = os.path.dirname(file_target)\n if not os.path.exists(path):\n os.makedirs(path)\n shutil.move(file_source, file_target)\...
[ "0.69844866", "0.68424857", "0.67688906", "0.6750627", "0.6640949", "0.6619133", "0.64734495", "0.6451692", "0.64118326", "0.6409421", "0.6336517", "0.6331257", "0.62477756", "0.6222287", "0.61894214", "0.6184978", "0.6182519", "0.61495227", "0.61475456", "0.6146206", "0.6137...
0.73066294
0
checks to see if there are any pending git commits any pending commits and the script will exit
def checkGit(directory):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commit_check(ctx):\n result = ctx.run(f\"{VENV_PREFIX} cz check --rev-range master..\", warn=True)\n if result.exited == 3: # NO_COMMIT_FOUND\n exit(0)\n else:\n exit(result.exited)", "def local_changes():\n result, output = popen('git status', False, False)\n try:\n retu...
[ "0.7016581", "0.6914419", "0.6737097", "0.66644025", "0.6564627", "0.65292114", "0.6516937", "0.64886695", "0.6482053", "0.64482194", "0.6266667", "0.6266017", "0.62159777", "0.605793", "0.6002832", "0.59305567", "0.59163755", "0.5910263", "0.5902178", "0.5882748", "0.5877310...
0.5918445
16
uses sha512 to verify that the soruce file and the destination file are the same
def verifyFile(source, destination): sourceHash = hashlib.sha256(open(source, 'rb').read()).digest() destinationHash = hashlib.sha256(open(destination, 'rb').read()).digest() if sourceHash == destinationHash: return (True, str(sourceHash)) return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sha512_file(file_name):\n\n hash_func = hashlib.sha256()\n\n with open(file_name, \"rb\") as fd:\n hash_func.update(fd.read())\n\n return hash_func.hexdigest()", "def sha512(digest, fileName):\n\n rc = sha512sum(digest, fileName)\n logging.debug(\"SHA512 (%s) = %s\", fileName, 'ok' if r...
[ "0.67451125", "0.6664096", "0.657134", "0.6448049", "0.6399249", "0.625933", "0.6167828", "0.6108488", "0.60713184", "0.60061806", "0.5995028", "0.5963704", "0.5957321", "0.5945975", "0.59287506", "0.5924034", "0.59063375", "0.58697104", "0.58629924", "0.58619326", "0.584064"...
0.73826236
0
Testing funciton for nose
def test_function(): logger = logConfigure("promote_test.log") message = "starting test of promote.py" logger.info(message) testConfigFile = "test.json" message = "testing existence of test config file {0}".format(testConfigFile) logger.info(message) testConfigExists = True print "{0}".format(str(os.path.is...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test():\n nose.run()", "def unitary_test():", "def tests():", "def test_something():", "def test():\n pass", "def test():", "def test():", "def test_func():\n pass", "def test_dummy():", "def test_basic_execution(self):", "def _test(self):", "def _test(self):", "def _test(s...
[ "0.8469399", "0.81757426", "0.81619143", "0.80219984", "0.7960618", "0.79495305", "0.79495305", "0.7836223", "0.7823098", "0.7812693", "0.77668256", "0.77668256", "0.77668256", "0.77668256", "0.77668256", "0.77300036", "0.7686654", "0.76723796", "0.76494384", "0.7616399", "0....
0.0
-1
Return a 2D binary array (mask) in which all pixels are either 0 or 1
def binary_array(array, thresh, value=0): if value == 0: # Create an array of ones with the same shape and type as # the input 2D array. binary = np.ones_like(array) else: # Creates an array of zeros with the same shape and type as # the input 2D array. binary = np.zeros_like(ar...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocess_mask(y):\n y[y <= 255./2] = 0 # Needs to be in this order, otherwise 1 gets overwritten\n y[y > 255./2] = 1\n binary_mask = y.astype(np.uint8)\n\n return binary_mask", "def get_binary_mask(self,index):\n mask = self.load_mask_png(index)\n (rows,cols) = np.where(mask>0)[0:...
[ "0.7493042", "0.74517816", "0.73958826", "0.7184049", "0.69006175", "0.6856227", "0.66759485", "0.6636539", "0.66169465", "0.660961", "0.6597759", "0.65790963", "0.6544609", "0.6487091", "0.64485276", "0.6424487", "0.64208025", "0.6418105", "0.63831675", "0.63831675", "0.6383...
0.6636052
8
Implementation for Gaussian blur to reduce noise and detail in the image
def blur_gaussian(channel, ksize=3): return cv2.GaussianBlur(channel, (ksize, ksize), 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gaussian_blur(self,img):\n return cv2.GaussianBlur(img, (self.kernel_size, self.kernel_size), 0)", "def __gaussian_blur(self, img, kernel_size=3):\n return cv2.GaussianBlur(img, (kernel_size, kernel_size), 0)", "def reblur(inp_img):\n\n img = np.array(inp_img)\n kernel_deviation = 1.5\n...
[ "0.81383604", "0.81237864", "0.7887736", "0.7797448", "0.77877295", "0.7773531", "0.77326", "0.77160615", "0.77160615", "0.77160615", "0.77160615", "0.77160615", "0.77160615", "0.77160615", "0.77160615", "0.77160615", "0.77160615", "0.77160615", "0.77160615", "0.77160615", "0...
0.6984415
54
Implementation of Sobel edge detection
def mag_thresh(image, sobel_kernel=3, thresh=(0, 255)): # Get the magnitude of the edges that are vertically aligned on the image sobelx = np.absolute(sobel(image, orient='x', sobel_kernel=sobel_kernel)) # Get the magnitude of the edges that are horizontally aligned on the image sobely = np.absolute(s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edgeDetectionSobel(img: np.ndarray, thresh: float = 0.7) -> (np.ndarray, np.ndarray):\r\n img = cv2.GaussianBlur(img, (3, 3), 0)\r\n\r\n Gx = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]])\r\n Gy = np.array([[-1, -2, -1], [0, 0, 0], [1, 2, 1]])\r\n thresh = thresh * 255\r\n\r\n smooth_x = cv2.fi...
[ "0.78049487", "0.7523176", "0.7453298", "0.7149273", "0.7147045", "0.68002224", "0.67776054", "0.6688813", "0.66406983", "0.6535428", "0.650613", "0.64538646", "0.6355191", "0.6325599", "0.62427187", "0.6242515", "0.62358284", "0.6234513", "0.6210202", "0.62055576", "0.618762...
0.5565513
86
Find edges that are aligned vertically and horizontally on the image
def sobel(img_channel, orient='x', sobel_kernel=3): # cv2.Sobel(input image, data type, prder of the derivative x, order of the # derivative y, small matrix used to calculate the derivative) if orient == 'x': # Will detect differences in pixel intensities going from # left to right on the image (i.e....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_pixel_edges(img):\n \n transparency_cells = img.T[3].T # Ignores rbg, returns only transparency. \n # Values are either:\n # 0 (fully transparent) or \n # 1 (not at all transparent)\n right_up...
[ "0.70753133", "0.68227047", "0.6705829", "0.6586866", "0.65544", "0.6475599", "0.6472296", "0.64205885", "0.63843906", "0.63522637", "0.6331612", "0.632474", "0.63219196", "0.625547", "0.62513036", "0.6231831", "0.61775094", "0.6137651", "0.6128345", "0.6114049", "0.6106298",...
0.0
-1
Apply a threshold to the input channel
def threshold(channel, thresh=(128,255), thresh_type=cv2.THRESH_BINARY): # If pixel intensity is greater than thresh[0], make that value # white (255), else set it to black (0) return cv2.threshold(channel, thresh[0], thresh[1], thresh_type)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_thresholding(x):\n return x > threshold_otsu(x)", "def global_threshold(img, threshold_method):\n pass", "def threshold(self,thresholdValue):\n # TO DO\n pass", "async def threshold(self, ctx, threshold: int):\n if threshold > 0:\n self.bot.db.execute(\"UPDATE ...
[ "0.694529", "0.67643166", "0.6673264", "0.666129", "0.6620091", "0.65957475", "0.65373987", "0.65017444", "0.6471623", "0.64246637", "0.64003336", "0.64003336", "0.64003336", "0.6351905", "0.61548465", "0.61462206", "0.61106056", "0.61106056", "0.61106056", "0.61106056", "0.6...
0.6551694
6
Asks user to specify a city, month, and day to analyze.
def get_filters(): print('Hello! Let\'s explore some US bikeshare data!') # Get user input for city (chicago, new york city, washington). HINT: Use a while loop to handle invalid inputs while True: city = input('Would you like to see data for Chicago, New York City or Washington?') if city....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Raw_Data(city,month,day):\n print(\"The city you have entered is: \",city)\n print(\"The month you have entered is: \",month)\n print(\"The day you have entered is: \",day)", "def get_filters():\n city = None\n month = None\n day = None\n while day == None:\n # TO DO: get user input f...
[ "0.6670955", "0.65355206", "0.64598334", "0.6373697", "0.63487226", "0.6310236", "0.6287051", "0.6259993", "0.62314963", "0.62125754", "0.62053525", "0.61813915", "0.6171331", "0.6169096", "0.61588687", "0.6158631", "0.6153347", "0.6144922", "0.6131542", "0.6105515", "0.61029...
0.0
-1
Loads data for the specified city and filters by month and day if applicable.
def load_data(city, month='all', day='all'): df = pd.read_csv(CITY_DATA[city.lower()]).rename(columns={'Unnamed: 0': 'Trip Id'}) cols = df.columns df['Start Time'] = pd.to_datetime(df['Start Time']) df['Month'] = df['Start Time'].dt.month df['Day of Week'] = df['Start Time'].dt.dayofweek df['St...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_data(city, month, day):\n df = pd.read_csv(CITY_DATA [city])\n \n # convert the Start Time column to datetime\n df['Start Time'] = pd.to_datetime(df['Start Time'])\n \n # extract month and day of week from Start Time to create new columns\n df['month'] = df['Start Time'].dt.month\n ...
[ "0.81320685", "0.8108889", "0.8042514", "0.80090284", "0.80071104", "0.79991937", "0.7998333", "0.7988789", "0.797905", "0.79737365", "0.79610896", "0.7956163", "0.7947432", "0.79463065", "0.7908287", "0.7908229", "0.7904569", "0.7900715", "0.78930074", "0.7889219", "0.788254...
0.8045821
2
Displays statistics on the most frequent times of travel.
def time_stats(df): print('\nCalculating The Most Frequent Times of Travel...\n') start_time = time.time() # display the most common month aux = df[['Month','Start Time']].groupby('Month').count()['Start Time'] month_max = aux.idxmax() month_max_cnt = aux.max() print("Most common month was...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_stats(df):\n\n print('\\nDisplaying the statistics on the most frequent times of '\n 'travel...\\n')\n start_time = time.time()\n\n # display the most common month\n most_common_month = df['Month'].mode()[0]\n print('For the selected filter, the month with the most travels is: ' +\...
[ "0.8023522", "0.802221", "0.7914353", "0.7826378", "0.7821697", "0.78140223", "0.7765606", "0.7739828", "0.7735833", "0.7733764", "0.7686237", "0.76675326", "0.7651101", "0.7644171", "0.7639292", "0.7636152", "0.76248395", "0.76227194", "0.7611663", "0.7599656", "0.75825727",...
0.7194641
71
Displays statistics on the most popular stations and trip.
def station_stats(df): print('\nCalculating The Most Popular Stations and Trip...\n') start_time = time.time() # display most commonly used start station aux = df[['Start Station','Start Time']].groupby('Start Station').count()['Start Time'] station_max = aux.idxmax() station_max_cnt = aux.max...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def station_stats(df):\n\n print('\\nCalculating The Most Popular Stations and Trip...\\n')\n start_time = time.time()\n\n # display most commonly used start station\n print(popular_start_station(df))\n\n # display most commonly used end station\n print(popular_end_station(df))\n\n # display m...
[ "0.7815998", "0.7661799", "0.755378", "0.74918276", "0.74751854", "0.7446441", "0.7429881", "0.74239737", "0.7417978", "0.74006975", "0.73876286", "0.7385986", "0.7365314", "0.73597723", "0.7356932", "0.7355265", "0.7352331", "0.7351879", "0.73507756", "0.734247", "0.734072",...
0.0
-1
Displays statistics on the total and average trip duration.
def trip_duration_stats(df): print('\nCalculating Trip Duration...\n') start_time = time.time() # display total travel time val = df['Trip Duration'].sum()/3600 print("Total trip duration was {:.2f} hours".format(val)) # display mean travel time val = df['Trip Duration'].mean()/60 pri...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri...
[ "0.8144002", "0.8025936", "0.80051756", "0.7950414", "0.7938244", "0.7932019", "0.7927543", "0.79160506", "0.7915316", "0.79089457", "0.79064983", "0.7901538", "0.7892409", "0.7890379", "0.7887529", "0.78859615", "0.78849727", "0.7883412", "0.78750104", "0.7869431", "0.786734...
0.78604645
25
Displays statistics on bikeshare users.
def user_stats(df): print('\nCalculating User Stats...\n') start_time = time.time() # Display counts of user types aux = df[['User Type','Start Time']].groupby('User Type').count() aux = aux.reset_index().rename(columns={'Start Time': 'Count'}) print("User Type statistics:") print(aux.to_s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_stats(request):\r\n user_count = UserMgr.count()\r\n pending_activations = ActivationMgr.count()\r\n users_with_bookmarks = BmarkMgr.count(distinct_users=True)\r\n return _api_response(request, {\r\n 'count': user_count,\r\n 'activations': pending_activations,\r\n 'with_bo...
[ "0.73559105", "0.73306274", "0.7287611", "0.72494894", "0.72382116", "0.71733415", "0.7168679", "0.7129041", "0.7076894", "0.7071431", "0.70602304", "0.7056935", "0.70490867", "0.7045232", "0.703642", "0.70238316", "0.7022488", "0.7022265", "0.7012312", "0.70086145", "0.69945...
0.0
-1
Displays raw data (trips sample).
def raw_data(df): print('\nDisplaying individual trip sample...\n') start_time = time.time() cnt = 0 rows = 5 while True: if cnt+rows < df.shape[0]: aux = df.iloc[cnt:cnt+rows] print("\n" + aux.to_string(index=False)) cnt += rows answer = inp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_data():", "def print_raw_data(self):\n\n start_time = time.time()\n data_frame = load_data(self.selections)\n if self.raw_data_index < len(data_frame) - 1:\n if self.raw_data_index + 5 < len(data_frame) - 1:\n print(data_frame[self.raw_data_index : self.raw...
[ "0.7264192", "0.7046372", "0.6878045", "0.62923914", "0.6280577", "0.62716645", "0.61874425", "0.61363494", "0.6096002", "0.6080934", "0.60643417", "0.6063628", "0.60584444", "0.6051726", "0.6024864", "0.6017971", "0.60011894", "0.5963676", "0.595541", "0.5946533", "0.5927268...
0.62318677
6
Creates a new nest operator. The set of keys is initially empty. If the map or entries operator is invoked before any key functions are registered, the nest operator simply returns the input array.
def __init__(self): self._keys = [] self._sortKeys = []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tree():\n return defaultdict(tree)", "def auto_nest(func):\n def wrapper(tensors, *args, **kwargs):\n return tf.nest.map_structure(\n lambda x: func(x, *args, **kwargs), tensors)\n return wrapper", "def _tree():\n return collections.defaultdict(_tree)", "def __create_nested_structure(ne...
[ "0.50510037", "0.5038567", "0.4854392", "0.48375788", "0.47468472", "0.4714622", "0.4705582", "0.47014457", "0.46549824", "0.4628407", "0.46255538", "0.46242553", "0.45791712", "0.45502764", "0.4549578", "0.44959244", "0.4480521", "0.44716427", "0.44619203", "0.44552702", "0....
0.0
-1
Registers a new key function. The key function will be invoked for each element in the input array, and must return a string identifier that is used to assign the element to its group. As most often the key function is just a simple accessor, this fuction also accepts a noncallable, which will be converted into a funct...
def key(self, fn): if not callable(fn): fn = itemgetter(fn) self._keys.append(fn) self._sortKeys.append({}) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key(func):\n return func.__func__ if hasattr(func, \"__func__\") else func", "def key(func):\n return func.__func__ if hasattr(func, \"__func__\") else func", "def new_key(self, key_name=None):\r\n return self.key_class(self, key_name)", "def __call__(self, key):\n\n def wrapper(f...
[ "0.62338203", "0.62239367", "0.59718996", "0.5883624", "0.5770307", "0.57404315", "0.57356715", "0.57341254", "0.5666792", "0.5658345", "0.56313723", "0.5578466", "0.5519251", "0.5460523", "0.5439024", "0.54283136", "0.5402386", "0.53601855", "0.53601855", "0.5331967", "0.526...
0.6798151
0
Registers a new key function. The key function will be invoked for each element in the input array, and must return a string identifier that is used to assign the element to its group. As most often the key function is just a simple accessor, this fuction also accepts a noncallable, which will be converted into a funct...
def prop(self, fn): if not callable(fn): fn = attrgetter(fn) self._keys.append(fn) self._sortKeys.append({}) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key(self, fn):\n if not callable(fn):\n fn = itemgetter(fn)\n self._keys.append(fn)\n self._sortKeys.append({})\n return self", "def key(func):\n return func.__func__ if hasattr(func, \"__func__\") else func", "def key(func):\n return func.__func__ if hasatt...
[ "0.6682632", "0.6177009", "0.6167243", "0.59728664", "0.5880275", "0.5739148", "0.5736727", "0.57136136", "0.56967425", "0.56370705", "0.5616288", "0.55425495", "0.5540175", "0.5514391", "0.5452194", "0.54279727", "0.54111975", "0.53730154", "0.53730154", "0.53143835", "0.528...
0.0
-1
Specifies the order for the mostrecently specified key.
def sortKeys(self, cmp=None, key=None, reverse=False): self._sortKeys[-1] = dict(cmp=cmp, key=key, reverse=reverse) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _augment_order(self, stmt, key, reverse):\n sqlstmt = stmt + \" ORDER BY %s\" % key\n if reverse:\n sqlstmt += \" DESC\"\n else:\n sqlstmt += \" ASC\"\n return sqlstmt", "def add(self, key, value):\r\n newest = Item(key, value) # make new item instan...
[ "0.5636925", "0.5439744", "0.54154766", "0.53488845", "0.53439325", "0.53188175", "0.5313001", "0.5313001", "0.52856255", "0.52856255", "0.5253114", "0.52403337", "0.52403337", "0.52403337", "0.5195061", "0.5147803", "0.5137212", "0.51138586", "0.5104338", "0.50992334", "0.50...
0.5488794
1
Specifies the order for leaf values; applies to both maps and entries array.
def sortValues(self, cmp=None, key=None, reverse=False): self._sortValues = dict(cmp=cmp, key=key, reverse=reverse) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __order_dict__(self, tree_level_labels, level_entries):\n # | - __order_dict__\n order_dict = {} # <--------------------------------------\n\n level_cnt = 0\n for level in tree_level_labels:\n level_cnt += 1\n for prop in level_entries[level]:\n ...
[ "0.6510195", "0.6324931", "0.55555844", "0.55430245", "0.5464267", "0.5439327", "0.5316074", "0.5254075", "0.5250325", "0.52135754", "0.51128393", "0.51121473", "0.50785637", "0.5063107", "0.5053161", "0.50316817", "0.50295913", "0.5025321", "0.4987931", "0.4981204", "0.49711...
0.0
-1
Specifies a rollup function to be applied on each group of leaf elements. The return value of the rollup function will replace the array of leaf values in either the associative array returned by the map operator, or the values attribute of each entry returned by the entries operator.
def rollup(self, fn): self._rollup = fn return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rollup(self, name, keys, aggregators=None, callback=None) :\n\n class Wildcard(object) :\n def __repr__(self) :\n return '*'\n w = Wildcard()\n\n # get the records for this table\n #\n rows = [d.as_dict() for d in self]\n cols = [k.get_name() ...
[ "0.5321749", "0.5007049", "0.4889394", "0.4833893", "0.47824767", "0.47508833", "0.47499952", "0.4718424", "0.4704678", "0.4611858", "0.45925716", "0.45839456", "0.4580275", "0.45792785", "0.4532239", "0.45245072", "0.45216066", "0.44919682", "0.44884452", "0.44791734", "0.44...
0.5791968
0
Applies the nest operator to the specified array, returning an array of keyvalues entries. Each entry in the returned array corresponds to a distinct key value returned by the first key function. The entry value depends on the
def map(self, data, depth=0): if depth >= len(self._keys): if self._rollup: return self._rollup(data) if self._sortValues: return sorted(data, **self._sortValues) return data values = defaultdict(list) it = data.iteritems() if isinstance(data, dic...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flatten_array(nested, prefix=''):\n result = dict()\n for index in range(len(nested)):\n prefix_key = '__'.join([prefix, str(index)]) if len(prefix) else str(index)\n\n value = nested[index]\n if isinstance(value, (list, np.ndarray)):\n result.update(flatten_array(value, p...
[ "0.55010843", "0.50831336", "0.49393448", "0.4874722", "0.48669982", "0.4860756", "0.48441294", "0.48316175", "0.47842464", "0.47713405", "0.47101563", "0.46756792", "0.46725106", "0.46214616", "0.4618535", "0.4615551", "0.46035823", "0.4602771", "0.45968628", "0.4594586", "0...
0.0
-1
Applies the nest operator to the specified array, returning an associative array. Each Entry (a named tuple with the fields 'key' and 'values') in the returned associative array corresponds to a distinct keyvalue pair returned by the first keyfunction. The entry value depends on the number
def entries(self, data, depth=0): return self._entries(self.map(data))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flatten_array(nested, prefix=''):\n result = dict()\n for index in range(len(nested)):\n prefix_key = '__'.join([prefix, str(index)]) if len(prefix) else str(index)\n\n value = nested[index]\n if isinstance(value, (list, np.ndarray)):\n result.update(flatten_array(value, p...
[ "0.5737612", "0.52897036", "0.50291884", "0.49283966", "0.48699978", "0.47915348", "0.47293574", "0.47216898", "0.46458194", "0.4611427", "0.45985267", "0.45661286", "0.4551411", "0.4547691", "0.45448223", "0.45383206", "0.45177352", "0.4515706", "0.45081964", "0.45067057", "...
0.41658196
79
Create a new Team and add two new Learners with different atomic actions. These Learners are added to the Learner population, and the Team is added to both the Team and root Team populations.
def initializeTeam(self): # Create two new Learners with different atomic actions a1 = randint(0, Trainer.ATOMIC_ACTION_RANGE) a2 = randint(0, Trainer.ATOMIC_ACTION_RANGE) while a1 == a2: a2 = randint(0, Trainer.ATOMIC_ACTION_RANGE) l1 = Learner(action = a1) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_add_team_manager_to_team(self):\n pass", "def test_assign_managing_team(self):\n pass", "def post(self):\n req = team_req.parse_args(strict=True)\n curr_user = api.user.get_user()\n if curr_user[\"teacher\"]:\n raise PicoException(\"Teachers may not create...
[ "0.63931805", "0.62942845", "0.6094177", "0.6046148", "0.5987049", "0.5950534", "0.59209555", "0.59143233", "0.58799905", "0.58205515", "0.5810097", "0.57936954", "0.57741076", "0.57400084", "0.5725225", "0.5720262", "0.56885177", "0.5675747", "0.5647381", "0.5604889", "0.555...
0.7741807
0
Given a full Learner and Team population, where each Team points to two unique Learners, randomly add existing Learners to each Team until that Team reaches its full complement.
def fillTeamsInPopulation(self): for team in self.team_pop: while len(team.learners) < team.max_size: learners = [l for l in self.learner_pop if l not in team.learners] if len(learners) == 0: break else: learner ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initializeTeam(self):\n\n # Create two new Learners with different atomic actions\n a1 = randint(0, Trainer.ATOMIC_ACTION_RANGE)\n a2 = randint(0, Trainer.ATOMIC_ACTION_RANGE)\n while a1 == a2:\n a2 = randint(0, Trainer.ATOMIC_ACTION_RANGE)\n\n l1 = Learner(action ...
[ "0.6198892", "0.60099727", "0.5909377", "0.5602736", "0.5578461", "0.5570028", "0.55162257", "0.54663473", "0.54535234", "0.5446338", "0.5419894", "0.5384661", "0.53839433", "0.537948", "0.53772473", "0.53582704", "0.53372985", "0.53203225", "0.5301221", "0.5300238", "0.52959...
0.71697813
0
Create the initial complement of Teams and the Learner population.
def initialize(self): r_keep = int(Trainer.R_SIZE * Trainer.PERCENT_KEEP) for i in range(r_keep): self.initializeTeam() self.fillTeamsInPopulation() # Double check that things are working as expected and that we now # have PERCENT_KEEP * R_SIZE Teams and that these ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initializeTeam(self):\n\n # Create two new Learners with different atomic actions\n a1 = randint(0, Trainer.ATOMIC_ACTION_RANGE)\n a2 = randint(0, Trainer.ATOMIC_ACTION_RANGE)\n while a1 == a2:\n a2 = randint(0, Trainer.ATOMIC_ACTION_RANGE)\n\n l1 = Learner(action ...
[ "0.67016745", "0.6666432", "0.5825645", "0.55707854", "0.55236286", "0.5364244", "0.5268502", "0.52265084", "0.5218145", "0.51675844", "0.51194715", "0.5089335", "0.5085048", "0.50581676", "0.50530136", "0.5036355", "0.5020107", "0.50176114", "0.50176114", "0.50087804", "0.49...
0.5799388
3
Refill the root Team population up to R_SIZE root Teams. This is done as the first step of every iteration of evolution to ensure that we are always evaluating R_SIZE root Teams.
def generation(self): # Re-count and re-collect all root Teams from the main Team # population into self.agent_pop self.updateAgentPopulation() # Generate new root Teams as variations of other Teams while self.getNumRootTeams() < Trainer.R_SIZE: # Randomly select p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(self):\n r_keep = int(Trainer.R_SIZE * Trainer.PERCENT_KEEP)\n\n for i in range(r_keep):\n self.initializeTeam()\n self.fillTeamsInPopulation()\n\n # Double check that things are working as expected and that we now\n # have PERCENT_KEEP * R_SIZE Teams an...
[ "0.64052784", "0.63281214", "0.57870644", "0.57000005", "0.5607969", "0.5547907", "0.5515359", "0.544081", "0.54305696", "0.53787595", "0.53169703", "0.53117955", "0.5303638", "0.52940786", "0.5237861", "0.5228605", "0.5212393", "0.5164609", "0.5151552", "0.5115436", "0.51149...
0.7226053
0
During evolution, after evaluating all agents (ie. root teams), delete the PERCENT_KEEP worstperforming Teams.
def selection(self): # Sort root Teams from best to worst ranked_agents = sorted(self.agent_pop, key=lambda rt : rt.team.fitness, reverse=True) # Save trainer and top agent so far self.save() if self.AGENT_NAME == "": ranked_agents[0].save(Trainer.ENV_NAME) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def agent_cleanup(self):\n\n logging.info(\"Best score: %s\" % self.best_score_ever)\n\n if self.results_file:\n self.results_file.close()", "def _remove_experts(self):\n self.experts = [ex for ex in self.experts if np.mean(\n ex.weight) >= self.theta]", "def trim_dat...
[ "0.56317484", "0.5397232", "0.5374889", "0.5315391", "0.5296942", "0.5236859", "0.52119124", "0.5208702", "0.51444036", "0.5137969", "0.5063565", "0.5044934", "0.4994451", "0.49477217", "0.49460474", "0.4923171", "0.49114072", "0.4853876", "0.4834487", "0.48299766", "0.481175...
0.4908848
17
Evaluate an agent over some number of episodes in a given environment 'env'
def evaluateAgent(self, agent, env, num_episodes, num_frames): # Skip agents that have already been evaluated, up to MAX_EVAL_SKIPS times if agent.team.fitness is not None and Trainer.DO_FAST_TRACK: if agent.team.num_skips < Trainer.MAX_EVAL_SKIPS: agent.team.num_skips += 1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eval_against_bot(env, q_agent, t_agent, num_episodes):\n score = 0\n for _ in range(num_episodes):\n time_step = env.reset()\n q_agent_output = q_agent.step(time_step, is_evaluation=True)\n t_agent_output = t_agent.step(time_step, is_evaluation=True)\n time_step = env.step([q_...
[ "0.73567104", "0.73567104", "0.72522426", "0.72513074", "0.72093165", "0.7190529", "0.718549", "0.71360284", "0.7111438", "0.7026913", "0.7013799", "0.69604534", "0.6952704", "0.6939247", "0.69145966", "0.690422", "0.6902681", "0.6878677", "0.6865183", "0.6861071", "0.6852929...
0.72531104
2
Perform the TPG evolution algorithm.
def evolve(self, env, num_generations, num_episodes, num_frames): for gen in range(num_generations): if Trainer.VERBOSE: print("Generation:", gen) # Generate new root Teams self.generation() # Evaluate current agents self.evaluation(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evolve(self, evolutions_to_run, evolution_count = 0):\n\n\n for i in range(evolutions_to_run):\n self.population = self.mating.mate(self.population)\n self.population = mutate.mutate(self.population)\n\n self.population = self.computeFitness.compute(self.population)\n ...
[ "0.6286169", "0.6101547", "0.606618", "0.6046805", "0.59923446", "0.5940404", "0.5926717", "0.5825156", "0.5811594", "0.57976264", "0.57265425", "0.5668708", "0.56585896", "0.5590751", "0.55892897", "0.5576272", "0.5574918", "0.55736893", "0.5543055", "0.55289966", "0.5516357...
0.5110463
73
Perform variation operators on the Team level.
def mutateTeam(self, team): self.removeLearners(team) self.addLearners(team) self.mutateLearners(team)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_team_strength(self):\n pass", "def ImprovedScore(tgtName, yourName, teamModels, featureImprove, teamTgtPipe, teamYourPipe, Imp = 0.1):\n\n ## Put featureImprove into target model - need to reverse _op and non _op\n coef = teamModels[tgtName]\n # Get stats of Team A's win and lose mat...
[ "0.5885755", "0.58623254", "0.5784955", "0.571331", "0.5696523", "0.55756694", "0.55301684", "0.5520191", "0.54968196", "0.545426", "0.54406863", "0.5344885", "0.53093714", "0.52367246", "0.52123815", "0.5171796", "0.51657", "0.5156609", "0.5141747", "0.51127", "0.5106896", ...
0.48860818
58
Delete all Learners that are no longer owned by any Team.
def cleanOrphanedLearners(self): # Before deleting Learners, ensure that if any Learners that are about to be # deleted point to a Team as their action, then that Team's count of # referincing Learners is decremented. for learner in self.learner_pop: if learner.getNumReferen...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_all_teachers(connection):\r\n with connection:\r\n return connection.execute(DELETE_ALL_TEACHERS)", "def delete_teams_all(self, team_name):\n self.execute(TABELLE['teams']['delete']['all'])", "def _delete_roles(self):\n for role in self.roles:\n role.delete()", "...
[ "0.6313414", "0.6120818", "0.61091095", "0.60356534", "0.5935509", "0.5842929", "0.5828907", "0.5745722", "0.5733355", "0.5720132", "0.5718106", "0.57144076", "0.56988364", "0.56943846", "0.5681858", "0.567302", "0.5666653", "0.5639008", "0.56309897", "0.55954045", "0.5594834...
0.71644795
0
Given the OpenAI Gym pendulum state [cos(theta), sin(theta), \dot{theta}], return [theta, \dot{theta}].
def get_state(s): return np.array([math.atan2(s[1], s[0]), s[2]])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pendulum(pos):\n\n def x_dot(x, y):\n return y\n\n def y_dot(x, y):\n return -np.sin(x)\n\n return np.array([x_dot(pos[0], pos[1]), y_dot(pos[0], pos[1])])", "def dtheta(state, t, I, p, E, gamma):\n theta, omega = state[0], state[1]\n dtheta =omega\n domega = -(gamma / I )* om...
[ "0.7569696", "0.69571704", "0.68560404", "0.6705998", "0.6366515", "0.6327622", "0.6223006", "0.62030417", "0.6044491", "0.60441226", "0.59695387", "0.5966636", "0.5925617", "0.5915176", "0.58980143", "0.58724684", "0.5863618", "0.583199", "0.583199", "0.5829571", "0.5824251"...
0.6069792
8
We use heapq class to implement Heaps in Python. By default Min Heap is implemented by this class. But we multiply each value by 1 so that we can use it as MaxHeap.
def addNum(self, num: int) -> None: small, large = self.heaps # push to small first by default heapq.heappush(large, -heapq.heappushpop(small, -num)) # keep size even (let len(small) >= len(large)) if len(large) > len(small): val = heapq.heappop(larg...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.max_heap = [] # to contain left smaller half, or + 1\n self.min_heap = [] # to contain right bigger half", "def __init__(self):\n # max_heap stores smaller half\n # min_heap stores larger half\n self.heaps = ([], [])", "def min_heap(self): \n \n ...
[ "0.76983464", "0.7662596", "0.74752456", "0.7363196", "0.7337437", "0.7319882", "0.72922516", "0.72666025", "0.7229037", "0.7225333", "0.72153676", "0.7207476", "0.7174666", "0.71282834", "0.704995", "0.70068634", "0.7000654", "0.6952775", "0.68923765", "0.6872462", "0.684775...
0.0
-1
Main script to run the command doc
def run(self) -> int: columns_sql = [] model = self._flags.model schema = self._dbt_profile.profile.get("target_schema", "") dbt_credentials = self._dbt_profile.profile connector = DB_CONNECTORS.get(dbt_credentials.get("type", "")) if not connector: raise No...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def libdoc_cli(arguments):\n LibDoc().execute_cli(arguments)", "def run(self):\n cmds = (self.clean_docs_cmd, self.html_docs_cmd, self.view_docs_cmd)\n self.call_in_sequence(cmds)", "def main():\n # We know that qidoc build will set the correct cwd\n qibuild_dir = \"..\"\n qibuild_dir...
[ "0.769044", "0.7378854", "0.72934943", "0.72900057", "0.7280042", "0.70528066", "0.7028129", "0.70109427", "0.70109427", "0.70109427", "0.70109427", "0.70109427", "0.70109427", "0.70109427", "0.70109427", "0.70109427", "0.70109427", "0.70109427", "0.70109427", "0.70109427", "...
0.0
-1
Updates the model description from a schema.yaml.
def update_model_description( self, content: Dict[str, Any], model_name: str, is_already_documented: bool = False ) -> Dict[str, Any]: message = f"Do you want to write a description for {model_name}" if is_already_documented: message = f"Do you want to change the model descriptio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_model(\n self, content: Dict[str, Any], model_name: str, columns_on_db: Sequence[str]\n ) -> Dict[str, Any]:\n logger.info(f\"The model '{model_name}' already exists, updating its documentation.\")\n for model in content.get(\"models\", []):\n if model[\"name\"] == mod...
[ "0.6301844", "0.5955802", "0.58623356", "0.58260643", "0.5749849", "0.56432885", "0.5605579", "0.55699617", "0.5438667", "0.5400471", "0.5385811", "0.53735393", "0.53630406", "0.53451717", "0.5329007", "0.5327524", "0.52972335", "0.5264293", "0.5264293", "0.5262192", "0.52173...
0.66931194
0
Move keys name and description to the beginning of the dictionary.
def move_name_and_description_to_first_position(self, model: Dict[str, Any]): # DEPRECATION: Drop ordered dict when dropping python 3.6 support ordered_dict = OrderedDict(model) if ordered_dict.get("description"): ordered_dict.move_to_end("description", last=False) ordered_di...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_prepend_key(self):\n self.prepend_key -= 1", "def harmonize_keys(self):\n self._data.key_regex_replacements = _key_regex_replacements\n self._data.key_replacements = _key_replacements", "def __parse_dict(self) -> OrderedDict:\r\n self.idx += 1\r\n d = OrderedDict(...
[ "0.5855813", "0.58174276", "0.5344455", "0.5334281", "0.5323044", "0.53075933", "0.53034145", "0.52598774", "0.5258003", "0.52408934", "0.52373326", "0.5168691", "0.5147976", "0.5109821", "0.50820005", "0.50367594", "0.5033817", "0.50227356", "0.5005109", "0.50036335", "0.498...
0.67776966
0
Gets the primary key info from a dbt model's config block.
def get_primary_key_from_sql(self, sql_file_path: Path) -> Optional[str]: sql_content = self.read_file(sql_file_path) unique_key = re.search(r"unique_key[^\S]*=[^\S]*\'([a-z_]+)\'", sql_content) if unique_key: return unique_key.group(1) return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def id(self):\n return self.config['key']", "def id(self):\n return self.config.get('key').lower()", "def get_primary_key(cls) -> str:\n return inspect(cls).primary_key[0].name", "def get_key_id(self):", "def get_primary_id(self):", "def pk(entity) -> str:\n for field in entit...
[ "0.675796", "0.6688599", "0.6348418", "0.63330615", "0.6260536", "0.6244676", "0.6244162", "0.61983496", "0.6189352", "0.60111696", "0.5995902", "0.5995902", "0.59907687", "0.5953107", "0.59288514", "0.591364", "0.58904403", "0.587706", "0.5850178", "0.5824004", "0.57448316",...
0.0
-1
Adds the primary key tests (unique, not_null) to the primary key column.
def add_primary_key_tests( self, schema_content: Dict[str, Any], model_name: str, ) -> None: model_file_path = self.get_file_path_from_sql_model(model_name=model_name) if not model_file_path: return primary_key_column = self.get_primary_key_from_sql(model...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_primary_key(self):\n assert self.tbl.primary_key == 'id'", "def test_code_add_primary_key(self):\n sql = \"\"\"\n CREATE TABLE public.address_no_primary_key\n (\n code character varying(10),\n address character varying(255),\n ...
[ "0.74589247", "0.66175616", "0.6569066", "0.64053077", "0.63456315", "0.63337296", "0.6306686", "0.62847334", "0.6270942", "0.6083501", "0.6062621", "0.60461", "0.60365766", "0.6021916", "0.59867954", "0.5968053", "0.59389657", "0.5910877", "0.5889046", "0.5881331", "0.587261...
0.70331806
1
Method to delete the failing tests from the schema.yml.
def delete_failed_tests_from_schema( self, path_file: Path, model_name: str, tests_to_delete: Dict[str, List[str]] ): content = open_yaml( path_file, preserve_yaml_order=self._sugar_config.config.get("preserve_yaml_order", False), ) for model in content["model...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tearDown(self):\n with app.app_context():\n db = app.db.get_db()\n cur = db.cursor()\n with app.open_resource('sql/drop_tests.sql', mode='r') as f:\n cur.execute(f.read())\n db.commit()\n cur.close()\n db.close()", "def t...
[ "0.7157708", "0.6840837", "0.6840837", "0.6744383", "0.67398924", "0.6644065", "0.663067", "0.6602651", "0.66019326", "0.65678084", "0.65678084", "0.65678084", "0.65678084", "0.6532619", "0.65185887", "0.6497793", "0.6494446", "0.6491216", "0.64835113", "0.648288", "0.6480997...
0.7389425
0
Method to document the columns from a model. Will ask the user which columns they want to document and collect the new definition.
def document_columns( self, columns: Dict[str, str], question_type: str = "undocumented_columns" ) -> None: allowed_question_types_map = { "undocumented_columns": "undocumented columns", "documented_columns": "documented columns", } assert ( questi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_model(\n self, content: Dict[str, Any], model_name: str, columns_on_db: Sequence[str]\n ) -> Dict[str, Any]:\n logger.info(f\"The model '{model_name}' already exists, updating its documentation.\")\n for model in content.get(\"models\", []):\n if model[\"name\"] == mod...
[ "0.60908073", "0.55415165", "0.5372188", "0.5359274", "0.5354231", "0.5340466", "0.5325151", "0.5293703", "0.52432853", "0.5163885", "0.5160039", "0.5150177", "0.5130315", "0.5116568", "0.51087177", "0.509843", "0.5091603", "0.5084476", "0.5083437", "0.5062949", "0.50574535",...
0.6973812
0
Method to update the columns from a model in a schema.yaml content.
def update_model( self, content: Dict[str, Any], model_name: str, columns_on_db: Sequence[str] ) -> Dict[str, Any]: logger.info(f"The model '{model_name}' already exists, updating its documentation.") for model in content.get("models", []): if model["name"] == model_name: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def upgradeSchema(self) -> None:", "def _patch_schema(self):\n fields = get_json()['data']['attributes'].keys()\n return make_entity_schema(\n self.SCHEMA, self.RESOURCE_NAME,\n make_data_schema(\n self.SCHEMA, id_required=True,\n only=field...
[ "0.6048077", "0.57747126", "0.5664433", "0.5589418", "0.5571424", "0.5421451", "0.5394761", "0.53772175", "0.53585315", "0.53123355", "0.52927804", "0.5254707", "0.5240652", "0.52377737", "0.52357596", "0.5179389", "0.51512194", "0.51078886", "0.51063067", "0.51058704", "0.51...
0.74676514
0
Method to create a new model in a schema.yaml content.
def create_new_model( self, content: Optional[Dict[str, Any]], model_name: str, columns_sql: Sequence[str] ) -> Dict[str, Any]: logger.info(f"The model '{model_name}' has not been documented yet. Creating a new entry.") columns = [] for column_sql in columns_sql: descript...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_model(self, ApiId: str, Name: str, Schema: str, ContentType: str = None, Description: str = None) -> Dict:\n pass", "def create_model(self):\n pass", "def create_model(self):\n pass", "def create_models( self ):", "def test_create_model(self):\n model = ControlledSche...
[ "0.75608915", "0.6931102", "0.6931102", "0.6764485", "0.673761", "0.6483227", "0.64785224", "0.6357424", "0.6350314", "0.63297427", "0.6329468", "0.6134453", "0.61336684", "0.6127344", "0.6127344", "0.60928607", "0.60823125", "0.60697037", "0.6068816", "0.6059946", "0.6040354...
0.6983313
1
Method to update/create a model entry in the schema.yml.
def create_or_update_model_entry( self, is_already_documented: bool, content: Optional[Dict[str, Any]], model_name: str, columns_sql: Sequence[str], ) -> Dict[str, Any]: if is_already_documented and content: content = self.update_model(content, model_name,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self, model: CreationType) -> CreationType:\n url = self._get_path(model.uid)\n updated = self.session.put_resource(url, model.dump())\n data = updated[self._individual_key] if self._individual_key else updated\n self._check_experimental(data)\n return self.build(data)...
[ "0.66110295", "0.65099454", "0.6503122", "0.6483552", "0.6447268", "0.63319486", "0.60912466", "0.6037311", "0.5939962", "0.59308195", "0.5920232", "0.5892795", "0.588365", "0.58739525", "0.58583957", "0.5846313", "0.58430684", "0.58265835", "0.5815904", "0.5811055", "0.58067...
0.6266865
6
Return a list of the lengths of each component
def connected_component_lengths(self): return [len(x) for x in nx.connected_components(self.return_undirected())]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lengths(self):\n lengths = []\n last = self._coordinates[-1]\n for c in self._coordinates:\n lengths.append(((c[0]-last[0])**2 + (c[1]-last[1])**2) ** 0.5)\n last = c\n return sorted(lengths)", "def lengths(self):\n return tuple(self.__lengths)", "de...
[ "0.78101194", "0.7739306", "0.7471985", "0.73547244", "0.72451776", "0.72150517", "0.720691", "0.70220983", "0.69397414", "0.6916224", "0.6876782", "0.6876782", "0.6876782", "0.68567157", "0.68480396", "0.68066955", "0.67870516", "0.6754018", "0.67148066", "0.669046", "0.6612...
0.7256557
4
Return a dictionary with the component length and number of such sized components
def connected_component_statistics(self, printStats=False): lengths = self.connected_component_lengths() lengthDict = dict(collections.Counter(lengths)) if printStats: orderedLengthDict = collections.OrderedDict(sorted(lengthDict.items())) numberOfGroups = nx.number_conn...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sizes(self) -> dict:\n raise NotImplementedError", "def size(self):\n cols = self.max_col + 1 - self.min_col\n rows = self.max_row + 1 - self.min_row\n return {'columns':cols, 'rows':rows}", "def component_size(self) -> int:\n return self._component_size", "def size(sel...
[ "0.67360574", "0.6725783", "0.6701124", "0.6548634", "0.6537382", "0.6504442", "0.6497762", "0.6469607", "0.6455232", "0.64512724", "0.6447988", "0.639165", "0.63511133", "0.6291684", "0.6270531", "0.6249778", "0.6229823", "0.62279826", "0.62087417", "0.6208018", "0.61990285"...
0.58657247
59
Return a list of connected component of a given size
def connected_components_with_size(self, size): components = [x for x in nx.connected_component_subgraphs(self.return_undirected()) if x.number_of_nodes() == size] for graph in components: SynonymNetwork.convert_to_special(graph) return components
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connected_component_nodes_with_size(self, size, showRending=False, printResults=False):\n\n graphsOfSize = self.connected_components_with_size(size)\n if showRending:\n ans = [{node:graph.rendering_of_graph_node(node) for node in super(SynonymNetwork, graph).nodes()} for graph in graph...
[ "0.7175926", "0.6962229", "0.68868196", "0.6776708", "0.6681602", "0.6661775", "0.664788", "0.6627815", "0.6584589", "0.6561159", "0.65440905", "0.64664924", "0.63913494", "0.6352398", "0.6340285", "0.62921864", "0.62775284", "0.6261488", "0.62403965", "0.62268996", "0.618964...
0.83368003
0
Return a list of infoboxes of a node
def infoboxes_of_graph_node(self, nodeName): return self.node[nodeName].keys()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def infoboxes_of_graph(self):\n infoboxes = []\n for nodeName in super(SynonymNetwork, self).nodes():\n infoboxes = infoboxes + self.infoboxes_of_graph_node(nodeName)\n return list(set(infoboxes))", "def _available_boxes(self, graph):\n return sorted([node.name for node in ...
[ "0.6946358", "0.6361805", "0.6139065", "0.59413755", "0.5941131", "0.58889467", "0.5884175", "0.5850629", "0.58499706", "0.5776936", "0.573916", "0.5717519", "0.5703713", "0.5701958", "0.5700756", "0.56752574", "0.56741536", "0.5662098", "0.5639799", "0.562524", "0.5618712", ...
0.6962848
0
Return a (nonredunant) list of a graph's infoboxes
def infoboxes_of_graph(self): infoboxes = [] for nodeName in super(SynonymNetwork, self).nodes(): infoboxes = infoboxes + self.infoboxes_of_graph_node(nodeName) return list(set(infoboxes))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def infoboxes_of_graph_node(self, nodeName):\n return self.node[nodeName].keys()", "def _available_boxes(self, graph):\n return sorted([node.name for node in graph.available_nodes()\n if not isinstance(node.meta, Ibox)])", "def infolist(self):\r\n return list(self.info...
[ "0.70919293", "0.65511703", "0.6170751", "0.56518734", "0.5469806", "0.5438119", "0.5431412", "0.5327349", "0.52892977", "0.5260679", "0.5251475", "0.5249176", "0.52470684", "0.5231178", "0.5216276", "0.51862216", "0.5169174", "0.5155935", "0.5152305", "0.5131187", "0.5118866...
0.7810729
0
Return either 'unrend', 'rend', or 'mixed' about a node
def rendering_of_graph_node(self, nodeName): rendingList = [item for sublist in self.node[nodeName].values() for item in sublist] # due to flattening [['unrend'],['rend','unrend']] etc. if all(items == 'unrend' for items in rendingList): return 'unrend' elif all(items == 'rend' for items in rend...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _getNodeType(node): # {{{\n if node.nodeType == node.ELEMENT_NODE : return \"ELEMENT_NODE\"\n elif node.nodeType == node.ATTRIBUTE_NODE : return \"ATTRIBUTE_NODE\"\n elif node.nodeType == node.TEXT_NODE : return \"TEXT_NODE\"\n elif...
[ "0.59330434", "0.57472795", "0.55685306", "0.55460465", "0.5446833", "0.52605206", "0.5232469", "0.5225675", "0.5222645", "0.5222645", "0.5211315", "0.5193215", "0.5136534", "0.5125108", "0.50817764", "0.5080642", "0.5071563", "0.5054469", "0.5050788", "0.5024682", "0.5009587...
0.7448862
0
Return a list of nodes for each connected component of a given size, optionally showing the rendering state ('rend', 'unrend', or 'mixed'), and optionally priting the results in a readable manner
def connected_component_nodes_with_size(self, size, showRending=False, printResults=False): graphsOfSize = self.connected_components_with_size(size) if showRending: ans = [{node:graph.rendering_of_graph_node(node) for node in super(SynonymNetwork, graph).nodes()} for graph in graphsOfSize] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connected_components_with_size(self, size):\n components = [x for x in nx.connected_component_subgraphs(self.return_undirected()) if x.number_of_nodes() == size]\n for graph in components:\n SynonymNetwork.convert_to_special(graph)\n\n return components", "def createNodes(self...
[ "0.7411901", "0.5986464", "0.5829044", "0.57453585", "0.56704384", "0.5544666", "0.5477517", "0.54514194", "0.5429409", "0.5378249", "0.5338306", "0.5332242", "0.5323817", "0.5284013", "0.52632344", "0.5228449", "0.52277344", "0.5223392", "0.51854527", "0.5174748", "0.5167538...
0.838628
0
Simulate rolling the DICE exactly NUM_ROLLS > 0 times. Return the sum of the outcomes unless any of the outcomes is 1. In that case, return 1.
def roll_dice(num_rolls, dice=six_sided): # These assert statements ensure that num_rolls is a positive integer. assert type(num_rolls) == int, 'num_rolls must be an integer.' assert num_rolls > 0, 'Must roll at least once.' # BEGIN PROBLEM 1 "*** YOUR CODE HERE ***" count, return_sum = 0, 0 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def simple_roll(dice):\n return roll(dice).total", "def roll(self):\n rolls = []\n if self.dice_array is not None:\n for dice in self.dice_array:\n rolls.append(np.random.randint(1, dice+1))\n else:\n for _ in range(0,self.number):\n rol...
[ "0.722231", "0.721332", "0.6934436", "0.6907222", "0.6787352", "0.6770178", "0.6726645", "0.66901255", "0.6653811", "0.6575561", "0.6574739", "0.6486671", "0.64543676", "0.64318657", "0.64160246", "0.64070636", "0.63740844", "0.6315325", "0.63017744", "0.62919956", "0.628643"...
0.67655975
6
Return the points scored from rolling 0 dice (Free Bacon).
def free_bacon(score): assert score < 100, 'The game should be over.' # BEGIN PROBLEM 2 "*** YOUR CODE HERE ***" return_value = 2 * (score//10) - (score%10) if return_value > 1: return return_value return 1 # END PROBLEM 2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_points(self):\n self.round_points = 0\n for die in self.dice:\n if die == 1:\n self.round_points += 100\n elif die == 5:\n self.round_points += 50\n return self.round_points", "def chance_points(dice_list):\n return sum(dice_list...
[ "0.71107715", "0.7004689", "0.68548566", "0.66713774", "0.6629163", "0.66016495", "0.6457354", "0.6445631", "0.64247847", "0.62659353", "0.62634397", "0.6239456", "0.621854", "0.6187291", "0.61325866", "0.609865", "0.60897076", "0.6088984", "0.60556155", "0.60112435", "0.5987...
0.0
-1
Simulate a turn rolling NUM_ROLLS dice, which may be 0 (Free Bacon). Return the points scored for the turn by the current player.
def take_turn(num_rolls, opponent_score, dice=six_sided): # Leave these assert statements here; they help check for errors. assert type(num_rolls) == int, 'num_rolls must be an integer.' assert num_rolls >= 0, 'Cannot roll a negative number of dice in take_turn.' assert num_rolls <= 10, 'Cannot roll mor...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def roll_the_dices(num_of_iterations: int) -> None:\n # initial variables\n player_wins: int = 0\n theoretical_win_chance: float = round(15/36, 4)\n\n # main loop\n for _ in range(num_of_iterations):\n croupier_roll = random.randint(1, 6)\n player_roll = random.randint(1, 6)\n i...
[ "0.7492326", "0.7283249", "0.72142756", "0.7099693", "0.70457476", "0.7032021", "0.70317835", "0.70165855", "0.7005138", "0.6891632", "0.6885169", "0.68767", "0.6866846", "0.6863758", "0.68346596", "0.6831231", "0.6797727", "0.6764949", "0.671695", "0.6702425", "0.66889226", ...
0.6527212
50
Return whether the current player's score has the same absolute difference between its last two digits as the opponent's score.
def is_swap(player_score, opponent_score): # BEGIN PROBLEM 4 "*** YOUR CODE HERE ***" player_diff = abs(((player_score // 10)%10) - (player_score % 10)) opponent_diff = abs(((opponent_score // 10)%10) - (opponent_score % 10)) if player_diff == opponent_diff: return True return False ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_for_end_of_game(self):\n return self.player_1.score + self.player_2.score >= self.number_of_cells", "def check_score(self):\r\n # If player reaches the exit before time expires\r\n final_score = int((5 - self._maze.items_remaining())*(self._time)*(100))\r\n score = (final_sc...
[ "0.64410603", "0.6398884", "0.61772853", "0.6137578", "0.6104868", "0.5995031", "0.5957221", "0.59311676", "0.5911049", "0.5877488", "0.5869364", "0.5831406", "0.5827793", "0.5821174", "0.5811221", "0.5742785", "0.573965", "0.5735727", "0.5733894", "0.57310593", "0.5688824", ...
0.6652104
0
Return the other player, for a player PLAYER numbered 0 or 1. >>> other(0) 1 >>> other(1) 0
def other(player): return 1 - player
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def otherPlayer(cls, player):\n return 0 if player == 1 else 1", "def other_player(cls, player):\n return 0 if player == 1 else 1", "def other_player(self, player):\n if player == self.__opponent:\n return self.__pid\n else:\n return self.__opponent", "def __...
[ "0.81847143", "0.81327176", "0.79256344", "0.7875795", "0.7709813", "0.7093842", "0.68455774", "0.6804346", "0.66201985", "0.66201985", "0.6579255", "0.6476013", "0.64561236", "0.64236355", "0.6390737", "0.63760537", "0.6363144", "0.6363144", "0.6335515", "0.62314063", "0.619...
0.780577
5
Announce nothing (see Phase 2).
def silence(score0, score1): return silence
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def announceGenerate(self):", "def acknowledged(self):\n ...", "def nothing():\n pass", "def announce(self):\n self.notify(self.newAgent)\n if not self.agent.is_someone_subscribed():\n self.fail(cause=\"Noone Interested\")", "def nothing(self, **kwargs):\n pass", ...
[ "0.64833313", "0.6462538", "0.6427069", "0.6208884", "0.6080106", "0.60444295", "0.60401314", "0.5978425", "0.59485215", "0.59143573", "0.5901542", "0.58910334", "0.5884047", "0.5867043", "0.58350474", "0.5829268", "0.57348514", "0.5711469", "0.5711469", "0.569965", "0.569663...
0.0
-1
Simulate a game and return the final scores of both players, with Player 0's score first, and Player 1's score second. A strategy is a function that takes two total scores as arguments (the current player's score, and the opponent's score), and returns a number of dice that the current player will roll this turn.
def play(strategy0, strategy1, score0=0, score1=0, dice=six_sided, goal=GOAL_SCORE, say=silence): player = 0 # Which player is about to take a turn, 0 (first) or 1 (second) # BEGIN PROBLEM 5 n = 0 #turn number change_turn = 0 #0 - change turn, 1 - extra turn, 2 - just gave extra turn and canno...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play(strategy0, strategy1, score0=0, score1=0, goal=GOAL_SCORE):\n player = 0 # Which player is about to take a turn, 0 (first) or 1 (second)\n dice_swapped = False # Whether 4-sided dice have been swapped for 6-sided\n my_score = score0\n opponent_score = score1\n while(score0<goal and score1...
[ "0.8078709", "0.77226627", "0.7643338", "0.7511744", "0.72544575", "0.72544575", "0.72544575", "0.69056386", "0.6778778", "0.67451346", "0.6727206", "0.6683956", "0.6642889", "0.65882045", "0.6545798", "0.6520198", "0.64840305", "0.64594907", "0.6428396", "0.64271224", "0.642...
0.7057277
7
A commentary function that announces the score for each player.
def say_scores(score0, score1): print("Player 0 now has", score0, "and Player 1 now has", score1) return say_scores
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_score():\n pass", "def _update_score(self) -> None:\n\n # setting new score by iterating over players\n self.score_play[self.n_play_turns, ] = [\n self._score_table[(\n self.contract.level,\n self.contract.suit,\n self.tricks...
[ "0.6046844", "0.5984142", "0.58788544", "0.57748145", "0.57382643", "0.57231647", "0.5692457", "0.5646813", "0.5645962", "0.5610773", "0.56061566", "0.5576601", "0.5571611", "0.5549147", "0.54914784", "0.54739916", "0.542415", "0.54227626", "0.541028", "0.53925556", "0.539219...
0.567084
7
Return a commentary function that announces lead changes. >>> f0 = announce_lead_changes() >>> f1 = f0(5, 0) Player 0 takes the lead by 5 >>> f2 = f1(5, 12) Player 1 takes the lead by 7 >>> f3 = f2(8, 12) >>> f4 = f3(8, 13) >>> f5 = f4(15, 13) Player 0 takes the lead by 2
def announce_lead_changes(previous_leader=None): def say(score0, score1): if score0 > score1: leader = 0 elif score1 > score0: leader = 1 else: leader = None if leader != None and leader != previous_leader: print('Player', leader, 'take...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_increment_function(delta):\n return lambda number: number + delta", "def updates(f):\n f.updates = True\n return f", "def announce_highest(who, previous_high=0, previous_score=0):\n assert who == 0 or who == 1, 'The who argument should indicate a player.'\n # BEGIN PROBLEM 7\n \"...
[ "0.52705693", "0.4956819", "0.48748475", "0.48450497", "0.47327447", "0.47263965", "0.4567901", "0.45541704", "0.45343226", "0.45111257", "0.4508821", "0.4503597", "0.44995", "0.4498226", "0.4497035", "0.44950983", "0.44797027", "0.44740486", "0.44602418", "0.44587052", "0.44...
0.75322604
0
Return a commentary function that says what f says, then what g says. >>> h0 = both(say_scores, announce_lead_changes()) >>> h1 = h0(10, 0) Player 0 now has 10 and Player 1 now has 0 Player 0 takes the lead by 10 >>> h2 = h1(10, 6) Player 0 now has 10 and Player 1 now has 6 >>> h3 = h2(6, 18) Player 0 gets 8 points, th...
def both(f, g): def say(score0, score1): return both(f(score0, score1), g(score0, score1)) return say
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def announce_lead_changes(previous_leader=None):\n def say(score0, score1):\n if score0 > score1:\n leader = 0\n elif score1 > score0:\n leader = 1\n else:\n leader = None\n if leader != None and leader != previous_leader:\n print('Player',...
[ "0.72504", "0.6531482", "0.58339536", "0.58319485", "0.57939136", "0.570603", "0.5563739", "0.5320002", "0.53060275", "0.53017294", "0.5292971", "0.5284072", "0.52297515", "0.5229289", "0.51723313", "0.51709175", "0.51519513", "0.5145487", "0.51122797", "0.5094572", "0.508087...
0.644719
2
Return a commentary function that announces when WHO's score increases by more than ever before in the game. >>> f0 = announce_highest(1) Only announce Player 1 score gains >>> f1 = f0(11, 0) >>> f2 = f1(11, 9) 9 point(s)! That's the biggest gain yet for Player 1 >>> f3 = f2(20, 9) >>> f4 = f3(12, 20) Player 1 gets 3 p...
def announce_highest(who, previous_high=0, previous_score=0): assert who == 0 or who == 1, 'The who argument should indicate a player.' # BEGIN PROBLEM 7 "*** YOUR CODE HERE ***" def highest_commentary(score0, score1): current_score = -1 if who == 0: current_score = score0 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def announce_highest(who, previous_high=0, previous_score=0):\n assert who == 0 or who == 1, 'The who argument should indicate a player.'\n if who ==0 :\n if previous_score> previous_high:\n previous_high=previous_score\n if previous_score>1:\n print(previous_score...
[ "0.7569457", "0.5807958", "0.5743568", "0.56182736", "0.54227114", "0.54214245", "0.5420976", "0.5420976", "0.54136336", "0.54079795", "0.5385615", "0.5337723", "0.53179383", "0.5317137", "0.5281766", "0.5249433", "0.5247084", "0.51886827", "0.5187498", "0.51824766", "0.51737...
0.7925943
0
Return a strategy that always rolls N dice. A strategy is a function that takes two total scores as arguments (the current player's score, and the opponent's score), and returns a number of dice that the current player will roll this turn. >>> strategy = always_roll(5) >>> strategy(0, 0) 5 >>> strategy(99, 99) 5
def always_roll(n): def strategy(score, opponent_score): return n return strategy
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def always_roll(n):\r\n def strategy(score, opponent_score):\r\n return n\r\n return strategy", "def always_roll(n):\r\n def strategy(score, opponent_score):\r\n return n\r\n return strategy", "def roll_dice(self):\n self.roll = (random.randint(1,6), random.randint(1,6))\n ...
[ "0.7990645", "0.7990645", "0.6305908", "0.6282267", "0.6265862", "0.6256419", "0.62271136", "0.6221337", "0.62017894", "0.60886043", "0.6063855", "0.6039743", "0.6021034", "0.6010283", "0.60091543", "0.5938398", "0.59243244", "0.59230936", "0.59065485", "0.59057117", "0.59048...
0.80193526
1
Return a function that returns the average value of FN when called. To implement this function, you will have to use args syntax, a new Python feature introduced in this project. See the project description. >>> dice = make_test_dice(4, 2, 5, 1) >>> averaged_dice = make_averaged(dice, 1000) >>> averaged_dice() 3.0
def make_averaged(fn, num_samples=1000): # BEGIN PROBLEM 8 "*** YOUR CODE HERE ***" def return_average(*args): k, total = 0, 0 while k < num_samples: total += fn(*args) k += 1 return total / num_samples return return_average # END PROBLEM 8
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_averaged(fn, num_samples=1000):\n # BEGIN PROBLEM 8\n def average(*args):\n sum = 0\n for i in range(num_samples):\n sum += fn(*args)\n return sum / num_samples\n return average\n # END PROBLEM 8", "def make_averaged(fn, num_samples=1000):\n # BEGIN PROBLEM...
[ "0.742507", "0.7286888", "0.69316167", "0.60547763", "0.60077626", "0.59997326", "0.5834956", "0.57966316", "0.5760647", "0.57417023", "0.57063097", "0.56811064", "0.5680927", "0.5663702", "0.55822456", "0.5506385", "0.5506385", "0.5506385", "0.546159", "0.54614824", "0.54594...
0.73083514
1
Return the number of dice (1 to 10) that gives the highest average turn score by calling roll_dice with the provided DICE over NUM_SAMPLES times. Assume that the dice always return positive outcomes. >>> dice = make_test_dice(1, 6) >>> max_scoring_num_rolls(dice) 1
def max_scoring_num_rolls(dice=six_sided, num_samples=1000): # BEGIN PROBLEM 9 "*** YOUR CODE HERE ***" k, max_value, max_num = 1, 0, 0 roll = make_averaged(roll_dice, num_samples) while k <= 10: current_value = roll(k, dice) #print('k: ' + str(k) + ' current_value: ' + str(current_v...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_scoring_num_rolls(dice=six_sided, num_samples=1000):\n # BEGIN PROBLEM 9\n averaged_dice = make_averaged(roll_dice, num_samples)\n max_score = 0\n result = 0\n for num_rolls in range(1, 11):\n average_turn_score = averaged_dice(num_rolls, dice)\n if average_turn_score > max_sco...
[ "0.8601709", "0.80853796", "0.6568092", "0.6565552", "0.6456323", "0.63220537", "0.62745166", "0.625151", "0.6118052", "0.60378474", "0.59962904", "0.5992495", "0.59903264", "0.5952468", "0.59410113", "0.5890593", "0.5816515", "0.5800886", "0.5747316", "0.5736538", "0.5682466...
0.8030235
2
Return 0 if strategy0 wins against strategy1, and 1 otherwise.
def winner(strategy0, strategy1): score0, score1 = play(strategy0, strategy1) if score0 > score1: return 0 else: return 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play(strategy0, strategy1):\r\n who = 0 # Which player is about to take a turn, 0 (first) or 1 (second)\r\n score0, score1 = 0, 0\r\n while who == 0:\r\n dice_num = dice_check(score0, score1, who, strategy0)\r\n score0 += take_turn(dice_num, score1, select_dice(score0, score1), name(who)...
[ "0.6689735", "0.6615073", "0.6372661", "0.6286028", "0.6247574", "0.62431514", "0.6144753", "0.61409026", "0.6093172", "0.60292673", "0.5996782", "0.5976392", "0.59516424", "0.59036964", "0.5876322", "0.5876114", "0.586334", "0.58454233", "0.58374006", "0.58091956", "0.579776...
0.8123433
1
Return the average win rate of STRATEGY against BASELINE. Averages the winrate when starting the game as player 0 and as player 1.
def average_win_rate(strategy, baseline=always_roll(4)): win_rate_as_player_0 = 1 - make_averaged(winner)(strategy, baseline) win_rate_as_player_1 = make_averaged(winner)(baseline, strategy) return (win_rate_as_player_0 + win_rate_as_player_1) / 2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def win_ratio_avg(self):\n win_ratio = 0\n # Adds all the win ratios of team in this conference which will be\n # used to compute the win ratio average.\n for team_obj in self._conf_teams:\n ### INVARIANT: team_obj is a Team class object and\n ### self._con...
[ "0.6717765", "0.64588726", "0.63417643", "0.62936395", "0.6277814", "0.610984", "0.61046314", "0.6065044", "0.59797865", "0.5971465", "0.5899065", "0.5877843", "0.5819356", "0.5789211", "0.5763565", "0.57442445", "0.5724848", "0.57111496", "0.5692904", "0.5664826", "0.5659643...
0.8115959
1
Run a series of strategy experiments and report results.
def run_experiments(): if False: # Change to False when done finding max_scoring_num_rolls six_sided_max = max_scoring_num_rolls(six_sided) print('Max scoring num rolls for six-sided dice:', six_sided_max) if False: # Change to True to test always_roll(8) print('always_roll(8) win rat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_experiments():\r\n result = eval_strategy_range(always_roll, 1, 10)\r\n print('Best always_roll strategy:', result)\r\n\r\n if True: # Change to True when ready to test make_comeback_strategy\r\n result = eval_strategy_range(make_comeback_strategy, 5, 15)\r\n print('Best comeback str...
[ "0.7600534", "0.70792615", "0.70204407", "0.69126785", "0.6863788", "0.683368", "0.66033673", "0.65340483", "0.648887", "0.6473116", "0.6473116", "0.6473116", "0.6462529", "0.6456427", "0.6447508", "0.64332825", "0.636296", "0.6348656", "0.62743956", "0.6269425", "0.6254592",...
0.7061546
2
This strategy rolls 0 dice if that gives at least MARGIN points, and rolls NUM_ROLLS otherwise.
def bacon_strategy(score, opponent_score, margin=8, num_rolls=4): # BEGIN PROBLEM 10 if free_bacon(opponent_score) >= margin: return 0 return num_rolls # END PROBLEM 10
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def roll(self):\n rolls = []\n if self.dice_array is not None:\n for dice in self.dice_array:\n rolls.append(np.random.randint(1, dice+1))\n else:\n for _ in range(0,self.number):\n rolls.append(np.random.randint(1, self.sides+1))\n #F...
[ "0.640882", "0.6383132", "0.6260958", "0.62457883", "0.623219", "0.6221527", "0.6191936", "0.6188556", "0.6102771", "0.6068335", "0.60042995", "0.597458", "0.5960024", "0.5950923", "0.5943093", "0.5897673", "0.58673483", "0.58545053", "0.5813064", "0.5807225", "0.5772373", ...
0.0
-1
This strategy rolls 0 dice when it triggers a beneficial swap. It also rolls 0 dice if it gives at least MARGIN points and does not trigger a nonbeneficial swap. Otherwise, it rolls NUM_ROLLS.
def swap_strategy(score, opponent_score, margin=8, num_rolls=4): # BEGIN PROBLEM 11 new_score = score + free_bacon(opponent_score) if is_swap(new_score, opponent_score) and (opponent_score > new_score): return 0 elif free_bacon(opponent_score) >= margin and not (is_swap(new_score, opponent_score...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_comeback_strategy(margin, num_rolls=5):\r\n def from_the_depths(score, opp_score):\r\n if opp_score - score >= margin: return num_rolls + 1\r\n else: return num_rolls\r\n return from_the_depths", "def final_strategy(score, opponent_score):\n # BEGIN PROBLEM 12\n def is_odd(n):\...
[ "0.6452284", "0.63540983", "0.63094753", "0.62689674", "0.62569886", "0.61875606", "0.612704", "0.612704", "0.6077186", "0.60761815", "0.60616195", "0.60535634", "0.60535634", "0.60535634", "0.6049227", "0.60323215", "0.60221475", "0.5974652", "0.5950272", "0.5941493", "0.592...
0.63004863
3
Read in the commandline argument and calls corresponding functions. This function uses Python syntax/techniques not yet covered in this course.
def run(*args): import argparse parser = argparse.ArgumentParser(description="Play Hog") parser.add_argument('--run_experiments', '-r', action='store_true', help='Runs strategy experiments') args = parser.parse_args() if args.run_experiments: run_experiments()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n args = parse_args()\n process_args(args)", "def main(args):", "def main(args):", "def main(args=None):", "def main(args=None):", "def main(args=None):\n pass", "def main():\n parser = argparse.ArgumentParser(description=\"\"\"Tester for YT Data API and different inputs\"\"\")\...
[ "0.7371581", "0.7101281", "0.7101281", "0.71001196", "0.71001196", "0.68302774", "0.67929476", "0.67655843", "0.6722067", "0.6722067", "0.6720285", "0.667106", "0.66193235", "0.66193235", "0.66193235", "0.66193235", "0.66193235", "0.66193235", "0.66193235", "0.66193235", "0.6...
0.0
-1
Ensure that it reduces to the mutual information for bivariate distributions.
def test_caekl_1(d): assert I(d) == pytest.approx(J(d))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_fit_default_distribution(self):\n\n copula = GaussianMultivariate(GaussianUnivariate)\n copula.fit(self.data)\n\n for i, key in enumerate(self.data.columns):\n assert copula.columns[i] == key\n assert copula.univariates[i].__class__ == GaussianUnivariate\n ...
[ "0.5723322", "0.56464213", "0.56001174", "0.55144453", "0.54087925", "0.54014647", "0.5367786", "0.5322792", "0.5297757", "0.52877957", "0.52863365", "0.5265465", "0.52652", "0.52548265", "0.52372015", "0.52356696", "0.51734567", "0.51734096", "0.5166007", "0.51452106", "0.51...
0.0
-1
Ensure that it reduces to the mutual information for bivariate distributions reduced from multivariate.
def test_caekl_2(d): rvs = [[0], [1]] assert I(d, rvs) == pytest.approx(J(d, rvs))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multivariate_gauss_prob(observed, mean, covariance):\n\n return None", "def _handleInput(self, paramInput):\n super()._handleInput(paramInput)\n if paramInput.parameterValues['method'] == 'pca':\n self.method = 'pca'\n elif paramInput.parameterValues['method'] == 'spline':\n self.method...
[ "0.58070433", "0.57255405", "0.56607497", "0.5495321", "0.535974", "0.52546823", "0.52330446", "0.5210722", "0.52041334", "0.5199552", "0.5195257", "0.5186404", "0.51677173", "0.51306176", "0.5130186", "0.5125754", "0.51237744", "0.51133645", "0.5106805", "0.5079338", "0.5073...
0.0
-1
Test a known value.
def test_caekl_3(): d = D(['000', '011', '101', '110'], [1 / 4] * 4) assert J(d) == pytest.approx(0.5)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_value(self, value):", "def _check_value(self, value):\n raise NotImplementedError", "def check(self, value):\n raise NotImplementedError", "def _check_value(self, value, name, check_function):\n if check_function is not None:\n is_good = check_function(value) #May ra...
[ "0.80775046", "0.7501336", "0.7266181", "0.7051244", "0.6900198", "0.6898595", "0.6877228", "0.684004", "0.6814614", "0.6802086", "0.6755023", "0.6750932", "0.66680443", "0.66036206", "0.6560172", "0.65543497", "0.6528797", "0.6458347", "0.64339", "0.642714", "0.64136505", ...
0.0
-1
Test that CAEKL is always less than or equal to the normalized total correlation.
def test_caekl_4(d): assert J(d) <= (T(d) / 3) + 1e-6
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_absolutely_monotonic(self,r,tol):\n s=len(self)\n K=np.vstack([self.A.astype(float),self.b.astype(float)])\n K=np.hstack([K,np.zeros([s+1,1])])\n X=np.eye(s+1)+r*K\n if abs(np.linalg.det(X))<tol: return 0\n beta_r=np.linalg.solve(X,K)\n v_r_sum = np.dot(np.e...
[ "0.604998", "0.6012431", "0.59215325", "0.5856045", "0.58455676", "0.58151805", "0.5794475", "0.5794475", "0.5794475", "0.5787765", "0.57562685", "0.57562685", "0.57562685", "0.5755928", "0.5742629", "0.57194674", "0.5675751", "0.56736386", "0.566482", "0.5655411", "0.5621105...
0.53975534
55
Applies the logistic function to x, elementwise.
def sigmoid(X): return 1 / (1 + np.exp(-X))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logistic(self,w,Xi):\n # print(w.T)\n # print(Xi)\n a = np.dot(w.T,Xi)\n return 1/(1+np.exp(-a))", "def logistic(self, X, w):\n g = 1 / (1 + np.exp(-X.dot(w)))\n return g", "def forward(self, x):\n\n embeds = self.dvector(x)\n logits = self.linear(emb...
[ "0.7002704", "0.6978957", "0.6883872", "0.68210745", "0.6803985", "0.6706345", "0.66907454", "0.6664395", "0.6663363", "0.66488755", "0.664373", "0.660833", "0.6597647", "0.6596353", "0.6534404", "0.64707106", "0.64558506", "0.64442515", "0.64267933", "0.6374905", "0.6363094"...
0.0
-1
Combines given list argument in a logistic equation and returns it as a function
def logistic_hypothesis(theta): return lambda X: sigmoid(np.dot(x_strich(X), theta))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logistic(mu):\n mu4 = 4*mu\n def f(x):\n return mu4*x*(1.-x)\n return f", "def logistic_function(self, data, b0, b1):\n return np.array([1/(1+exp(-1*b0+(-1*b1*x))) for x in data])", "def logistic_function(z):\n\tg = 1/(1+np.exp(-z))\n\t#g = np.exp(z)/(1+np.exp(z))\n\treturn g", "de...
[ "0.68958294", "0.68420416", "0.6600226", "0.65383476", "0.6343635", "0.628913", "0.624117", "0.62409633", "0.61989814", "0.6157783", "0.61215085", "0.6084098", "0.60748845", "0.6012121", "0.5917856", "0.5874498", "0.58656096", "0.5851732", "0.58011216", "0.57765955", "0.57699...
0.60247886
13
Implements crossentropy as a function costs(theta) on given traning data
def cross_entropy(X, y): return lambda theta: -y * np.log(logistic_hypothesis(theta)(X) + 1e-9) - ( 1 - y ) * np.log(1 - logistic_hypothesis(theta)(X) + 1e-9)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_entropy(y_observed, p):\n\n pass", "def cross_entropy(t,y):\r\n #print(-1*t*np.log(y))\r\n #print(np.shape(np.log(y)))\r\n #print(np.shape(t))\r\n return t*np.log(y)*(-1)", "def cross_entropy(predictions, targets):\n likelihood = targets * np.log(predictions)\n return -np.sum(lik...
[ "0.73253536", "0.6912139", "0.6881294", "0.6762478", "0.6754978", "0.6689187", "0.6629159", "0.660048", "0.6590784", "0.65587205", "0.6547451", "0.6451672", "0.64506274", "0.6429443", "0.64189255", "0.63606083", "0.6355681", "0.633888", "0.6335124", "0.6334", "0.63227713", ...
0.71423405
1
Updates learnable parameters theta The update is done by calculating the partial derivities of the cost function including the linear hypothesis. The gradients scaled by a scalar are subtracted from the given theta values.
def compute_new_theta(X, y, theta, learning_rate, lambda_reg): thetas = np.zeros(len(theta)) thetas = theta * (1 - learning_rate * (lambda_reg / len(X))) - ( learning_rate / len(X) ) * np.sum((logistic_hypothesis(theta)(X) - y) * x_strich(X).T, axis=1) return thetas
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_grad_updates(self):\n \n gradients = T.grad(self.cost, self.theta)\n \n for target_param, grad in zip(self.theta, gradients):\n \n if target_param.name ==\"W\" and self.num_hidden ==0\\\n and self.zero_diag:\n \n grad ...
[ "0.70289654", "0.694744", "0.694744", "0.6826142", "0.66292876", "0.6610046", "0.65948474", "0.6546575", "0.652195", "0.65193623", "0.65162325", "0.65117294", "0.65025204", "0.64622724", "0.64474326", "0.641127", "0.63753605", "0.63573223", "0.63517094", "0.63488644", "0.6333...
0.62909085
27
Minimize theta values of a logistic model based on crossentropy cost function
def gradient_descent(X, y, theta, learning_rate, num_iters, lambda_reg): thetas = [theta] cost = np.zeros(num_iters) J = mean_cross_entropy_costs(X, y, lambda_reg) cost[0] = J(thetas[0]) for i in range(1, num_iters): thetas.append(compute_new_theta(X, y, thetas[i - 1], learning_rate, lambda...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logit_cost(self, theta, X, y):\n\n cost = 0.0\n\n ### YOUR CODE HERE\n sig = utils.sigmoid(theta)\n \n for i in range(0, X.shape[0]):\n cost += (y[i]-1)*theta[i] + np.log(sig[i])\n ### END YOUR CODE\n cost = cost #+ 0.01 * self.regularizer[0](self.wei...
[ "0.75096697", "0.7109986", "0.7026688", "0.69945616", "0.6948253", "0.68546367", "0.6719014", "0.6706194", "0.66798836", "0.6674309", "0.6670411", "0.6663733", "0.6650096", "0.6644245", "0.6628111", "0.6595147", "0.6570327", "0.6524744", "0.6518117", "0.6495512", "0.6472702",...
0.0
-1
Implements mean crossentropy as a function J(theta) on given traning data
def mean_cross_entropy_costs(X, y, lambda_reg=0.0): return lambda theta: np.mean(cross_entropy(X, y)(theta)) + L2_regularization_cost( X, theta, lambda_reg )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_entropy(y_observed, p):\n\n pass", "def cross_entropy(t,y):\r\n #print(-1*t*np.log(y))\r\n #print(np.shape(np.log(y)))\r\n #print(np.shape(t))\r\n return t*np.log(y)*(-1)", "def objective_function(theta, X, y):\n # m number of training instances\n m = X.shape[0]\n jtheta = sum...
[ "0.6527088", "0.6297951", "0.6211556", "0.61678755", "0.6018695", "0.596516", "0.59576994", "0.5953384", "0.59498775", "0.59448695", "0.59320253", "0.5895446", "0.58729154", "0.58721983", "0.5862694", "0.5858808", "0.5858743", "0.5858007", "0.583182", "0.58312905", "0.5809158...
0.0
-1
Plots the costs over the iterations
def plot_progress(fig, costs, learning_rate, lambda_reg): ax = fig.add_subplot(111) ax.plot( np.arange(len(costs)), costs, alpha=0.8, label="LR: " + str(learning_rate) + " __ Lambda: " + str(lambda_reg), ) ax.legend( bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_costs(j_history):\n plt.figure(figsize=(14, 8))\n plt.plot(range(len(j_history)), j_history)\n plt.grid(True)\n plt.title('J (Cost)')\n plt.xlabel('Iteration')\n plt.ylabel('Cost function')\n plt.xlim([0, 1.05 * ITERATIONS])\n plt.ylim([4, 7])\n plt.show()\n plt.close()", "...
[ "0.7945268", "0.7783235", "0.767943", "0.7237459", "0.68332607", "0.6824882", "0.67958784", "0.67673373", "0.67216945", "0.6590324", "0.6507171", "0.6492306", "0.6478465", "0.647183", "0.64140046", "0.6411427", "0.633973", "0.632849", "0.63174886", "0.62941676", "0.6243552", ...
0.69094783
4
Set up each webpage with a header and navigation bar.
def setup_page( self, html_page, links, label=None, title=None, approximant=None, background_colour=None, histogram_download=False ): html_file = webpage.open_html( web_dir=self.webdir, base_url=self.base_url, html_page=html_page, label=label ) html_fi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_webpages(self):\n if self.add_to_existing:\n self.add_existing_data()\n self.make_home_pages()\n self.make_1d_histogram_pages()\n self.make_corner_pages()\n self.make_config_pages()\n if self.make_comparison:\n self.make_comparison_pages(...
[ "0.6627888", "0.6465586", "0.62752324", "0.6114537", "0.6103888", "0.606285", "0.60445887", "0.6036751", "0.60337174", "0.6021009", "0.5930741", "0.5924869", "0.5913862", "0.58483374", "0.5833003", "0.58251595", "0.57794666", "0.57769567", "0.57743686", "0.5753638", "0.575228...
0.6815308
0
Make a navbar for the homepage
def make_navbar_for_homepage(self): links = [ "home", ["Result Pages", self._result_page_links()], "Version" ] if len(self.samples) > 1: links[1][1] += ["Comparison"] if self.publication: links.insert(2, "Publication") if self.gwdata is not Non...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main_nav():\n return render_template('home.html')", "def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")", "def index():\n return render_template(\n 'index.html',\n nav=nav,\n title='Home Page',\n year=datetime...
[ "0.736893", "0.67783135", "0.6750848", "0.66524625", "0.6623326", "0.6588633", "0.6580005", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.6562279", "0.653496", "0.6521001", "0.6503073", "0.64983183", ...
0.71998024
1
Make a navbar for the result page homepage
def make_navbar_for_result_page(self): links = { i: ["1d Histograms", [{"Custom": i}, {"All": i}]] for i in self.labels } for num, label in enumerate(self.labels): for j in self.categorize_parameters(self.samples[label].keys()): j = [j[0], [{k: label} for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_navbar_for_homepage(self):\n links = [\n \"home\", [\"Result Pages\", self._result_page_links()], \"Version\"\n ]\n if len(self.samples) > 1:\n links[1][1] += [\"Comparison\"]\n if self.publication:\n links.insert(2, \"Publication\")\n if...
[ "0.80170983", "0.7169193", "0.6690814", "0.6587678", "0.6552421", "0.6529632", "0.65201473", "0.65188295", "0.64830226", "0.6469217", "0.64192796", "0.64133656", "0.6382045", "0.6367651", "0.63470757", "0.63470757", "0.63470757", "0.63470757", "0.63470757", "0.63470757", "0.6...
0.6568194
4
Generate all webpages for all result files passed
def generate_webpages(self): if self.add_to_existing: self.add_existing_data() self.make_home_pages() self.make_1d_histogram_pages() self.make_corner_pages() self.make_config_pages() if self.make_comparison: self.make_comparison_pages() if ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n for file_name in os.listdir(CONTENT_FOLDER):\n if file_name.endswith('.html'):\n try_generate_page(file_name)", "def make_all_html_results(cmd, folder_names = [], jobs=[]):\n run = cmd.results.current['run_name']\n if not os.path.exists(pjoin(cmd.me_dir, 'HTML', run)):\n ...
[ "0.7309482", "0.6664472", "0.6591473", "0.65694594", "0.6510609", "0.6404508", "0.6366648", "0.63231736", "0.6277945", "0.622136", "0.6204493", "0.6124423", "0.6105005", "0.60247594", "0.6022048", "0.5962354", "0.5959207", "0.59505546", "0.59500504", "0.5926389", "0.5917044",...
0.70953083
1