LoginSignup
0
0

More than 3 years have passed since last update.

mglearn citibike datasetを使ってみる

Last updated at Posted at 2021-04-20

mglearn citibikeというデータセットがある。

scikit-learnからロードできる。。


import mglearn
citibike = mglearn.datasets.load_citibike()
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

plt.figure(figsize=(24, 8), dpi=50)
xticks = pd.date_range(start=citibike.index.min(), end=citibike.index.max(),
                       freq='D')
plt.xticks(xticks, xticks.strftime("%a %m-%d"), rotation=90, ha="left")
plt.plot(citibike, linewidth=1)
plt.xlabel("Date")
plt.ylabel("Rentals")

ダウンロード (21).png

ついでに、季節変動を取り除いてみる。。


import statsmodels.api as sm
res = sm.tsa.seasonal_decompose(citibike, freq=7)

plt.rcParams["figure.figsize"] = (14, 6)
plt.figure(figsize=(24, 8), dpi=50)
res.plot()

ダウンロード (22).png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0