Gaurav Kumar has Published 50 Answers

Implementing K-means clustering of Diabetes dataset with SciPy library

Gaurav Kumar

Gaurav Kumar

Updated on 14-Dec-2021 08:59:17

The Pima Indian Diabetes dataset, which we will be using here, is originally from the National Institute of Diabetes and Digestive and Kidney Diseases. Based on the following diagnostic factors, this dataset can be used to place a patient in ether diabetic cluster or non-diabetic cluster −PregnanciesGlucoseBlood PressureSkin ThicknessInsulinBMIDiabetes Pedigree ... Read More

Implementing K-means clustering with SciPy by splitting random data in 3 clusters?

Gaurav Kumar

Gaurav Kumar

Updated on 14-Dec-2021 08:48:44

Yes, we can also implement a K-means clustering algorithm by splitting the random data in 3 clusters. Let us understand with the example below −Example#importing the required Python libraries: import numpy as np from numpy import vstack, array from numpy.random import rand from scipy.cluster.vq import whiten, kmeans, vq from pylab ... Read More

Implementing K-means clustering with SciPy by splitting random data in 2 clusters?

Gaurav Kumar

Gaurav Kumar

Updated on 14-Dec-2021 08:42:53

K-means clustering algorithm, also called flat clustering, is a method of computing the clusters and cluster centers (centroids) in a set of unlabeled data. It iterates until we find the optimal centroid. The clusters, we might think of a group of data points whose inter-point distances are small as compared ... Read More

What is scipy cluster hierarchy? How to cut hierarchical clustering into flat clustering?

Gaurav Kumar

Gaurav Kumar

Updated on 25-Nov-2021 07:05:23

The scipy.cluster.hierarchy module provides functions for hierarchical clustering and its types such as agglomerative clustering. It has various routines which we can use to −Cut hierarchical clustering into the flat clustering.Implement agglomerative clustering.Compute statistics on hierarchiesVisualize flat clustering.To check isomorphism of two flat cluster assignments.Plot the clusters.The routine scipy.cluster.hierarchy.fcluster is ... Read More

Which linear function of SciPy is used to solve a banded matrix equation?

Gaurav Kumar

Gaurav Kumar

Updated on 25-Nov-2021 06:50:00

The linear function named scipy.linalg.solve_banded is used to solve the banded matrix equation. The form of this function is as follows −scipy.linalg.solve_banded(l_and_u, ab, b, overwrite_ab=False, overwrite_b=False, debug=None, check_finite=True)This linear function will solve the equation ax = b for x where a is a banded matrix.The banded matrix a is stored ... Read More

What is scipy.cluster.hierarchy.fcluster()method?

Gaurav Kumar

Gaurav Kumar

Updated on 25-Nov-2021 06:43:02

scipy.cluster.hierarchy.fcluster(Z, t, criterion=’inconsistent’depth=2, R=None, monocrat=None)− The fcluster() method forms flat clusters from the hierarchical clustering. This hierarchical clustering is defined by the given linkage matrix, identifying a link between clustered classes.Below is given the detailed explanation of its parameters −ParametersZ− ndarrayIt represents the hierarchical clustering which is encoded with the ... Read More

How to solve Hermitian positive-banded matrix equation using Python SciPy?

Gaurav Kumar

Gaurav Kumar

Updated on 25-Nov-2021 06:36:52

The linear function named scipy.linalg.solveh_banded is used to solve the banded matrix equation. In the below given example we will be solving the banded system Hx = b where −$$\mathrm{H} = \begin{bmatrix} 8 & 2-1j&0 &0 \\ 2+1j & 5& 1j & -2-1j0\\ 0 & -1j& 9& \\ 0 & ... Read More

How to solve triangular matrix equations using Python SciPy?

Gaurav Kumar

Gaurav Kumar

Updated on 24-Nov-2021 14:37:03

The linear function named scipy.linalg.solveh_triangular is used to solve the banded matrix equation. In the below given example we will be solving the triangular system ax = b where −$$\mathrm{a} = \begin{bmatrix} 3 & 0 & 0 & 0\\ 2 & 1 & 0 & 0\\ 1 &0 &1 &0 ... Read More

Finding inverse of a square matrix using SciPy library

Gaurav Kumar

Gaurav Kumar

Updated on 24-Nov-2021 13:42:44

SciPy library has scipy.linalg.inv() function for finding the inverse of a square matrix. Let’s understand how we can use this function to calculate the inverse of a matrix −ExampleInverse of a 2 by 2 matrix#Importing the scipy package import scipy.linalg #Importing the numpy package import numpy as np ... Read More

Various approaches in Python to load CSV data for ML projects

Gaurav Kumar

Gaurav Kumar

Updated on 24-Nov-2021 13:10:55

To successfully build a machine learning project, loading data properly is one of the most important as well as challenging tasks. CSV is the most common format for machine learning projects. It is a simple format which is used to store tabular data.Followings are the three most common approaches in ... Read More

Advertisements