Found 10476 Articles for Python

How to avoid the points getting overlapped while using stripplot in categorical scatter plot Seaborn Library in Python?

AmitDiwan
Updated on 11-Dec-2020 10:23:00

1K+ Views

Visualizing data is an important step since it helps understand what is going on in the data without actually looking at the numbers and performing complicated computations. Seaborn is a library that helps in visualizing data. It comes with customized themes and a high level interface.General scatter plots, histograms, etc can’t be used when the variables that need to be worked with are categorical in nature. This is when categorical scatterplots need to be used.Plots such as ‘stripplot’, ‘swarmplot’ are used to work with categorical variables. The ‘stripplot’ function is used when atleast one of the variables is categorical. The ... Read More

What is SciPy in Python? Explain how it can be installed, and its applications?

AmitDiwan
Updated on 11-Dec-2020 10:21:48

229 Views

Data present in large amounts needs to be dealt with properly. This is why computers with large capacities are used. Scientific and technical computations of large datasets can be done with the help of a library in Python known as SciPy. SciPy is short of ‘Scientific Python’.The Numpy library in Python is a pre-requisite to SciPy because SciPy is built on top of Numpy. Ensure that Numpy library is installed before installing SciPy library. It is an open-source software that is easily available to install and use.It has many features of data science and machine learning that are required to ... Read More

How can Seaborn library be used to display kernel density estimations in Python?

AmitDiwan
Updated on 11-Dec-2020 10:20:39

112 Views

Visualizing data is an important step since it helps understand what is going on in the data without actually looking at the numbers and performing complicated computations. Seaborn is a library that helps in visualizing data. It comes with customized themes and a high-level interface.Kernel Density Estimation, also known as KDE is a method in which the probability density function of a continuous random variable can be estimated.This method is used for the analysis of the non-parametric values. While using ‘distplot’, if the argument ‘kde’ is set to True and ‘hist’ is set to False, the KDE can be visualized.Let ... Read More

How can scikit-learn library be used to load data in Python?

AmitDiwan
Updated on 11-Dec-2020 10:17:10

399 Views

Scikit-learn, commonly known as sklearn is an open-source library in Python that is used for the purpose of implementing machine learning algorithms.This includes classification, regression, clustering, dimensionality reduction, and much more with the help of a powerful, and stable interface in Python. This library is built on Numpy, SciPy and Matplotlib libraries.Let us see an example to load data −Examplefrom sklearn.datasets import load_iris my_data = load_iris() X = my_data.data y = my_data.target feature_name = my_data.feature_names target_name = my_data.target_names print("Feature names are : ", feature_name) print("Target names are : ", target_name) print("First 8 rows of the dataset are : ", X[:8])OutputFeature ... Read More

Explain the basics of scikit-learn library in Python?

AmitDiwan
Updated on 11-Dec-2020 10:16:02

389 Views

Scikit-learn, commonly known as sklearn is a library in Python that is used for the purpose of implementing machine learning algorithms.It is an open-source library hence it can be used free of cost. Powerful and robust, since it provides a wide variety of tools to perform statistical modelling. This includes classification, regression, clustering, dimensionality reduction, and much more with the help of a powerful, and stable interface in Python. This library is built on Numpy, SciPy and Matplotlib libraries.It can be installed using the ‘pip’ command as shown below −pip install scikit-learnThis library focuses on data modelling.There are many models ... Read More

Explain how Nelder-Mead algorithm can be implemented using SciPy Python?

AmitDiwan
Updated on 10-Dec-2020 13:47:25

715 Views

SciPy library can be used to perform complex scientific computations at speed, with high efficiency. Nelder-Mead algorithm is also known as simple search algorithm.It is considered to be one of the best algorithms that can be used to solve parameter estimation problems, and statistical problems. Relevant to use this algorithm in situations where the values of functions are uncertain or have lots of noise associated with it.This algorithm can also be used to work with discontinuous functions which occur frequently in statistics. It is a simple algorithm and it is easy to understand as well. Used to minimize the parameters ... Read More

Explain how the minimum of a scalar function can be found in SciPy using Python?

AmitDiwan
Updated on 10-Dec-2020 13:45:53

180 Views

Finding the minimum of a scalar function is an optimization problem. Optimization problems help improve the quality of the solution, thereby yielding better results with higher performances. Optimization problems are also used for curve fitting, root fitting, and so on.Let us see an example −Exampleimport matplotlib.pyplot as plt from scipy import optimize import numpy as np print("The function is defined") def my_func(a):    return a*2 + 20 * np.sin(a) plt.plot(a, my_func(a)) print("Plotting the graph") plt.show() print(optimize.fmin_bfgs(my_func, 0))OutputOptimization terminated successfully.    Current function value: -23.241676    Iterations: 4    Function evaluations: 18    Gradient evaluations: 6 [-1.67096375]ExplanationThe required packages are imported.A ... Read More

How can discrete Fourier transform be performed in SciPy Python?

AmitDiwan
Updated on 10-Dec-2020 13:44:39

552 Views

Discrete Fourier Transform, or DFT is a mathematical technique that helps in the conversion of spatial data into frequency data.Fast Fourier Transformation, or FTT is an algorithm that has been designed to compute the Discrete Fourier Transformation of spatial data.The spatial data is usually in the form of a multidimensional array. Frequency data refers to data that contains information about the number of signals or wavelengths in a specific period of time.Let us see how this DFT can be achieved using the ‘SciPy’ library.The graph is created using the matplotlib library and data is generated using the Numpy library −ExampleFrom ... Read More

How can SciPy be used to calculate the eigen values and eigen vectors of a matrix in Python?

AmitDiwan
Updated on 10-Dec-2020 13:42:50

2K+ Views

Eigen vectors and Eigen values find their uses in many situations. The word ‘Eigen’ in German means ‘own’ or ‘typical’. An Eigen vector is also known as a ‘characteristic vector’. Suppose we need to perform some transformation on a dataset but the given condition is that the direction of data in the dataset shouldn’t change. This is when Eigen vectors and Eigen values can be used.Given a square matrix (a matrix where the number of rows is equal to the number of columns), an Eigen value and an Eigen vector fulfil the below equation.Eigen vectors are computed after finding the ... Read More

Explain how the top ‘n’ elements can be accessed from series data structure in Python?

AmitDiwan
Updated on 10-Dec-2020 13:40:49

120 Views

We have previously used slicing with the help of operator ‘:’, which is used in the case of extracting top ‘n’ elements from series structure. It helps assign a range to the series elements that will later be displayed.Let us see an example −Example Live Demoimport pandas as pd my_data = [34, 56, 78, 90, 123, 45] my_index = ['ab', 'mn' ,'gh', 'kl', 'wq', 'az'] my_series = pd.Series(my_data, index = my_index) print("The series contains following elements") print(my_series) n = 3 print("Top 3 elements are :") print(my_series[:n])OutputThe series contains following elements ab  34 mn  56 gh  78 kl  90 wq  123 az ... Read More

Advertisements