O'Reilly logo

Python Deep Learning Cookbook by Indra den Bakker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. First, load all libraries:
import numpy as npimport pandas as pdfrom matplotlib import pyplot as pltfrom keras.models import Sequentialfrom keras.layers import Dense, Dropoutfrom keras import regularizers
  1. Import the data and extract the features:
data = pd.read_csv('Data/bike-sharing/hour.csv')# Feature engineeringohe_features = ['season', 'weathersit', 'mnth', 'hr', 'weekday']for feature in ohe_features:    dummies = pd.get_dummies(data[feature], prefix=feature, drop_first=False)    data = pd.concat([data, dummies], axis=1)drop_features = ['instant', 'dteday', 'season', 'weathersit',                   'weekday', 'atemp', 'mnth', 'workingday', 'hr', 'casual', 'registered']data = data.drop(drop_features, axis=1)
  1. Normalize numerical data:

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required