text
stringlengths
301
426
source
stringclasses
3 values
__index_level_0__
int64
0
404k
Data Science, Churn Analysis, Analytics, Lifetime Value, Machine Learning. possible alternatives To use this approach it is critical to find a parametric distribution that fits the actual data (baseline distribution) fairly well. For this we can use qq_plots (as discussed above). In the above example the Weibull distribution fit the data well. In some cases you will not
medium
314
Data Science, Churn Analysis, Analytics, Lifetime Value, Machine Learning. find a distribution that fits the data, in which case the parametric approach will not be an ideal approach. In such cases semi-parametric models may be used. In conclusion parametric models are very powerful models to predict survival. They can estimate the effect of different features/covariates
medium
315
Algorithms, Programming, Interview, Python. Shortest path algorithms — Dijkstra & Bellman-Ford Part II of Graph traversal algorithm series. Read Part I and Part III Shortest path in a weighted graph Djikstra Djikstra’s is a graph traversal algorithm used to find the shortest path between source and destination. Similar to Prim’s algorithm for
medium
317
Algorithms, Programming, Interview, Python. MST this is also a Greedy algorithm. In Djikstra we maintain two sets, one set contains vertices included in the Shortest Path Tree (SPT), and another set has the remaining vertices. In every iteration, we find a vertex from the second (remaining nodes) set that has a minimum distance from the
medium
318
Algorithms, Programming, Interview, Python. source. The core idea of the Dijkstra algorithm is to continuously eliminate longer paths between the source node and all possible destinations. Below are the detailed steps used in Dijkstra’s algorithm: Create an SPT set that keeps track of vertices included in the shortest-path tree. Initially,
medium
319
Algorithms, Programming, Interview, Python. this set is empty. Initialize all vertices in the input graph with an infinite distance value. Assign the distance value as 0 for the source vertex so that it is picked first. While SPT doesn’t include all vertices: 1. Pick a vertex u which is not there in SPT and has a minimum distance value. 2.
medium
320
Algorithms, Programming, Interview, Python. Include u in SPT. 3. Update the distance value of all adjacent vertices of u. To update the distance values, iterate through all adjacent vertices. For every adjacent vertex v, if the sum of the distance value of u (from source) and weight of edge u-v, is less than the distance value of v, then
medium
321
Algorithms, Programming, Interview, Python. update the distance value of v. This process is known as Edge relaxation. In DAG we use topological order to relax the edges. Since we are adding weights of the edges to find the shortest path, Dijkstra’s algorithm can only work with graphs that have positive weights. Code Implementation import
medium
322
Algorithms, Programming, Interview, Python. math from heapq import heappop, heappush class Node: def __init__(self, vertex, weight=0): self.vertex = vertex self.weight = weight def __lt__(self, other): return self.weight < other.weight class Graph: def __init__(self, edges, n): self.adjList = [[] for _ in range(n)] for (source, dest, weight)
medium
323
Algorithms, Programming, Interview, Python. in edges: self.adjList[source].append((dest, weight)) def get_route(prev, i, route): if i >= 0: get_route(prev, prev[i], route) route.append(i) def dijkstra(graph, source, n): pq = [] heappush(pq, Node(source)) dist = [math.inf] * n dist[source] = 0 processed = [False] * n processed[source] = True
medium
324
Algorithms, Programming, Interview, Python. prev = [-1] * n while pq: node = heappop(pq) u = node.vertex for (v, weight) in graph.adjList[u]: if not processed[v] and (dist[u] + weight) < dist[v]: dist[v] = dist[u] + weight prev[v] = u heappush(pq, Node(v, dist[v])) processed[u] = True route = [] for i in range(n): if i != source and dist[i]
medium
325
Algorithms, Programming, Interview, Python. != math.inf: get_route(prev, i, route) print(f'Path ({source} —> {i}): Minimum cost = {dist[i]}, Route = {route}') route.clear() if __name__ == '__main__': n = 5 edges = [ (0, 1, 10), (0, 4, 3), (1, 2, 2), (1, 4, 4), (2, 3, 9), (3, 2, 7), (4, 1, 1), (4, 2, 8), (4, 3, 2) ] graph = Graph(edges, n)
medium
326
Algorithms, Programming, Interview, Python. for source in range(n): dijkstra(graph, source, n) The time complexity of this algorithm being O(|E|+|V|log|V|). Shortest path with negative weights Bellman Ford Algorithm The Bellman-Ford algorithm is an example of bottom-up Dynamic Programming. It starts with a starting vertex and calculates the
medium
327
Algorithms, Programming, Interview, Python. distances of other vertices which can be reached by one edge. It then continues to find a path with two edges and so on. This algorithm also works on graphs with a negative edge weight. Initializes the distance to the source to 0 and all other nodes to INFINITY. For all edges, if the distance to
medium
328
Algorithms, Programming, Interview, Python. the destination can be shortened by taking the edge, the distance is updated to the new lower value. At each iteration i that the edges are scanned, the algorithm finds all shortest paths of at most length i edges. Since the longest possible path without a cycle can be V-1 edges, the edges must be
medium
329
Algorithms, Programming, Interview, Python. scanned V-1 times to ensure that the shortest path has been found for all nodes. A final scan of all the edges is performed, and if any distance is updated, then a path of length |V| edges has been found, which can only occur if at least one negative cycle exists in the graph. Code Implementation
medium
330
Algorithms, Programming, Interview, Python. import math def getPath(parent, vertex): if vertex < 0: return [] return getPath(parent, parent[vertex]) + [vertex] def bellmanFord(edges, source, n): distance = [math.inf] * n parent = [-1] * n distance[source] = 0 for k in range(n - 1): for (u, v, w) in edges: if distance[u] != math.inf and
medium
331
Algorithms, Programming, Interview, Python. distance[u] + w < distance[v]: distance[v] = distance[u] + w parent[v] = u for (u, v, w) in edges: if distance[u] != math.inf and distance[u] + w < distance[v]: return for i in range(n): if i != source and distance[i] < math.inf: print(f'The distance of vertex {i} from vertex {source}, using path
medium
332
Algorithms, Programming, Interview, Python. {getPath(parent, i)}, is {distance[i]}.') if __name__ == '__main__': edges = [ (0, 1, -1), (0, 2, 4), (1, 2, 3), (1, 3, 2), (1, 4, 2), (3, 2, 5), (3, 1, 1), (4, 3, -3) ] n = 5 for source in range(n): bellmanFord(edges, source, n) Its Time complexity is O(VE) . Choosing between two? Happy
medium
333
Design, Design Process, User Experience Design, User Experience, UX. I graduated in Psychology from Nottingham University in 1992, and there is one experiment which I took part in which I still remember to this very day. The reason is simple — embarrassment. We were discussing animal cognition in one of our classes, and we carried out a simple test as an icebreaker
medium
335
Design, Design Process, User Experience Design, User Experience, UX. (experiment would be too strong a word). We placed five different coins in a number of felt bags, and and goal was to pick out one specific coin which we were shown and able to play with before dipping our hands in the bags. The vast majority of my fellow students were able to do this without
medium
336
Design, Design Process, User Experience Design, User Experience, UX. issue, but for some reason I was really having an off day. In the five attempts I was given, I could not pull out the target coin, I kept pulling out the one most similar in size and weight. As I mentioned, this was an ice-breaker with no defined methodological procedure. This is a wordy way of
medium
337
Design, Design Process, User Experience Design, User Experience, UX. saying that when I failed the test, those around me laughed at me, with one pointing out that even a chimp would have had a statistically better performance than me. At the time I remember feeling really stupid for failing. Image: Pixabay This was an extremely important experience for me to have,
medium
338
Design, Design Process, User Experience Design, User Experience, UX. since after graduating I joined BT as a professional psychologists in their Human Factors department. There we carried out a wide range of usability tests and trials with members of the public, working with prototype telecoms products and services to see how easy of difficult, or indeed frustrating
medium
339
Design, Design Process, User Experience Design, User Experience, UX. they were to use. As a professional and member of the British Psychological Association all the tests I designed and ran fully complied with the BPS Standards and Guidelines. These are all available to read online, and are divided into a number of sections, the main ones of interest in relation to
medium
340
Design, Design Process, User Experience Design, User Experience, UX. design tests being: BPS Code of Ethics and Conduct (2009) BPS Practice Guidelines Data Protection Act 1998 — Guidelines for Psychologists (2009) Ethical Enquiries FAQ The main Code of Ethics and Conduct provides a simple framework for understanding the professional practice of psychologists. The
medium
341
Design, Design Process, User Experience Design, User Experience, UX. practice is underpinned by four key ethical values — Respect, Competence, Responsibility and Integrity — and these five core skills: assessment and establishment of agreements with the client; formulation of client needs and problems; intervention or implementation of solutions; evaluation of
medium
342
Design, Design Process, User Experience Design, User Experience, UX. outcomes; and communication through reporting and reflecting on outcomes. These are shown in the figure below: Source: The British Psychological Society, Practice Guidelines, Third Edition “Assessment of psychological processes and behaviour is derived from the theory and practice of both academic
medium
343
Design, Design Process, User Experience Design, User Experience, UX. and applied psychology. It includes both assessing change and stability, and comparison with others. Assessment procedures used will depend heavily on the practice context and may include: the development and use of psychometric tests following best practice; the application of systematic
medium
344
Design, Design Process, User Experience Design, User Experience, UX. observation and measurement of behaviour in a range of contexts and settings; devising structured assessment strategies for individual clients, teams and organisations; and the use of a range of interview processes with clients, carers, other stakeholders and other professionals.” The list above
medium
345
Design, Design Process, User Experience Design, User Experience, UX. describes the range of structured methodologies used in the practice of psychology as a science. When carrying out any type of experiment or trial, including usability testing, the general principle is that people must leave the trial in at least the same sound frame of mind as when they entered
medium
346
Design, Design Process, User Experience Design, User Experience, UX. it. If we think back to the simple test of selecting a coin, I did not finish the test in the same state of mind; I felt embarrassment. In order to ensure that this principle is always in operation in any test or trial, the psychologist will draw up a full briefing and de-briefing procedure. So for
medium
347
Design, Design Process, User Experience Design, User Experience, UX. example, when asking users to play with a new interface, I always used to emphasise that if any parts were difficult to use, this was a fault of the design and the person should not leave thinking they were somehow lacking. As industry trends shifted from the scientific multi-disciplinary Human
medium
348
Design, Design Process, User Experience Design, User Experience, UX. Factors to frameworks such as Design Thinking, non-qualified professionals are now being encouraged to carry out rapid-prototype testing as well as many other trials and customer research, such as empathy mapping. In general, this is positive, but I have seen trials carried out with no regard for
medium
349
Design, Design Process, User Experience Design, User Experience, UX. any formal structure or procedures which acknowledge the psychological impact of being tested upon. Just as a historic side note, it’s interesting for me to see people nowadays talk about lean startups and agility and the need for minimal viable products. In this Channel 4 programme for which I was
medium
350
Design, Design Process, User Experience Design, User Experience, UX. interviewed in 2000, I discuss the fact that technology is changing was (and is) changing so rapidly, that knowledge can soon be out of date. There is huge pressure for those in the design space to trial as fast as possible with the minimum of checks and balances. These pressures though are no
medium
351
Design, Design Process, User Experience Design, User Experience, UX. excuse not to follow ethical guidelines and in fact it was great to see IDEO recently publishing their own book on ethics in design. In the field of personality psychology there is the concept of locus of control. This refers to a person’s belief system in relation to the degree to which they
medium
352
Design, Design Process, User Experience Design, User Experience, UX. ascribe external or internal events and factors to their success in life. If someone has an internal locus of control, they see their own personal efforts as contributing to their success, but someone with an external locus of control places more emphasis on factors external to them. These effects
medium
353
Design, Design Process, User Experience Design, User Experience, UX. are always taken into account by psychologists when designing experiments, as are many other forms of cognitive bias. (The BPS guidelines, pp 11–12, list many of these if you are interested in finding out more). But to what extent are these guidelines and factors taken into account in design
medium
354
Design, Design Process, User Experience Design, User Experience, UX. experiments? This question is the reason I am writing this article. I have seen extremely unprofessional practices which have the potential to be damaging to a lesser or greater degree on those volunteers agreeing to take part in tests. No matter how informal or innocent a test may appear, there
medium
355
Design, Design Process, User Experience Design, User Experience, UX. are potential risks of harm, or, at the very least, accidentally inducing feelings of embarrassment and shame. When experiments and trials are carried out with the correct guidelines and procedures, these risks are reduced immensely. Given that many different people are moving into and doing Design
medium
356
Design, Design Process, User Experience Design, User Experience, UX. Thinking from a wide variety of backgrounds, and who do not necessarily have much in the way of professional training in the design and running of consumer experiments and trials, I did feel the need to write this article to alert people to the need for vigilance in this area. There is huge
medium
357
Design, Design Process, User Experience Design, User Experience, UX. pressure for those in the design space to trial as fast as possible with the minimum of checks and balances. These pressures though are no excuse not to follow ethical guidelines and in fact it was great to see IDEO recently publishing their own book on ethics in design. In the field of personality
medium
358
Design, Design Process, User Experience Design, User Experience, UX. psychology there is the concept of locus of control. This refers to a person’s belief system in relation to the degree to which they ascribe external or internal events and factors to their success in life. If someone has an internal locus of control, they see their own personal efforts as
medium
359
Design, Design Process, User Experience Design, User Experience, UX. contributing to their success, but someone with an external locus of control places more emphasis on factors external to them. These effects are always taken into account by psychologists when designing experiments, as are many other forms of cognitive bias. (The BPS guidelines, pp 11–12, list many
medium
360
Design, Design Process, User Experience Design, User Experience, UX. of these if you are interested in finding out more). But to what extent are these guidelines and factors taken into account in design experiments? This question is the reason I am writing this article. I have seen extremely unprofessional practices which have the potential to be damaging to a
medium
361
Design, Design Process, User Experience Design, User Experience, UX. lesser or greater degree on those volunteers agreeing to take part in tests. No matter how informal or innocent a test may appear, there are potential risks of harm, or, at the very least, accidentally inducing feelings of embarrassment and shame. When experiments and trials are carried out with
medium
362
Design, Design Process, User Experience Design, User Experience, UX. the correct guidelines and procedures, these risks are reduced immensely. Given that many different people are moving into and doing Design Thinking from a wide variety of backgrounds, and who do not necessarily have much in the way of professional training in the design and running of consumer
medium
363
Design, Design Process, User Experience Design, User Experience, UX. experiments and trials, I did feel the need to write this article to alert people to the need for vigilance in this area. I know other people are looking and writing about design ethics, and I just wanted to add my voice and provide some references for where to look further. In addition to the
medium
364
Design, Design Process, User Experience Design, User Experience, UX. British Psychological Association guidelines, Richard Gross has written one of the definitive student textbooks on psychology, Psychology: The Science of Mind and Behaviour, and this has an extensive final section on ethics, issues and debates for psychologists. Although it is written for
medium
365
Linear Algebra, Python, Mathematics, Machine Learning, Numpy. Welcome to the Section on a medium that demonstrates the role of Mathematics in Machine Learning We can start with Linear Algebra which deals with the Linear equations What are linear equations ?, Linear equations are the equations that deal with equations in which the highest power of the variable
medium
367
Linear Algebra, Python, Mathematics, Machine Learning, Numpy. is always 1. Also known as a one-degree equation. The standard form of a linear equation in one variable is of the form Ax+B=0, Here x is a variable, A is a coefficient and B is constant, but in the case of the two variables is Ax+By=C, for example, 3x+7y=10 is the standard form of the 2 variables.
medium
368
Linear Algebra, Python, Mathematics, Machine Learning, Numpy. There are three major forms of linear equations: point-slope form, standard form, and slope-intercept form. Slope-Intercept form y=mx+b, where m is the slope and b is the y-intercept Point-slope form y - y1 = m( x — x1 ), where m is the slope and b is the y-intercept Standard form Ax + By = C ,
medium
369
Linear Algebra, Python, Mathematics, Machine Learning, Numpy. where A , B , C are constants Solving Linear Equations Clear fractions or decimals. Simply each of the sides of the equations by removing the parenthesis and combining the like terms. Isolate the variable term only on 1 side of the equation. Solve further by dividing on each side Check the Main
medium
370
Linear Algebra, Python, Mathematics, Machine Learning, Numpy. solution. It is known as a Linear equation because : Each term has an equation of 1 This equation can be graphed It always results in a straight line. The main meaning of linear in mathematics is those functions that have their function in a straight line. A linear function has 1 independent
medium
371
Linear Algebra, Python, Mathematics, Machine Learning, Numpy. variable and 1 dependent variable. But dear guys remember in the case where the maximum degree of a term is 2 or more than two is called a non-linear equation.For example 3x2 + 2x +1 =0 , 3x +4y=5.This is an example of non-linear equations. Equation 1 has the highest degree of 2 and the second
medium
372
Linear Algebra, Python, Mathematics, Machine Learning, Numpy. equation has variables x and y. Now coming to the main part how we deal with this with the Machine Linear using this concept:- Systems of the linear equations can be solved with arrays with NumPy.Numpy’s np. linalg.solve() function can be used to solve this system of equations for the variables x,
medium
373
Linear Algebra, Python, Mathematics, Machine Learning, Numpy. y, and z.To start with we have to create a Numpy Array A that has a 3 by 3 array of the coefficients. Also, create an array b as the right-hand side of the equations. Now solve the values of x, and z using np. linalg.solve(A,b) The NumPy library is the best library suitable for a variety of
medium
374
Linear Algebra, Python, Mathematics, Machine Learning, Numpy. mathematical/scientific operations such mathematical/scientific operations such as matrix cross and dot products, finding sine and cosine values, Fourier transforms and shape manipulation, etc. Numpy is a short-hand notation for “Numerical Python”. We use the in-built method linalg() and its
medium
375
Python, Python Programming, Coding, Data Structures, Data Analysis. Introduction: Python is a popular high-level programming language that is widely used for various applications, from web development and data analysis to artificial intelligence and scientific computing. One of the key features of Python is its built-in support for various data structures, which
medium
377
Python, Python Programming, Coding, Data Structures, Data Analysis. allow developers to efficiently store and manipulate data in their programs. In this explanation, we will discuss the main types of data structures in Python and provide real-life examples of how they can be used. In simple terms, data structures in Python are used to store and organize data. They
medium
378
Python, Python Programming, Coding, Data Structures, Data Analysis. are important because they allow programmers to efficiently manipulate and access data. Python has several built-in data structures, including lists, tuples, sets, and dictionaries, and each of these structures has its own unique properties and uses. Let’s take a closer look at each of these data
medium
379
Python, Python Programming, Coding, Data Structures, Data Analysis. structures and how they work: Classifications Data structures can be classified into several categories based on how the data is organized and how it can be accessed. The main classifications of data structures in Python include: Sequences: Sequences are data structures that store an ordered
medium
380
Python, Python Programming, Coding, Data Structures, Data Analysis. collection of items. Examples of sequences in Python include lists, tuples, and strings. Sets: Sets are data structures that store an unordered collection of unique items. Sets can be used to efficiently remove duplicates from a list, perform set operations such as union and intersection, and more.
medium
381
Python, Python Programming, Coding, Data Structures, Data Analysis. Dictionaries: Dictionaries are data structures that store key-value pairs. They can be used to efficiently look up values based on their keys, and to store data in a structured and organized way. Stacks and Queues: Stacks and queues are data structures that store a collection of items in a specific
medium
382
Python, Python Programming, Coding, Data Structures, Data Analysis. order. Stacks follow a “last-in, first-out” (LIFO) order, while queues follow a “first-in, first-out” (FIFO) order. Trees and Graphs: Trees and graphs are data structures that store hierarchical and interconnected data. They can be used to represent complex relationships between data items, such as
medium
383
Python, Python Programming, Coding, Data Structures, Data Analysis. the structure of a file system or a social network. By understanding the different classifications of data structures, developers can choose the most appropriate data structure for a particular task, which can help optimize their code for performance and efficiency. 1. Lists A list is a collection
medium
384
Python, Python Programming, Coding, Data Structures, Data Analysis. of values that are ordered and changeable. Lists are defined using square brackets and can contain any type of data. Here’s an example: my_list = [1, 2, 3, "four", "five"] In this example, my_list is a list that contains integers and strings. We can access individual elements of the list using
medium
385
Python, Python Programming, Coding, Data Structures, Data Analysis. their index. For example: print(my_list[0]) # Output: 1 print(my_list[3]) # Output: four We can also modify the list by adding, removing, or changing elements. Here are some examples: my_list.append(6) # Adds 6 to the end of the list my_list.insert(3, "new") # Inserts "new" at index 3
medium
386
Python, Python Programming, Coding, Data Structures, Data Analysis. my_list.remove(2) # Removes the element with value 2 my_list[4] = "five2" # Changes the value at index 4 to "five2" 2. Tuples A tuple is similar to a list, but it is immutable (i.e., cannot be changed once it is created). Tuples are defined using parentheses and can contain any type of data. Here’s
medium
387
Python, Python Programming, Coding, Data Structures, Data Analysis. an example: my_tuple = (1, 2, 3, "four", "five") We can access individual elements of the tuple using their index, just like with a list. However, we cannot modify the tuple. Here are some examples of how to access elements of the tuple: print(my_tuple[0]) # Output: 1 print(my_tuple[3]) # Output:
medium
388
Python, Python Programming, Coding, Data Structures, Data Analysis. four 3. Sets A set is an unordered collection of unique elements. Sets are defined using curly braces or the set() function and can contain any type of data. Here’s an example: my_set = {1, 2, 3, 4, 4, "five"} In this example, my_set contains integers and a string, but it only contains one instance
medium
389
Python, Python Programming, Coding, Data Structures, Data Analysis. of each value (since sets only contain unique elements). We can access elements of the set using a loop or the in keyword. For example: for element in my_set: print(element) if "five" in my_set: print("Yes") We can also modify the set by adding or removing elements. Here are some examples:
medium
390
Python, Python Programming, Coding, Data Structures, Data Analysis. my_set.add(5) # Adds 5 to the set my_set.remove(2) # Removes the element with value 2 4. Dictionaries A dictionary is a collection of key-value pairs. Dictionaries are defined using curly braces and colons, and each key-value pair is separated by a comma. Here’s an example: my_dict = {"name":
medium
391
Python, Python Programming, Coding, Data Structures, Data Analysis. "Alice", "age": 30, "location": "New York"} In this example, my_dict has three key-value pairs, where the keys are “name”, “age”, and “location”, and the values are “Alice”, 30, and “New York”, respectively. We can access individual values by using their keys, like this: print(my_dict["name"]) #
medium
392
Python, Python Programming, Coding, Data Structures, Data Analysis. Output: Alice print(my_dict["location"]) # Output: New York We can also add, modify, or remove key-value pairs. Here are some examples: my_dict["occupation"] = "Programmer" # Adds a new key-value pair my_dict["age"] = 31 # Changes the value of an existing key del my_dict["location"] # Removes a
medium
393
Python, Python Programming, Coding, Data Structures, Data Analysis. key-value pair Real-life Examples Now, let’s look at some real-life examples of how these data structures can be used: Lists: Suppose you are building a to-do list application. You could use a list to store the tasks that need to be completed. Each element of the list could be a dictionary that
medium
394
Python, Python Programming, Coding, Data Structures, Data Analysis. contains information about the task, such as its description and due date. todo_list = [ {"description": "Buy groceries", "due_date": "2023-04-10"}, {"description": "Do laundry", "due_date": "2023-04-12"}, {"description": "Pay bills", "due_date": "2023-04-15"}] Tuples: Suppose you are building a
medium
395
Python, Python Programming, Coding, Data Structures, Data Analysis. weather application that displays the current temperature and the forecast for the day. You could use a tuple to store this information, since it is fixed and will not change once it is retrieved from the weather API. weather_info = ("New York", 55, "Cloudy") Sets: Suppose you are building a social
medium
396
Python, Python Programming, Coding, Data Structures, Data Analysis. network application. You could use a set to store the user’s friends, since each friend should only appear once in the list. user_friends = {"Alice", "Bob", "Charlie", "David"} Dictionaries: Suppose you are building a recipe application. You could use a dictionary to store information about each
medium
397
Python, Python Programming, Coding, Data Structures, Data Analysis. recipe, such as its name, ingredients, and instructions. recipe = { "name": "Spaghetti Bolognese", "ingredients": ["spaghetti", "ground beef", "tomato sauce"], "instructions": ["Boil the spaghetti", "Cook the ground beef", "Mix everything together"] } Here are some tips and tricks related to Python
medium
398
Python, Python Programming, Coding, Data Structures, Data Analysis. data structures: 1. Use list comprehensions to create lists more efficiently: List comprehensions are a concise way to create lists based on existing lists. For example, instead of using a for loop to create a new list, you can use a list comprehension like this: numbers = [1, 2, 3, 4, 5] squares =
medium
399
Python, Python Programming, Coding, Data Structures, Data Analysis. [num**2 for num in numbers] 2. Use dictionaries to store key-value pairs: Dictionaries are very useful for storing data in key-value pairs. For example, you can use a dictionary to store information about a person, such as their name, age, and email: person = {"name": "Alice", "age": 30, "email":
medium
400
Python, Python Programming, Coding, Data Structures, Data Analysis. "alice@example.com"} 3. Use sets to remove duplicates from lists: If you have a list with duplicate items, you can use a set to remove them: numbers = [1, 2, 3, 3, 4, 5, 5] unique_numbers = set(numbers) 4. Use tuples to make functions return multiple values: Tuples are a great way to return
medium
401
Python, Python Programming, Coding, Data Structures, Data Analysis. multiple values from a function. For example, you can use a tuple to return the minimum and maximum values from a list: def min_max(numbers): min_num = min(numbers) max_num = max(numbers) return (min_num, max_num) 5. Use slicing to extract parts of lists: You can use slicing to extract parts of a
medium
402
Python, Python Programming, Coding, Data Structures, Data Analysis. list. For example, you can extract the first three items of a list like this: numbers = [1, 2, 3, 4, 5] first_three = numbers[:3] These are just a few tips and tricks related to Python data structures. By mastering these techniques, you can write more efficient and effective code in Python.
medium
403
Python, Python Programming, Coding, Data Structures, Data Analysis. Conclusion: In conclusion, understanding data structures is an important aspect of Python programming, as it can help developers write more efficient and effective code. By knowing which data structure to use for a particular task, developers can optimize their code for performance, readability,
medium
404
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. Computer Vision Efficient Biomedical Segmentation When Only a Few Label Images Are Available @MICCAI2020 A Proposal for State-of-the-Art Unsupervised Segmentation Using Contrastive Learning MICCAI 2020 Photo by National Cancer Institute on Unsplash In this story, Label-Efficient Multi-Task
medium
406
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. Segmentation using Contrastive Learning, by the University of Tokyo and Preferred Networks, is presented. This is published as a technical paper of the MICCAI BrainLes 2020 workshop. In this paper, a multi-task segmentation model is proposed for a precision medical image task where only a small
medium
407
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. amount of labeled data is available, and contrast learning is used to train the segmentation model. We show experimentally for the first time the effectiveness of contrastive predictive coding [Oord et al., 2018 and H´enaff et al., 2019] as a regularization task for image segmentation using both
medium
408
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. labeled and unlabeled images, and The results provide a new direction for label-efficient segmentation. The results show that it outperforms other multi-tasking methods, including state-of-the-art fully supervised models, when the amount of annotated data is limited. Experiments suggest that the
medium
409
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. use of unlabeled data can provide state-of-the-art performance when the amount of annotated data is limited. Let’s see how they achieved that. I will explain only the essence of ssCPCseg, so If you are interested in reading my blog, please click on ssCPCseg paper and Github. What does this paper
medium
410
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. say? Obtaining annotations for 3D medical images, such as clinical data, is generally costly. On the other hand, there is often a large number of unlabeled images. Therefore, semi-supervised learning methods have a wide range of applications in medical image segmentation tasks. Self-supervised
medium
411
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. learning is a representation learning method that predicts missing input data from unlabeled input data among the remaining input data. Contrastive predictive coding (CPC) has been proposed as a method for self-supervised learning, and it can be applied to small labeled ImageNet classification task
medium
412
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. in the data domain, it has been proposed to outperform the full learning method [H´enaff et al., 2019], but the effectiveness of CPC in the segmentation task has not yet been investigated. Since the risk of overfitting can be reduced by sharing parameters for both the main segmentation task and the
medium
413
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. regularization subtask, multi-task learning has been considered an efficient method for small data. Semi-supervised CPCseg (ssCPCseg) outperformed all other regularization methods, including VAEseg, a fully supervised state-of-the-art model, when the amount of labeled data was small (Table 1).
medium
414
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. Therefore, a contrastive learning (CPC)-based approach was integrated into the multi-task segmentation model task. Methodology The medical image segmentation network in this paper, shown in Figure 1, is an encoder/decoder structure, where the Contrastive predictive coding (CPC) branch branches with
medium
415
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. the decoder block at the end of the Encoder block. The encoder and decoder are composed of ResNet-like blocks (ResBlocks) with skip connections between the encoder and decoder. Besides the CPC branch, different types of regularization branches, VAE branch, and Boundary attention branch, have been
medium
416
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. implemented in this paper, but my blog focuses on the CPC branch only. Contrastive predictive coding (CPC) branch First, the input image is divided into 16 overlapping patches of 32 x 32 x 32 voxels. Each of the divided patches is encoded separately using an encoder in the Encoder-Decoder
medium
417
Deep Learning, Machine Learning, Computer Vision, Artificial Intelligence, Medical Imaging. architecture, spatially averaged, and aggregated into a single feature vector z_i,j,k. Then, the eighth layer ResBlock f_res8 and linear layer W are applied to the upper half of this feature vector to predict the lower half of the feature vector z_i,j,k_low. In addition, a negative sample z_l is
medium
418