How to Save and Load Machine Learning Models in Python

In this tutorial, you will learn –  How to create a basic linear regression model How to save and load an ML model using Pickle module How to save and load an ML model using Joblib module Background and Motivation Over the past years, Machine Learning (ML) has grown in importance with easy access to … Read more

Python TypeError: ‘dict_values’ Not Subscriptable (Fix This Stupid Bug)

Do you encounter the following error message? TypeError: ‘dict_values’ object is not subscriptable You’re not alone! This short tutorial will show you why this error occurs, how to fix it, and how to never make the same mistake again. So, let’s get started! Solution Python raises the “TypeError: ‘dict_values’ object is not subscriptable” if you … Read more

Python TypeError: ‘dict_keys’ Not Subscriptable (Fix This Stupid Bug)

Do you encounter the following error message? TypeError: ‘dict_keys’ object is not subscriptable You’re not alone! This short tutorial will show you why this error occurs, how to fix it, and how to never make the same mistake again. So, let’s get started! Solution Python raises the “TypeError: ‘dict_keys’ object is not subscriptable” if you … Read more

How to use range(len()) in Python?

Problem Formulation Have you come across the usage of range(len()) while trying to iterate across all the items of a given iterable? Now, this brings up a couple of questions – (i) Why do we use range(len())? (ii) How do we use range(len())? πŸ“Solution Generally, range(len()) allows you to iterate across a given iterable/sequence to … Read more

Python – Return NumPy Array From Function

Do you need to create a function that returns a NumPy array but you don’t know how? No worries, in sixty seconds, you’ll know! Go! πŸš€ A Python function can return any object such as a NumPy Array. To return an array, first create the array object within the function body, assign it to a … Read more

Python Return String From Function

Do you need to create a function that returns a string but you don’t know how? No worries, in sixty seconds, you’ll know! Go! πŸš€ A Python function can return any object such as a string. To return a string, create the string object within the function body, assign it to a variable my_string, and … Read more