# Coding

### K-Means Clustering Algorithm

K-Means is a widely used clustering algorithm that partitions a set of data points into K clusters, where each cluster is defined by its centroid. The goal of the algorithm is to minimize the sum of squared distances between each data point and its closest centroid. The algorithm starts by randomly selecting K initial centroids and assigning each data point to the closest centroid. Then, it iteratively updates the position of the centroids and reassigns each data point to the closest centroid until the assignments no longer change. The algorithm terminates when the centroids reach a stable position. Mathematical Intuition…

### Support Vector Machine

Support Vector Machines (SVM) is a supervised machine learning algorithm that can be used for classification or regression tasks. The goal of the SVM algorithm is to find the hyperplane in an N-dimensional space that maximally separates the two classes. Mathematical Intuition Support Vector Machines (SVMs) are a type of supervised machine learning algorithm that can be used for classification or regression tasks. The goal of an SVM is to find the hyperplane in a high-dimensional space that maximally separates the different classes. Imagine we have two classes of data points, represented by circles and rectangles The SVM algorithm will…

### Find out the Longest Path in a matrix

Given an m-by-n matrix with positive integers, determine the length of the longest path of increasing within the matrix. For example, consider the input matrix:[1 2 34 5 67 8 9] The answer should be 5 since the longest path would be 1-2-5-6-9 def isValid(mat, i, j): return 0 <= i < len(mat) and 0 <= j < len(mat) def findLongestPath(mat, i, j): if not isValid(mat, i, j): return [] path = [] if i > 0 and mat[i - 1][j] - mat[i][j] == 1: path = findLongestPath(mat, i - 1, j) if j + 1 < len(mat) and mat[i][j…

### How do you count repeated words in a list in Python?

In this post, we will talk about how to count repeated words in python list. It can be done in many ways. Using collections.Counter() # Importing counter function. from collections import Counter words = ["a", "b", "a", "c", "c", "a", "c"] duplicate_dict = Counter(words) print(duplicate_dict)#to get occurence of each of the element. print(duplicate_dict['a'])# to get occurence of specific element. Output: Counter({'a': 3, 'c': 3, 'b': 1}) 3 Using count() letter = ["b", "a", "a", "c", "b", "a", "c",'a'] counting=letter.count('a') print(counting) Output: > 4 Hope this helps! Important Notice for college students If you’re a college student and have skills in programming languages,…

### What is the difference between artificial and convolutional neural networks?

A Convolutional Neural Network (ConvNet/CNN) is a Deep Learning algorithm that can take in an input image, assign importance (learnable weights and biases) to various aspects/objects in the image, and be able to differentiate one from the other. The pre-processing required in a ConvNet is much lower as compared to other classification algorithms. While in primitive methods filters are hand-engineered, with enough training, ConvNets have the ability to learn these filters/characteristics. The architecture of a ConvNet is analogous to that of the connectivity pattern of Neurons in the Human Brain and was inspired by the organization of the Visual Cortex. Individual neurons…

### What is the VGG 19 neural network?

VGG 19 is a convolutional neural network architecture that is 19 layers deep. The main purpose for which the VGG net was designed was to win the ILSVRC imagenet competition. Let’s take a brief look at the architecture of VGG19. Input: The VGG-19 takes in an image input size of 224×224.Convolutional Layers: VGG’s convolutional layers leverage a minimal receptive field, i.e., 3×3, the smallest possible size that still captures up/down and left/right. This is followed by a ReLU activation function. ReLU stands for rectified linear unit activation function, it is a piecewise linear function that will output the input if positive otherwise, the output is zero. Stride is…

### How do I solve tough programming problems in HackerRank?

If you are a beginner then go with easy problems first, try to solve as much you can for getting confidence. If, you are not able to solve easy problems then spend some time on that try to think harder, even you can't solve the problem go for editorial read the approach, don't read the code and try to solve your own spend time and practice gives you high return for sure. If you think you can solve easy problems go for a medium one. Go with the same approach as you have done with easy problems…even giving more time…

### What is the difference between the append() and insert() list methods in Python?

Difference between append() and insert () Append(): This function is used to modify an already existing list. Adds a new specific element at the end of the list. Syntax: List_Name.append(item) Insert(): This function also modifies an already existing list. The only difference between append() and insert() is that the insert function allows us to add a specific element at a specified index of the list unlike append() where we can add the element only at end of the list. Syntax: List_Name.insert(index, item) Refer below example for better understanding Important Notice for college students If you’re a college student and have…

### Create a digital clock using Python-Turtle￼

Prerequisites: Turtle in programming Python. Turtle is a special feature of Python. Using Turtle, we can easily draw on a drawing board. First, we import the turtle module. Then create a window, next we create a turtle object and using the turtle methods we can draw on the drawing board. In this blog we'll be creating a digital clock using turtle and python. Installation:  To install this module type the below command in the terminal. pip install turtle Note: To create a clock we will use the ‘time’ and ‘DateTime’ module of Python also, To install time use the following command:…