[Collection] All Finxter Articles and Tutorials

How to Classify Star Wars Lego Images using CNN and Transfer Learning

This tutorial is about training deep learning (DL) models to classify Star Wars Lego images. We use the TensorFlow library to create and compare the image classifiers. Are you looking for interesting deep learning projects that are suitable for beginners? Do not worry, this is not another MNIST image classification tutorial. Instead, we are going

​Read More
How to Classify Star Wars Lego Images using CNN and Transfer Learning

A Simple Guide To Remove Multiple Spaces In A String

Table of Contents Introduction🔦Method 1: Using Regular Expressions📌re.sub()🔦Method 2: Using The split() Method🔦Method 3: Using The replace() Method🔦Method 4: Using A For LoopConclusionRelated Posts Introduction Have you ever come across strings in Python that have unnecessary spacing between the words or characters? If so then you are at the correct place to find the solutions

​Read More
A Simple Guide To Remove Multiple Spaces In A String

Logistic Regression in Python Scikit-Learn

Logistic regression is a popular algorithm for classification problems (despite its name indicating that it is a “regression” algorithm). It belongs to one of the most important algorithms in the machine learning space. Table of Contents Linear Regression BackgroundLogistic Regression and Sigmoid FunctionLogistic Regression with sklearn.linear_modelLogisticsRegression MethodsConclusionPython One-Liners Book: Master the Single Line First!Related Posts

​Read More
Logistic Regression in Python Scikit-Learn

Random Forest Classifier with sklearn

Does your model’s prediction accuracy suck but you need to meet the deadline at all costs? Try the quick and dirty “meta-learning” approach called ensemble learning. In this article, you’ll learn about a specific ensemble learning technique called random forests that combines the predictions (or classifications) of multiple machine learning algorithms. In many cases, it

​Read More
Random Forest Classifier with sklearn

[Google Interview] How To Find The Majority Element In An Array?

Company Tags: Google, Amazon, Yahoo, Microsoft This is one of the Google interview questions and one of the most commonly asked questions during many interviews. So, can you give the optimal solution to this problem? Table of Contents Problem Formulation📖Examples🖊️Method 1: Brute Force Approach🖊️Method 2: Using A Python Dictionary🖊️Optimized Solution: Boyer–Moore Majority Vote AlgorithmConclusionRelated Posts Problem

​Read More
[Google Interview] How To Find The Majority Element In An Array?

What Are Differences Between type() and isinstance()?

The main difference between type() and isinstance() is that type(object) returns the type of an object and isinstance(object, class) returns True if the object argument is an instance of the class argument or in a direct or indirect subclass relationship. To strengthen your understanding, let’s quickly recap the syntactical definitions of both functions: type(object) –

​Read More
What Are Differences Between type() and isinstance()?

SVM sklearn: Python Support Vector Machines Made Simple

Support Vector Machines (SVM) have gained huge popularity in recent years. The reason is their robust classification performance – even in high-dimensional spaces: SVMs even work if there are more dimensions (features) than data items. This is unusual for classification algorithms because of the curse of dimensionality – with increasing dimensionality, data becomes extremely sparse

​Read More
SVM sklearn: Python Support Vector Machines Made Simple

Python Bitwise NOT Operator

Python’s bitwise NOT operator ~x inverts each bit from the binary representation of integer x so that 0 becomes 1 and 1 becomes 0. This is semantically the same as calculating ~x == -x-1. For example, the bitwise NOT expression ~0 becomes -1, ~9 becomes -10, and ~32 becomes -33. As you go over the

​Read More
Python Bitwise NOT Operator

How to Convert a Boolean Array to an Integer Array in Python?

Table of Contents Problem FormulationMethod 1: Don’t Do ItMethod 2: Multiplication with 1Method 3: Use array.astype(int)Related Posts Problem Formulation Given a NumPy array consisting of Boolean values. How to convert it to an integer array? Convert each True value to integer 1, and Convet each False value to integer 0. Here’s an example Boolean array:

​Read More
How to Convert a Boolean Array to an Integer Array in Python?

Python’s time.clock() Vs. time.time() – A Detailed Comparison

Table of Contents Introduction⏰time.time()⏰time.clock()➥Difference In Execution Speed✨REMEMBER: Benchmarking in Python❖ The timeit Module ConclusionRelated Posts Introduction Before we get into the detailed comparison between time.clock() vs. time.time(), there are some prerequisites that you need to focus upon. It is important to have knowledge about the various types of time in the computing world. Don’t worry if

​Read More
Python’s time.clock() Vs. time.time() – A Detailed Comparison

How to Remove Control Characters from a String in Python?

Table of Contents Problem FormulationWhat is a Control Character?Solution Based on Unicode CategoryRelated Posts Problem Formulation Given a string s. Create a new string based on s with all control characters such as ‘\n’ and ‘\t’ removed. What is a Control Character? A control character, also called non-printing character (NPC), is a character that doesn’t

​Read More
How to Remove Control Characters from a String in Python?

Python Delete File [Ultimate Guide]

Table of Contents Python Delete FilePython Delete Files in FolderPython Delete File shutilPython Delete Files WildcardPython Delete Files in Folder with ExtensionRelated Posts Python Delete File To delete a file in Python, import the os module with import os and run os.remove(filename) in your script. The following code removes the file ‘file.dat’ from the current

​Read More
Python Delete File [Ultimate Guide]

Как преобразовать строку Юникода в строковый объект в Питоне?

Это руководство покажет вам, как преобразовать строку Юникода в строку в Питоне. Если вы уже знаете о Юникоде, вы можете пропустить следующий раздел, посвященный справочной информации, и сразу же погрузиться в проблему. Table of Contents Истоки ЮникодаФормулировка проблемыМетод 1. StringМетод 2. Repr()Метод 3. Модуль Unicodedata, функция normalizeМетод 4. Список и str.joinМетод 5. Библиотека ftfyМетод 6.

​Read More
Как преобразовать строку Юникода в строковый объект в Питоне?

Python Convert Unicode to Int, Python Convert Unicode to Float

In the previous article, we got acquainted with Unicode and methods of processing input Unicode strings, different ways of processing and converting them into a readable form – string objects in Python. Let’s look at ways of converting to other types of output data and applying different encodings to them. Table of Contents Problem FormulationFunction

​Read More
Python Convert Unicode to Int, Python Convert Unicode to Float

Конвертация символов Юникода в целое число и число с плавающей точкой в Питоне

В предыдущей статье мы познакомились с Юникодом и способами обработки входных юникодных строк, разным способам обработки и преобразования их в читаемый вид – объекты типа стринг в Питоне. Рассмотрим способы преобразования в другие типы выходных данных и применение различных кодировок к ним. Table of Contents Формулировка задачиФункция ord.Конвертация символов Юникода в число с плавающей точкойФункция

​Read More
Конвертация символов Юникода в целое число и число с плавающей точкой в Питоне

Python Convert Unicode to Bytes, ASCII, UTF-8, Raw String

Table of Contents Python Convert Unicode to BytesMethod 1 Built-in function bytes()Method 2 Built-in function encode()Python Convert Unicode to ASCIIMethod 1 Built-in function decode()Method 2 Module unidecode()Python Convert Unicode to UTF-8Method 1 Built-in function encode() and decode()Method 2 Module unidecodeRelated Posts Python Convert Unicode to Bytes Converting Unicode strings to bytes is quite common these

​Read More
Python Convert Unicode to Bytes, ASCII, UTF-8, Raw String

How to Count the Number of Occurrences of a Character in a Python String?

Table of Contents Problem FormulationMethod 1: str.count()Method 2: Regular ExpressionMethod 3: List Comprehension + len()Related Posts Problem Formulation Given a string s, and Given a character c. How many times does character c occur in the string s? Consider the following examples: INPUT s = ‘hello world’ c = ‘l’ OUTPUT 3 INPUT s =

​Read More
How to Count the Number of Occurrences of a Character in a Python String?

How to Return Dictionary Keys as a List in Python?

Short answer: use the expression list(dict.keys()). Table of Contents Problem FormulationSolutionAlternative Solution with UnpackingPython One-Liners Book: Master the Single Line First!Related Posts Problem Formulation Given a dictionary that maps keys to values. Return the keys as a list. For example: Given dictionary {‘Alice’: 18, ‘Bob’, 21, ‘Carl’: 24} Return the keys as a list [‘Alice’,

​Read More
How to Return Dictionary Keys as a List in Python?

How to Concatenate Two NumPy Arrays?

Table of Contents Problem FormulationMethod 1: np.concatenate()Method 2: np.append()Method 3: np.vstack()ConclusionRelated Posts Problem Formulation Given two NumPy arrays a and b. How to concatenate both? Method 1: np.concatenate() NumPy’s concatenate() method joins a sequence of arrays along an existing axis. The first couple of comma-separated array arguments are joined. If you use the axis argument,

​Read More
How to Concatenate Two NumPy Arrays?

Python Not Operator

Python’s not operator returns True if the single operand evaluates to False, and returns False if it evaluates to True. Thus, it logically negates the implicit or explicit Boolean value of the operand. As you read through the article, you can also watch my video for supporting explanations: Table of Contents Python Not Operator on

​Read More
Python Not Operator

Reverse A Linked List In Python

#Approach 1: Iterative Approach to Reverse Linked List Test Cases: # Example 1 linked_list = Solution() linked_list.push(5) linked_list.push(4) linked_list.push(3) linked_list.push(2) linked_list.push(1) Output: Given linked list 1 2 3 4 5 Reversed linked list 5 4 3 2 1 # Example 2 linked_list = Solution() linked_list.push(5) linked_list.push(4) linked_list.push(3) linked_list.push(2) linked_list.push(1) Output: Given linked list 1 2

​Read More
Reverse A Linked List In Python

[Solved] TypeError: method() takes 1 positional argument but 2 were given

From teaching hundreds of thousands of students Python, I found this error to be a classic. I think understanding classes is hard enough, but many coders who’ve just started to learn about Python are rightly confused 😖 about the TypeError that complains about too few positional arguments. Let’s resolve this confusion once and for all,

​Read More
[Solved] TypeError: method() takes 1 positional argument but 2 were given