Python tutorials

Overview of Classification Methods in Python with Scikit-Learn

Introduction Are you a Python programmer looking to get into machine learning? An excellent place to start your journey is by getting acquainted with Scikit-Learn. Doing some classification with Scikit-Learn is a straightforward and simple way to start applying what you’ve learned, to make machine learning concepts concrete by implementing them with a user-friendly, well-documented, and robust library. What is Scikit-Learn? Scikit-Learn is a library for Python that was first developed by David Cournapeau in 2007. It contains a range […]

Read more

Test Driven Development with pytest

Introduction Good software is tested software. Testing our code can help us catch bugs or unwanted behavior. Test Driven Development (TDD) is a software development practice that requires us to incrementally write tests for features we want to add. It leverages automated testing suites, like pytest – a testing framework for Python programs. Automated Testing Developers usually write code, compile it if necessary, and then run the code to see if it works. This is an example of manual testing. […]

Read more

Python for NLP: Working with the Gensim Library (Part 1)

This is the 10th article in my series of articles on Python for NLP. In my previous article, I explained how the StanfordCoreNLP library can be used to perform different NLP tasks. In this article, we will explore the Gensim library, which is another extremely useful NLP library for Python. Gensim was primarily developed for topic modeling. However, it now supports a variety of other NLP tasks such as converting words to vectors (word2vec), document to vectors (doc2vec), finding text […]

Read more

Introduction to Reinforcement Learning with Python

Introduction Reinforcement Learning is definitely one of the most active and stimulating areas of research in AI. The interest in this field grew exponentially over the last couple of years, following great (and greatly publicized) advances, such as DeepMind’s AlphaGo beating the word champion of GO, and OpenAI AI models beating professional DOTA players. Thanks to all of these advances, Reinforcement Learning is now being applied in a variety of different fields, from healthcare to finance, from chemistry to resource […]

Read more

Working with PDFs in Python: Adding Images and Watermarks

This article is the second in a series on working with PDFs in Python: Introduction Today, a world without the Portable Document Format (PDF) seems to be unthinkable. It has become one of the most commonly used data formats ever. Up to PDF version 1.4, displaying a PDF document in an according PDF viewer works fine. Unfortunately, the features from the newer PDF revisions, such as forms, are tricky to implement, and still require further work to be fully functional […]

Read more

Python for NLP: Working with the Gensim Library (Part 2)

This is my 11th article in the series of articles on Python for NLP and 2nd article on the Gensim library in this series. In a previous article, I provided a brief introduction to Python’s Gensim library. I explained how we can create dictionaries that map words to their corresponding numeric Ids. We further discussed how to create a bag of words corpus from dictionaries. In this article, we will study how we can perform topic modeling using the Gensim […]

Read more

Brief Introduction to OpenGL in Python with PyOpenGL

Introduction In this tutorial, we’re going to learn how to use PyOpenGL library in Python. OpenGL is a graphics library which is supported by multiple platforms including Windows, Linux, and MacOS, and is available for use in multiple other languages as well; however, the scope of this post will be limited to its usage in the Python programming language. OpenGL, as compared to other similar graphics libraries, is fairly simple. We’ll start with setting it up on our system, followed […]

Read more

Overview of Async IO in Python 3.7

Python 3’s asyncio module provides fundamental tools for implementing asynchronous I/O in Python. It was introduced in Python 3.4, and with each subsequent minor release, the module has evolved significantly. This tutorial contains a general overview of the asynchronous paradigm, and how it’s implemented in Python 3.7. Blocking vs Non-Blocking I/O The problem that asynchrony seeks to resolve is blocking I/O. By default, when your program accesses data from an I/O source, it waits for that operation to complete before […]

Read more

Python: Append Contents to a File

In this article, we’ll examine how to append content to an existing file using Python. Let’s say we have a file called helloworld.txt containing the text “Hello world!” and it is sitting in our current working directory on a Unix file system: $ cat ./helloworld.txt Hello world! Now assume we want to append the additional text “It’s good to have been born!” to the end of this file from a Python program. The first step is to obtain a reference […]

Read more

Python: Check if String Contains Substring

In this article, we’ll examine four ways to use Python to check whether a string contains a substring. Each has their own use-cases and pros/cons, some of which we’ll briefly cover here: 1) The in Operator The easiest way to check if a Python string contains a substring is to use the in operator. The in operator is used to check data structures for membership in Python. It returns a Boolean (either True or False) and can be used as […]

Read more
1 145 146 147 148 149 172