Python Articles

Page 776 of 852

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

AmitDiwan
AmitDiwan
Updated on 11-Dec-2020 142 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
AmitDiwan
Updated on 11-Dec-2020 438 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 how Nelder-Mead algorithm can be implemented using SciPy Python?

AmitDiwan
AmitDiwan
Updated on 10-Dec-2020 784 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
AmitDiwan
Updated on 10-Dec-2020 227 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 scikit learn library be used to preprocess data in Python?

AmitDiwan
AmitDiwan
Updated on 10-Dec-2020 361 Views

Pre-processing data refers to cleaning of data, removing invalid data, noise, replacing data with relevant values and so on.This doesn’t always mean text data; it could also be images or video processing as well. It is an important step in the machine learning pipeline.Data pre-processing basically refers to the task of gathering all the data (which is collected from various resources or a single resource) into a common format or into uniform datasets (depending on the type of data).This is done so that the learning algorithm can learn from this dataset and give relevant results with high accuracy. Since real-world ...

Read More

How can decision tree be used to construct a classifier in Python?

AmitDiwan
AmitDiwan
Updated on 10-Dec-2020 232 Views

Decision tree is the basic building block of the random forest algorithm. It is considered as one of the most popular algorithms in machine learning and is used for classification purposes. They are extremely popular because they are easy to understand.The decision given out by a decision tree can be used to explain why a certain prediction was made. This means the in and out of the process would be clear to the user.They are also a foundation for ensemble methods such as bagging, random forests, and gradient boosting. They are also known as CART, i.e. Classification And Regression Trees. ...

Read More

How to view the pixel values of an image using scikit-learn in Python?

AmitDiwan
AmitDiwan
Updated on 10-Dec-2020 784 Views

Data pre-processing basically refers to the task of gathering all the data (which is collected from various resources or a single resource) into a common format or into uniform datasets (depending on the type of data).Since real-world data is never ideal, there is a possibility that the data would have missing cells, errors, outliers, discrepancies in columns, and much more.Sometimes, images may not be correctly aligned, or may not be clear or may have a very large size. The goal of pre-processing is to remove these discrepancies and errors.To get the pixels of an image, a built-in function named ‘flatten’ ...

Read More

How can scikit-learn library be used to get the resolution of an image in Python?

AmitDiwan
AmitDiwan
Updated on 10-Dec-2020 490 Views

Data pre-processing basically refers to the task of gathering all the data (which is collected from various resources or a single resource) into a common format or into uniform datasets (depending on the type of data). Since real-world data is never ideal, there is a possibility that the data would have missing cells, errors, outliers, discrepancies in columns, and much more. Sometimes, images may not be correctly aligned, or may not be clear or may have a very large size. The goal of pre-processing is to remove these discrepancies and errors.To get the resolution of an image, a built-in function ...

Read More

Python - Join tuple elements in a list

Hafeezul Kareem
Hafeezul Kareem
Updated on 13-Nov-2020 11K+ Views

In this article, we are going to learn how to join tuple elements in a list. It's a straightforward thing using join and map methods. Follow the below steps to complete the task.Initialize list with tuples that contain strings.Write a function called join_tuple_string that takes a tuple as arguments and return a string.Join the tuples in the list using map(join_tuple_string, list) method.Convert the result to list.Print the result.Example# initializing the list with tuples string_tuples = [('A', 'B', 'C'), ('Tutorialspoint', 'is a', 'popular', 'site', 'for tech learnings')] # function that converts tuple to string def join_tuple_string(strings_tuple) -> str:    return ...

Read More

Linear search on list or tuples in Python

Hafeezul Kareem
Hafeezul Kareem
Updated on 13-Nov-2020 4K+ Views

In this article, we are going to learn how to apply a linear search on lists and tuples.A linear search starts searching from the first element and goes till the end of the list or tuple. It stops checking whenever it finds the required element.Linear Search - Lists & TuplesFollow the below steps to implement linear search on lists and tuples.Initialize the list or tuple and an element.Iterate over the list or tuple and check for the element.Break the loop whenever you find the element and mark a flag.Print element not found message based on the flag.ExampleLet's see the code.# ...

Read More
Showing 7751–7760 of 8,519 articles
« Prev 1 774 775 776 777 778 852 Next »
Advertisements