Skip to content
Home » python » Page 5

python

Solving “set_params() takes 1 positional argument but 2 were given”

  • by
  • 2 min read

Brief blog post on a silly Python error. I’m still working on my ML project started hypertuning my sklearn pipeline — manually. To set the parameters of my pipeline in every iteration, I had to use set_params. My estimator is called model_pipeline and I needed to set the parameters via… 

Pandas: Solve ‘You are trying to merge on object and float64 columns’

Pandas can be somewhat puzzling, sometimes. It has a ton load of functionalities, but that can make the syntax and methods obscure. Simply judging from the method name, the ‘join’ and ‘merge’ method could be the same thing. However, they aren’t. Here’s an error that I used to run into… 

Solve “columns overlap but no suffix specified” in Pandas

Surprisingly, the Pandas error “columns overlap but no suffix specified”, is one I ran into surprisingly late. Solving it is usually very straightforward. We’ll tackle it in this blog post. First, let’s take a closer look at the error: “ValueError: columns overlap but no suffix specified: Index([<list of columns>], dtype=’object’)”… 

Solving “Found unknown categories […] in column” with sklearn OneHotEncoder

In this short blog post, I tackle an error related to a classic problem within machine learning: how to treat unseen categorical values and solve the “found unknown categories” error. Imagine you have a train and a test data set with the following values in a column: Train: [‘green’, ‘red’,… 

Undersampling a Pandas DataFrame

  • by
  • 2 min read

In a previous post, I explained how you can sample two Pandas DataFrame exactly the same way. In this blog post, I want to use that helper function to undersample your predictors and target variable. When you are working with an imbalanced data set, it’s often good practice to under-…