Articles on Trending Technologies

Technical articles with clear explanations and examples

Calculating the Hamming distance using SciPy

Gaurav Kumar
Gaurav Kumar
Updated on 24-Nov-2021 1K+ Views

Hamming distance calculates the distance between two binary vectors. Mostly we find the binary strings when we use one-hot encoding on categorical columns of data. In one-hot encoding the integer variable is removed and a new binary variable will be added for each unique integer value. For example, if a column had the categories say ‘Length’, ‘Width’, and ‘Breadth’. We might one-hot encode each example as a bitstring with one bit for each column as follows −Length = [1, 0, 0]Width = [0, 1, 0]Breadth = [0, 0, 1]The Hamming distance between any of the two categories mentioned above, can ...

Read More

What is Expectation-Maximization?

Ginni
Ginni
Updated on 24-Nov-2021 1K+ Views

The EM (Expectation-Maximization) algorithm is a famous iterative refinement algorithm that can be used for discovering parameter estimates. It can be considered as an extension of the k-means paradigm, which creates an object to the cluster with which it is most similar, depending on the cluster mean.EM creates each object to a cluster according to a weight defining the probability of membership. In other term, there are no strict boundaries among clusters. Thus, new means are evaluated based on weighted measures.EM begins with an original estimate or “guess” of the parameters of the combination model (collectively defined as the parameter ...

Read More

What is the difference between scipy.cluster.vq.kmeans() and scipy.cluster.vq.kmeans2() methods?

Gaurav Kumar
Gaurav Kumar
Updated on 24-Nov-2021 685 Views

The scipy.cluster.vq()has two methods to implement k-means clustering namely kmeans() and kmeans2(). There is a significant difference in the working of both these methods. Let us understand it −scipy.cluster.vq.kmeans(obs, k_or_guess, iter=20, thresh=1e-05, check_finite=True)− The kmeans() method forms k clusters by performing k-means algorithm on a set of observation vectors. To determine the stability of the centroids, this method uses a threshold value to compare the change in average Euclidean distance between the observations and their corresponding centroids. The output of this method is a code book mapping centroid to codes and vice versa.scipy.cluster.vq.kmeans2(data, k, iter=10, thresh=1e-05, minit='random', missing='warn', check_finite=True)− The ...

Read More

What is scipy.cluster.vq.kmeans()method?

Gaurav Kumar
Gaurav Kumar
Updated on 24-Nov-2021 382 Views

The scipy.cluster.vq.kmeans(obs, k_or_guess, iter=20, thresh=1e- 05, check_finite=True)method forms k clusters by performing a k-means algorithm on a set of observation vectors. To determine the stability of the centroids, this method uses a threshold value to compare the change in average Euclidean distance between the observations and their corresponding centroids. The output of this method is a code book mapping centroid to codes and vice versa.Below is given the detailed explanation of its parameters−Parametersobs− ndarrayIt is an ‘M’ by ‘N’ array where each row is an observation, and the columns are the features seen during each observation. Before using, these features ...

Read More

Find the Number of Prefix Sum Prime in Given Range Query using C++

Prateek Jangid
Prateek Jangid
Updated on 24-Nov-2021 401 Views

In this article, we need to find a number of prefix sum which are prime numbers in a given array arr[ ] of positive integers and range query L, R, where L is the initial index value arr[ L ] for prefixsum[ ] array and R is the number of prefix sum we need to find.To fill the prefix sum array, we start with index L to index R and add the present value with the last element in the given array. So here is the Example for the problem −Input : arr[ ] = { 3, 5, 6, 2, ...

Read More

Which function of scipy.cluster.vq module is used to assign codes from a code book to observations?

Gaurav Kumar
Gaurav Kumar
Updated on 24-Nov-2021 322 Views

Before implementing k-means algorithms, the scipy.cluster.vq.vq(obs, code_book, check_finite = True) used to assign codes to each observation from a code book. It first compares each observation vector in the ‘M’ by ‘N’ obs array with the centroids in the code book. Once compared, it assigns the code to the closest centroid. It requires unit variance features in the obs array, which we can achieve by passing them through the scipy.cluster.vq.whiten(obs, check_finite = True)function.ParametersBelow are given the parameters of the function scipy.cluster.vq.vq(obs, code_book, check_finite = True) −obs− ndarrayIt is an ‘M’ by ‘N’ array where each row is an observation, and ...

Read More

Find the Number of Possible Pairs of Hypotenuse and Area to Form Right Angled Triangle using C++

Prateek Jangid
Prateek Jangid
Updated on 24-Nov-2021 346 Views

In this article, we will explain how to solve the number of possible pairs of hypotenuse and area form a right-angled triangle in C++.We need to determine the number of all possible pairs of a hypotenuse and the area ( H, A ) to form a right-angled triangle with H as hypotenuse and A as Area.In this example −         x = Base of Right Angled Triangle         y = Height of Right Angled Triangle         H = hypotenuse of Right Angled TriangleWe know Area of right angled triangle, A = ( x * ...

Read More

Node.js – Timers Module – Cancelling Timers

Mayank Agarwal
Mayank Agarwal
Updated on 24-Nov-2021 568 Views

A timer can only be cancelled after it is being scheduled. The Immediate class has an object for setImmediate() method and passes the same object to clearImmediate(), in case it wants to cancel the scheduled timer function.Scheduling TimersThis type of timers schedules the task to take place after a certain instant of time.setImmediate()setInterval()setTimeout()Cancelling TimersThis type of timers cancels the scheduled tasks which is set to take place.ClearImmediate()clearInterval()clearTimeout()1. clearImmediate() methodThis method clears the Immediate timer object that is created by the setImmediate() method.SyntaxclearImmediate( timer )Examplefilename - clearImmediate.js// clearImmediate() Example var timer = setImmediate(function A() {    console.log("Timer set"); }); ...

Read More

Find the Number of permutation with K inversions using C++

Prateek Jangid
Prateek Jangid
Updated on 24-Nov-2021 681 Views

In an array, A pair a[i], a[j] is known as an inversion if a[i] > a[j] and i < j. We have two numbers N and k, and need to figure out how many possible permutations of the first N numbers end in a perfect K inversion. So here is the example −Input: N = 4, K = 1 Output: 3 Explanation: Permutation of the first N numbers in total : 1234, 1243, 1324 and 2134. With 1 inversion we have 1243, 1324 and 2134. Input : N = 3, K = 2 Output : 3 Explanation: Permutation of ...

Read More

Using Redis Cache with Spring Boot

Mayank Agarwal
Mayank Agarwal
Updated on 24-Nov-2021 6K+ Views

In this article, we will see how to integrate Redis Cache with Spring Boot. We will learn how we can configure Redis data inside the Spring boot cache.Let's look at the dependencies first that are required to import Redis into a Spring boot application.Dependencies// Adding spring-boot cache & redis dependencies    org.springframework.boot    spring-boot-starter-cache    2.4.3    org.springframework.boot    spring-boot-starter-data-redis    2.4.3 ConfigurationAfter adding the Redis dependencies, you now need to perform some configuration so that it could be used in your project. Spring Boot will automatically configure a Redis-cache Manager but with default properties. We can ...

Read More
Showing 47001–47010 of 61,299 articles
Advertisements