5 Simple ways to create movie recommendations using Python

Image for post
Image for post
Photo by cottonbro from Pexels

Big companies such as Netflix, Amazon, and Google use complex recommendation systems. This helps them to sell more products and to keep customers engaged.

In this article, I will show you that recommendation systems don’t have to be complicated. I will show this using Python, Pandas, and functions from the SciKit learn library.

I will use Python 3.8 with data from the MovieLens database. The source code is available on Github.

MovieLens database

To show recommendations, I will use the MovieLens data set from GroupLens Research. Instead of the full data set, I will use a subset. This subset contains 100,000 ratings, 3,600 tags applied to 9,000 movies by 600 users. …


Use Transfer Learning with TensorFlow to improve the accuracy of a model for the Kaggle Dogs vs Cats competition

Image for post
Image for post
Storming the Kaggle Cats vs Dogs Leaderboard, image by the author

While I study deep learning, I like to practice the theory by entering Kaggle competitions. Previously, I created a Convolutional Neural Network with TensorFlow to join the Cats vs. Dogs competition on Kaggle. This Convolutional Neural Network got me to place 833 on the Kaggle public leaderboard.

The accuracy of the CNN was around 90%. I want to try to improve the accuracy of my model and rise on the Kaggle leaderboard. I will use Transfer Learning to enhance my model. Transfer Learning is a technique where you reuse a model that someone else trained as your model’s starting point. …


Advanced logging features in Python using the standard logging module

Image for post
Image for post
Watching and filtering logging messages, photo by Soumil Kumar from Pexels

I work as a software developer for a company that develops climate control systems for greenhouses. These climate control systems control various aspects of a greenhouse to create an optimal climate for growing crops. We connect the system to several sensors, and the system sends the measurements of these sensors to a central location in the cloud.

The grower, our customer, can access these measurements through various dashboards that include graphs and reports. Last week, we received a customer call through the helpdesk that he did not see any new measurements come in. …


Use a Convolution Deep Neural Network to enter Kaggle’s Dogs vs Cats competition

Image for post
Image for post
Image by Snapwire from Pexels

I like to use practical examples and projects to help me memorize the theory during my study of Deep Neural Networks. An excellent resource for finding these practical projects is Kaggle. Kaggle is an online community of data scientists and machine learning practitioners.

Kaggle allows you to search and publish data sets, explore, and build models. You can perform these functions in a web-based environment. Kaggle also offers machine learning competitions with actual problems and provides prizes to the winners.

I am currently studying Deep Learning with TensorFlow. One of the subjects I want to learn is image recognition. This article describes my attempt to solve a former Kaggle competition from 2013, called “Dogs vs. Cats.” For implementing the solution I used Python 3.8 …


My first exploration of Machine learning using the Titanic competition on Kaggle

Image for post
Image for post
Louis & Lola, survivors of the Titanic disaster (Photo from Library of Congress Prints and Photographs, No known restrictions on publication)

This article describes my attempt at the Titanic Machine Learning competition on Kaggle. I have been trying to study Machine Learning but never got as far as being able to solve real-world problems. But after I read two newly released books about practical AI, I was confident enough to enter the Titanic competition.

The first part of the article describes preparing the data. The second part shows how I used a Support Vector Machine (SVM). I used the SVM to create a model that predicts the survival of the passengers of the Titanic.

The model resulted in a score of 0.779907, which got me in the top 28% of the competition. I am very happy with the result. You can find a Jupiter notebook with the solution and documentation in Github. …


Investigate health inspection results for New York City’s 27,000 restaurants using Python

Image for post
Image for post
Ruebens Style Pastrami, image by the author

A week ago, I saw a tweet from Ashley Willis (@ashleymcnamara) in which she asked, “What’s the best tech talk you’ve ever seen?”. The response was overwhelming. Make sure to check out the answers for some of the most excellent tech talks.

Since then, I have been watching some of the recommended talks. The first I saw was “Discovering Python” by David Beazley. An exceptional talk in which he uses Python to support a Patent litigation lawsuit.

As I searched for more talks by David Beazley, I found “Builtin Superheroes.” In this presentation, he used standard Python data types to analyze food inspections. …


Quickly create a list, dictionary, or set in Python without using for loops

Image for post
Image for post
A comprehensive set of turnstones, image by the author

Python offers three types of comprehensions to create basic collection data types conveniently in Python with better readability.

I will explain each type of comprehension using examples.

List Comprehensions

List Comprehensions are a different way of rapidly creating a list with Python. If you find yourself using a for loop along with .append() to create a list, List Comprehensions are an excellent alternative.

List Comprehensions have the following signature.

[expr for val in collection if condition]

You can use List Comprehensions for the following:

  • Manipulating lists
  • Extracting information
  • Filtering lists

I will explain the possibilities of List Comprehensions using four different examples. Each example shows how to implement the functionality with and without List Comprehensions. …


Feedback can be difficult. Here’s a recipe for your pull requests

Image for post
Image for post
Pull Request comments on GitHub (Image by the author)

Almost twenty years ago, I started as a developer in a company that used code reviews. At that time, I had never done a code review nor was my code ever reviewed.

For my first project, I had to create a COM component in C++ using the ATL framework. ATL uses reference counting to manage the lifetime of an object. Reference counting means that you have to call Release() when you are done using the object. If you forget to call it, it results in a memory leak.

I remember the result of my first code review as if it was yesterday. …


Handle your errors in Python like a pro

Image for post
Image for post
Error handling in Python, image by the author

When during the execution of a program, Python encounters an error, it stops. This can be caused by two types of errors, syntax errors, or exceptions. In this article, we will discuss the second, exceptions, and show how to handle, catch, and raise them.

What are Exceptions?

Exceptions are errors that Python reports when syntactically correct code executes, and an exceptional situation occurs. For example, look at the following code.

A program that raises an exception

This program tries to divide the number ten by zero, which is something that is not possible in Python.

When you execute this program, Python raises a ZeroDivisionError and terminates the application. …


How to log message in Python using the standard logging module

Image for post
Image for post
Photo by Chris Ried on Unsplash

The standard library with each Python installation contains a logging module that provides a flexible framework for logging messages. Most Python applications and libraries use this module.

There are four types of classes used when logging.

  • Loggers — exposes the interface that your application can use to log
  • Handlers — send the log messages to the appropriate destination
  • Filters — determine which messages is send to what output
  • Formatters — how is a message formatted in the final output

Loggers

To create a logger in your application or library, you can call logging.getLogger("app"). The argument "app" is the name that you choose for this logger. You can use the name of a logger to form a hierarchy by using dots in the name like 'app.module.function'. A Filter can use this hierarchy to only view messages from a specific function or module. …

About

Patrick Kalkman

I write and design software. I love to learn and teach. I am an Open-Source and Agile enthusiast.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store