Member-only story

Use sklearn’s neural network to predict on podcast listening times

Crystal X
5 min readApr 5, 2025

It doesn’t matter what I am engaged in, I always try to fit Kaggle’s monthly playground competition into my schedule. This month required the data scientist to predict the length of time that an individual would listen to a podcast.

While I have used a linear regression model to make predictions in the past I opted to try out a nonlinear model in this competition.

MLPRegressor in scikit-learn is a multi-layer perceptron (MLP) regressor, which is a type of neural network used for regression tasks. It learns complex relationships between input features and a continuous target variable.

Key Features of MLPRegressor

  • Hidden Layers: You can specify the number of hidden layers and neurons in each layer using hidden_layer_sizes=(100,), where 100 represents the number of neurons in the single hidden layer.
  • Activation Functions: Supports activation functions like ReLU, tanh, logistic, and identity.
  • Optimization Solvers: Uses Adam, SGD, or LBFGS for weight optimization.
  • Regularization: Includes L2 regularization (alpha parameter) to prevent overfitting.
  • Learning Rate: Can be constant, adaptive, or inverse scaling.

Sklearn’s MLPRegressor can be used when:-

  • The data has non-linear relationships that traditional regression models struggle with.
  • When you need a flexible model that can learn complex patterns.
  • When you have enough data to train a neural network effectively.

I haven’t used sklearn’s neural network for a while, so I thought it would be a good refresher for me to employ this model. I write the code in Python, using Kaggle’s Jupyter Notebook, and stored it in my account with Kaggle.

The first thing that I did after creating the Jupyter Notebook was to import the libraries that I would need to execute the program, being:-

  1. Numpy to perform numeric computations on the data,
  2. Pandas to perform data processing on the data,
  3. Os to go into the computer’s operating system,

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Crystal X

Written by Crystal X

I have over five decades experience in the world of work, being in fast food, the military, business, non-profits, and the healthcare sector.

No responses yet

Write a response