10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

無料の時系列データまとめ#1

Last updated at Posted at 2019-09-19

最近,時系列データを用いた予測,クラスタリングや異常検知の手法検討を始めたため,無料で入手できる時系列データベースをまとめました.
二次利用ができるかどうか等は,それぞれのデータの規約をご確認ください.

脳波の時系列データ

2015年のkaggleのコンペディションで, 脳波から人の動作を予測するものがありました.
脳波データと動作のイベントデータが存在するため, 時系列予測だけではなくクラスタリングや異常検知の例にも使えます.
十分に学習可能なデータ量があり,多次元の時系列データであることも良い点です.

コンペのリンク : https://www.kaggle.com/c/grasp-and-lift-eeg-detection/

kaggleへの登録とコンペへの参加をするとデータが入手できます.

UEA & UCR Time Series Classification Repository

時系列データのクラスタリングように整備されたデータベースです.
データの中には,

  1. 心電図のデータ
  2. 自動車やロボットのセンサーデータ
  3. デジタルペンを使って書くときのモーションデータ

など,様々なデータがあります.

学習データが少ない場合があるので,注意が必要です.

リンクhttp://www.timeseriesclassification.com/dataset.php

為替データ(注文もできます)

時系列解析を始めた人が一度は夢見るのはFXでいい予測をして,お金をもうけることだと思います.
OANDAというFX業者がAPIを公開しています.
そのAPIを使って為替データを取得しましょう!!
さらに,このAPIを使って,python上で注文もできます.

  1. OANDAでデモ口座を登録する(本当にお金を動かしたい人は正式な口座を開設してください.)
  2. デモ口座のacount IDとaccess_tokenを取得
  3. pip install oandapyV20
  4. pythonを使ってデータを取得

登録とかはほかサイトを引用してください.

こことか

以下はデータ取得のサンプルコードです.
為替の時系列データが,指定した間隔ごとにcsvファイルとして出力されます.


from oandapyV20 import API
import oandapyV20.endpoints.instruments as instruments
import pandas as pd

# 取得したアカウントIDとアクセストークンで書き換えてください.
accountID = '***'
access_token = '***'

# api開始
api = API(access_token=access_token)

# 取得したい為替リストの指定
instrument_list=["USD_JPY","EUR_JPY","GBP_JPY","CAD_JPY","ZAR_JPY","TRY_JPY","CHF_JPY","AUD_JPY","NZD_JPY"]

# 取得したい時間間隔の指定
time_length_list = ['M1','M5','M10','M15','M30','H1','H2','H3','H4']

# データ取得関数
def get_market_df(params):
    df_list = []

    for instrument in instrument_list:
        r = instruments.InstrumentsCandles(instrument=instrument, params=params)
        api.request(r)


        data = []
        for raw in r.response['candles']:
            data.append([raw['time'], raw['mid']['o']])

        df = pd.DataFrame(data)
        df.columns = ['time', instrument]
        df.time = pd.to_datetime(df.time)
        df[instrument] = df[instrument].map(float)

        df_list.append(df)

    df = df_list[0]
    for i in range(len(df_list)-1):
        df = pd.merge(df,df_list[i+1],on = 'time',how='inner')

    return df

# データの取得と保存
for time_length in time_length_list:
    params = {
        "count": 5000,
        "granularity": time_length
    }

    df = get_market_df(params)
    df.to_csv(time_length + '.csv')

その他

時系列データベースの推移が↓でまとめられています.
面白い.

10
9
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
10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?