algorithm

Does the preprocessing of one algorithm change the conditions of the experiment?

Does the preprocessing of one algorithm change the conditions of the experiment? Question: As an example, We have two algorithms that utilize the same dataset and the same train and test data: 1 – uses k-NN and returns the accuracy; 2 -applies preprocessing before k-NN and adds a few more things, before returning the accuracy. …

Total answers: 1

Algorithm to calculate number of child per each parent from excel file

Algorithm to calculate number of child per each parent from excel file Question: I have an excel file containing 2 columns & 763 row, screenshot : parent-child file Those strange strings is just a code for a mobile sites. As a description, this file has in both columns a mobile sites names, and as you …

Total answers: 1

maximum word split

maximum word split Question: Given a string s and a dictionary of valid words d, determine the largest number of valid words the string can be split up into. I tried solving this problem with the code below but it is not giving me the answer I am looking for. def word_split_dp(s): n = len(s) …

Total answers: 1

Insertion sort python algorithm: Why do we subtract 1 from i?

Insertion sort python algorithm: Why do we subtract 1 from i? Question: Here is the code: list_a = [3,2,5,7,4,1] def insertion_sort(list_a): indexing_length = range(1,len(list_a)) for i in indexing_length: value_to_sort = list_a[i] while list_a[i-1] > value_to_sort and i>0: list_a[i], list_a[i-1] = list_a[i-1], list_a[i] i = i – 1 return list_a I understand the logic to the …

Total answers: 4

Find all combinations that add up to given number python with list of lists

Find all combinations that add up to given number python with list of lists Question: I’ve seen plenty of threads on how to find all combinations that add up to a number with one list, but wanted to know how to expand this such that you can only pick one number at a time, from …

Total answers: 3

why is iterating over a Numpy array faster than direct operations

why is iterating over a Numpy array faster than direct operations Question: I wanted to find out if it is significantly slower to iterate over the first two dimensions of an array in comparison to doing the operations columnwise. To my surprise if found out that its actually faster to do the operations elementwise. Can …

Total answers: 2

Can't index through graph containing string values

Can't index through graph containing string values Question: My goal im to be able to read the shortest distance between a specific building between all other buildings using the Dijkstra algorithm. I believe if I can fix the error, I will be able to complete my goal. The error below stops at a for loop, …

Total answers: 1

Print 1..N² in NxN matrix, starting at bottom-right and zig-zag

Print 1..N² in NxN matrix, starting at bottom-right and zig-zag Question: Given an input n, I want to print n lines with each n numbers such that the numbers 1 through n² are displayed in a zig-zag way, starting with 1 appearing at the bottom-right corner of the output matrix, and 2 at the end …

Total answers: 1

Knapsack with SPECIFIC AMOUNT of items from different groups

Knapsack with SPECIFIC AMOUNT of items from different groups Question: So this is a variation of the Knapsack Problem I came with the other day. It is like a 0-1 Knapsack Problem where there are multiple groups and each item belongs to only one group. The goal is to maximize the profits subject to the …

Total answers: 1