La forma más pitónica de comparar dos listas en Python

Problema: Se dan dos listas l1 y l2. Quieres realizar una de las siguientes acciones: 1. Comparación booleana: comparar las listas por elementos y devolver True si la métrica de comparación devuelve True para todos los pares de elementos y False en caso contrario. 2. Diferencia: encontrar la diferencia entre los elementos de la primera … Read more

Cómo convertir una lista de enteros en una lista de cadenas en Python

English version of article (English): https://blog.finxter.com/how-to-convert-an-integer-list-to-a-string-list-in-python/ La forma más pitónica de convertir una lista de enteros ints en una lista de cadenas es usar el código de una línea strings = [str(x) for x in ints]. Recorre todos los elementos de la lista ints y convierte cada elemento de la lista x en una cadena … Read more

Python Palindromes One-Liner

This one-liner introduces another basic computer science term: palindromes. Similar to anagrams, palindromes are a popular coding interview question. First things first: What is a Palindrome? “A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward, such as madam or racecar or the number 10201.“ [source] … Read more

Cómo convertir una lista de cadenas en una lista de números en coma flotante (flotantes) en Python

La forma más pitónica de convertir una lista de cadenas en una lista de flotantes es usar una comprensión de listas floats = [float(x) for x in strings]. Recorre todos los elementos de la lista y convierte cada elemento de la lista x en un flotante utilizando la función incorporada float(x). Este artículo muestra las … Read more

Python Anagrams in One Line Python

Why Learning about Python Anagrams? A popular question in programming interviews is to create an anagram checker. The interviewer wants to test your knowledge about the basic terminology in computer science, and how good you are at developing your own simple algorithms to solve the problems you are facing. In this article, you’ll learn about … Read more

How to Print Without Newline in Python—A Simple Illustrated Guide

Summary: To print without the newline character in Python 3, set the end argument in the print() function to the empty string or the single whitespace character. This ensures that there won’t be a newline in the standard output after each execution of print(). Alternatively, unpack the iterable into the print() function to avoid the … Read more

People Who Bought X Also Bought …? An Introduction to NumPy Association Analysis

Imagine you are Jeff Bezos. One of the most successful features of your company Amazon is product recommendation. “People who bought X also bought Y.” Roughly speaking, this feature alone has made you billions. For you, Jeff Bezos, product recommendation is the most important algorithm in the world, isn’t it? In this article, you’ll learn … Read more

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. Linear Regression Background Let’s review linear regression. Given the training data, we compute a line that fits this training data so that … Read more

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

K-Nearest Neighbors (KNN) with sklearn in Python

The popular K-Nearest Neighbors (KNN) algorithm is used for regression and classification in many applications such as recommender systems, image classification, and financial data forecasting. It is the basis of many advanced machine learning techniques (e.g., in information retrieval). There is no doubt that understanding KNN is an important building block of your proficient computer … Read more

Python Linear Regression with sklearn – A Helpful Illustrated Guide

Machine Learning Linear Regression Python

? This tutorial will show you the most simple and straightforward way to implement linear regression in Python—by using scikit-learn’s linear regression functionality. I have written this tutorial as part of my book Python One-Liners where I present how expert coders accomplish a lot in a little bit of code. Feel free to bookmark and download … Read more