Introducing Python libraries and Their Applications
You do not need to know programming languages to introduce Python libraries.
Python libraries, if you are not a programmer or computer student. But you should definitely appreciate them for all the apps you use throughout the day.
Because of them, every application and website or many of the technologies you use are built with programming languages.
This article aims to provide an overview of the Python programming language , its libraries and their applications. If you’re a techie, you’ve probably heard of the Python programming language. This language is one of the best programming languages in the world today (the following article is suitable for those who want to learn more about Python or learn about Python libraries).
Introducing Python
- Python is a high-level programming language (languages that are closer to human language and somewhat simpler)
- All-purpose (with Python you can program for any device)
- Open source (you can modify it and provide a better version)
- It is object-oriented (languages that are made according to the laws of our world, such as having an object and object properties).
Python is extremely simple and has countless libraries (through these libraries that you can create applications for both mobile and PC). Python is also used for information security.
Another important feature of Python is its simplicity and high readability. This high readability puts you very ahead in teamwork. The code in Python is short and high-yielding. The big companies that use Python are Google, NASA, and Yahoo (we just gave a brief introduction to Python to get to the Python libraries faster).
TensorFlow TensorFlow
If you are working on a machine learning project (machine learning or machine learning means giving machine learning capabilities, whether software or vehicles), you must have heard the name TensorFlow.
It is one of the best machine learning libraries in Python (there are many libraries for machine learning in Python and that is why Python is the first choice for those who want to work with machine learning) TensorFlow by Google and Brain Team is built and is open source (the tensor is used in almost all Google machine learning applications).
This library is also used for deep learning purposes (a sub-branch of machine learning) and numerical calculations.
Where is the flow tensor used?
You are using Flow Tensor on a daily basis, although indirectly, applications such as GoogleVoice and GooglePhotos have been developed by this library.
Django
In the following article, we talked about the Python programming language and mentioned that Python is a general-purpose programming language, which means that you can write software for all operating systems with Python.
Python is all-purpose thanks to its libraries. Django is a Python framework for web site design, if you want to design a website with Python.
Django is the first choice (there are many tutorials for this framework) if you want to build a website in Python environment, or even a site content management system or a personal blog and web application use this framework.
Skate Lrn Scikit-learn
Scikit-learn is one of the most popular car learning libraries in Python. This library includes simple and efficient tools for data mining and data analysis. The applications of SkateLearn include the following:
- Classification: Specify which category an object belongs to
- Regression: Predicts a consistently valuable attribute associated with an object
- Clustering: Automatically group similar objects into one set
- Dimension reduction: reducing the number of random variables to handle; If the concepts are not clear to you, it is because you do not know anything about the scientific concepts of Python and the learning machine.
- Model selection: comparison, validation and selection of parameters and models
- Pre-processing: feature extraction and normalization
These were some of the uses of this efficient library. Here is an example code to get acquainted with the structure of Python and of course part of this library:
Demo of the hierarchical clustering of the structured section on the coin image:
The division of a two-dimensional image is calculated by Ward hierarchical clustering. Clustering is spatially limited so that each area is divided into one piece.
(If you do not understand something, it is because you are not familiar with specialized concepts. This example is given from the website https://scikit-learn.org).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | print(__doc__) import time as time import numpy as np from distutils.version import LooseVersion from scipy.ndimage.filters import gaussian_filter import matplotlib.pyplot as plt import skimage from skimage.data import coins from skimage.transform import rescale from sklearn.feature_extraction.image import grid_to_graph from sklearn.cluster import AgglomerativeClustering # these were introduced in skimage-0.14 if LooseVersion(skimage.__version__) >= ‘0.14’: rescale_params = {‘anti_aliasing’: False, ‘multichannel’: False} else: rescale_params = {} # Generate dataorig_coins = coins() smoothened_coins = gaussian_filter(orig_coins, sigma=2) rescaled_coins = rescale(smoothened_coins, 0.2, mode=“reflect”, **rescale_params) X = np.reshape(rescaled_coins, (–1, 1)) # Define the structure A of the data. Pixels connected to their neighbors. connectivity = grid_to_graph(*rescaled_coins.shape) # Compute clustering print(“Compute structured hierarchical clustering…”) st = time.time() n_clusters = 27 # number of regions ward = AgglomerativeClustering(n_clusters=n_clusters, linkage=‘ward’, connectivity=connectivity) ward.fit(X) label = np.reshape(ward.labels_, rescaled_coins.shape) print(“Elapsed time: “, time.time() – st) print(“Number of pixels: “, label.size) print(“Number of clusters: “, np.unique(label).size) # Plot the results on an image plt.figure(figsize=(5, 5)) plt.imshow(rescaled_coins, cmap=plt.cm.gray) for l in range(n_clusters): plt.contour(label == l, colors=[plt.cm.nipy_spectral(l / float(n_clusters)), ]) plt.xticks(()) plt.yticks(()) plt.show() |
In this example, several different libraries are used. This example is related to the clustering discussion in SkateLearn and is just to familiarize you with a sample code in Python and use libraries. Of course, you will find many examples, large and small, on the Internet.
Pendulum Library
A little distance from the learning machine and its libraries. Penulum is a library of time and history. With this library you will be able to use the time zone, time and date to deliver all the work related to the date, days, weeks and time you want to do in a programming language Pendulum Brought by Python.
Selnium Library
Another popular Python framework for web design. You can use this library to do a lot of web design operations with a bit of coding, that is, things like filling out forms, logging in or opening a web page, and این this framework can do for you.
Pillow Library
Pillow is one of the best Python programming language libraries. For image processing (part of computer science, which refers to the two main parts of machine vision and image improvement).
In simple terms, image processing means performing some operations using algorithms on digital images) and any work with the image is used. Pilot applications in the Python programming language include image saving, image resizing, image cropping, image rotation, image reading and display, image enhancement, filtering over the image (important crystal filters, painted, sharp, smooth and edge finding). Is) and شود becomes.
The following is an example of Pilo code in the Python programming language (to understand the uses of this library, it is necessary to give some examples with coding, please practice the examples and get the output):
Reading and displaying the image: In the first line of code, we used the Pilo library for the operation on the image. In the second line, we opened a photo called beautiful and transferred it to the image to be ready for the rest of the operation. We showed
1 2 3 | from PIL import Image image = Image.open(“sample.jpg”) image.show() |
Save the image
In Python, in order for the changes to take effect, we must save them. Below, we have saved the image using the save function
1 | image.save(“sample.png”) |
size change
In the first line, resize the image code to 200 by 200 and put it in resized_img and then save it.
1 2 | image = image.resize((200,200)) image.save(“sample.jpg”) |
Photo filter
In the first line of the code, we use the Pilo library for the filter operation on the image.
In fact, we call this part of the library and in the second line, we apply the crystal filter on an image and put it in the image variable.
And in the third line, we save the image.
1 2 3 | from PIL import ImageFilter image = Image.filter(ImageFilter.BLUR) image.save(“sample.jpg”) |
PyMongo Library
One of the most important Python libraries is Python for working with the MongoDB database. Databases have the task of storing, inserting, deleting and updating information that is immediately available whenever the user requests the information. This valuable library is free and has many uses in Python and database discussion. MongoDB is a very convenient database. It is valuable, it has speed, power, flexibility and scalability, and one of the great features of Python programming language is the ability to connect to all databases in the world.
PyGame Library
So far we have talked about many libraries in Python and their applications, but now it’s time for one of the Python game libraries, most of the Python libraries are related to machine learning discussions, data science , data mining and more. But in any programming language, of course, we need game engines and rich libraries. PyGame is one of those libraries.
PyGame is known as a Python game engine that video game makers use to build games in Python. This is an open source game engine like many other Python libraries (this feature is very valuable in the software world) One of the important applications of PyGame is rendering source code, which is very easy in this library.
Other applications include sprite management and control of incoming events. It should also be noted that PyGame can be used to build games for various operating systems, including Android.
PyWin32 Library
Python is an all-purpose language. You can write with it all kinds of applications for different operating systems. One of these important operating systems is Windows. The first way is to create a program for Windows using programming languages like C # that Microsoft made.
But if you want a simpler language, Python is a better choice, and of course to access more hardware you have to use very difficult languages like C and C ++, which Python is extremely simple compared to.
Python has many libraries for Windows PyWin32 is one of them If you want to write system programs and communicate with lower levels of Windows PyWin32 helps you in this task Using this library you can easily manage the hardware do.