Article
Checking whether a string contains a substring aids to generalize conditionals and create more flexible code. Additionally, depending on your domain model - checking if a string contains a substring may also allow you to infer fields of an object, if a string encodes a field in itself. In this...
Jacob Stopak
In Python, functions are objects: they can be assigned to variables, can be returned from other functions, stored in lists or dicts and passed as parameters for other functions. Consider, for example, the map() built-in function. Its syntax is map(function, iterable) and it is used to handily apply function...
Felipe Antunes
Python's json library has many utilities for encoding and decoding data in JSON format. In particular, the json.load() method decodes an JSON read as a file, and the json.loads() decode an JSON read as a string. In general, when decoding JSON files, the data is converted to Python...
Byte
Tree-based models have become a popular choice for Machine Learning, not only due to their results, and the need for fewer transformations when working with data (due to robustness to input and scale invariance), but also because there is a way to take a peek inside of them to see...
Cássia Sampaio
NumPy (oftentimes also written as Numpy) is a linear algebra library, which is the basis for most of the scientific computing done in Python. Most libraries for data science, analysis and machine learning are built on top of NumPy as the basis for linear algebra, and also have tight coupling...
Dictionaries in Python are an implementation of hash tables: a data structure on which data is labeled by a key-value. This data structure is efficient for looking up data by its key, with an expected O(1) lookup time. It is important to keep in mind that dict objects are...
The switch statement is a powerful and convenient tool for controlling the flow of your program. It allows you to quickly and easily create multiple branches of code, depending on the value of a given variable or expression. It's commonly used when you need to execute different logic depending on...
Guest Contributor
Decision trees are widely used in machine learning problems. We'll assume you are already familiar with the concept of decision trees and you've just trained your tree based algorithm! Advice: If not, you can read our in-depth guide on "Decision Trees in Python with Scikit-Learn guide". Now, it...
Python dict objects have many useful methods for handling data. One method that is useful for accessing data and converting it to a list of tuples is the dict.items() method. my_data = { "Joe": 1, "Jane" : 2, "Alice" : 3, "Bob" : 4 } print(...
© 2013-2025 Stack Abuse. All rights reserved.