Found 1383 Articles for Open Source

How to Reverse a String using Unix Shell Programming?

Prateek Jangid
Updated on 29-Nov-2021 10:46:19

9K+ Views

Bash is a shell or command line interpreter. It is a layer programming language that understands and executes the command that a user enters or can read commands from a script. Essentially Bash or Shell allows users of Unix-like systems and Windows via a Windows subsystem for Linux to control the innermost components of the Operating system using text-based commands.In this article, we will discuss a problem to be solved by Shell scripting. We are given a String, and we need to print the reverse of that string using Shell Programming. For example, Input : str = “ Hello ” ... Read More

Resetting a Root Password in Linux without External Media

Prateek Jangid
Updated on 26-Nov-2021 06:56:45

354 Views

Discuss how to recover the root password of Linux without using any external media. The version of Linux we are working with is CentOS version 8.2. Still, the procedures we will see can work with any Linux distro and many others. You may find that it doesn’t work with some Debian-based distro.To do this exercise, you should have the following requisites Prerequisites −Willingness to work in the Linux command line environment.Physical access to the Linux server(it cannot do this across a network).Procedures to follow to change the root passwordRestart the computer and interrupt the boot process at the grub screen ... Read More

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

Gaurav Kumar
Updated on 24-Nov-2021 08:02:10

134 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

Which function of scipy.cluster.vq module is used to normalize observations on each feature dimension?

Gaurav Kumar
Updated on 23-Nov-2021 13:23:51

87 Views

Before implementing k-means algorithms, it is always beneficial to rescale each feature dimension of the observation set. The function scipy.cluster.vq.whiten(obs, check_finite = True)is used for this purpose. To give it unit variance, it divides each feature dimension of the observation by its standard deviation (SD).ParametersBelow are given the parameters of the function scipy.cluster.vq.whiten(obs, check_finite = True) −obs− ndarrayIt is an array, to be rescaled, where each row is an observation, and the columns are the features seen during each observation. The example is given below −obs = [[ 1., 1., 1.], [ 2., 2., 2.], ... Read More

How can we call the documentation for NumPy and SciPy?

Gaurav Kumar
Updated on 23-Nov-2021 13:15:28

127 Views

If you are unsure of how to use a particular function or variable in NumPy and SciPy, you can call for the documentation with the help of ‘?’. In Jupyter notebook and IPython shell we can call up the documentation as follows −ExampleIf you want to know NumPy sin () function, you can use the below code −import numpy as np np.sin?OutputWe will get the details about sin() function something like as follows −We can also view the source with the help of double question mark (??) as follows −import numpy as np np.sin??Similarly, if you want to see the ... Read More

Implementing K-means clustering of Diabetes dataset with SciPy library

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

672 Views

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 FunctionAgeYou can get this dataset in .CSV format from Kaggle website.ExampleThe example below will use SciPy library to create two clusters namely diabetic and non-diabetic from the Pima Indian diabetes dataset.#importing the required Python libraries: import matplotlib.pyplot as plt import numpy as np from scipy.cluster.vq import whiten, kmeans, vq ... Read More

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

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

140 Views

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 import plot, show #Random data generation: data = vstack((rand(200, 2) + array([.5, .5]), rand(150, 2))) #Normalizing the data: data = whiten(data) # computing K-Means with K = 3 (3 clusters) centroids, mean_value = kmeans(data, 3) print("Code book :", centroids, "") print("Mean of Euclidean distances :", mean_value.round(4)) ... Read More

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

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

339 Views

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 to the distances to the point outside of that cluster. The number of clusters identified from unlabeled data is represented by ‘K’ in K-means algorithm.Given an initial set of K centers, the K-means clustering algorithm can be done using SciPy library by executing by the following steps −Step1− Data point ... Read More

Which SciPy package is used to implement Clustering?

Gaurav Kumar
Updated on 23-Nov-2021 12:49:59

122 Views

Clustering is one among the most useful unsupervised ML methods. It is used to find the relationship patterns and similarity among the input data samples. After finding these patterns, unsupervised algorithm clusters the data samples having similarities into groups as illustrated in the diagram below −Anomaly detection, image segmentation, medical imaging, social network analysis, and market segmentation are some common applications for clustering. K-means and Hierarchical are the two most common forms of clustering.To implement clustering, SciPy provides us a clustering package (scipy.cluster) which further has two modules as given below −scipy.cluster.vq module − This SciPy module provides functions for k-means ... Read More

To work with SciPy, do I need to import the NumPy functions explicitly?

Gaurav Kumar
Updated on 23-Nov-2021 12:39:42

215 Views

When SciPy is imported, you do not need to explicitly import the NumPy functions because by default all the NumPy functions are available through SciPy namespace. But as SciPy is built upon the NumPy arrays, we must need to know the basics of NumPy.As most parts of linear algebra deals with vectors and matrices only, let us understand the basic functionalities of NumPy vectors and matrices.Creating NumPy vectors by converting Python array-like objectsLet us understand this with the help of following example−Exampleimport numpy as np list_objects = [10, 20, 30, 40, 50, 60, 70, 80, 90] array_new = np.array(list_objects) print ... Read More

Advertisements