7
4

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.

stravaでロードバイクの偏差値を計算してみた

Posted at

ふと自分のロードバイク偏差値が気になったので計算してみた。

まず、Stravaのアプリを登録して、CLIENT_SECRETをゲット

対象となるセグメントの全ランキングを取得。
今回は、ベイエリアのライダーがベンチマークにしている Old La Honda(https://graphics.stanford.edu/~lucasp/grade/oldlahonda.html) を使用。

import requests
import json
import time

apiPath = "https://www.strava.com/api/v3/segments/8109834/leaderboard"

headers = {'Authorization': 'Bearer STRAVA_CLIENT_SECRET'}

pageLimit = 100

firstPagePath = apiPath + "?page=1&per_page=" + str(pageLimit)
firstPage = requests.get(firstPagePath, headers=headers).json()
totalCount = firstPage["entry_count"]

pageCount = totalCount / pageLimit

entries = []

for num in range(pageCount):
    pageNum = num + 1
    path = apiPath + "?page=" + str(pageNum) + "&per_page=" + str(pageLimit)
    pageData = requests.get(path, headers=headers).json()
    entries += pageData["entries"]
    time.sleep(0.5)

print json.dumps(entries)

Jupiter notebookでヒストグラムと偏差値を計算

%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt
import json


f = open('oldlahonda.json', 'r')
entries = json.load(f)

elapsed = []
ranking = {}
power = []

for entry in entries:
    ranking[entry["rank"]] = entry

for t in ranking.values():
    elapsed.append(t["elapsed_time"])

np_scores = np.array(elapsed)  
mean = np.mean(np_scores)
std = np.std(np_scores)

score_a = 1531 # My best record

deviation = (score_a - mean) / std
deviation_value = 50 - deviation * 10

print(deviation_value)

plt.hist(elapsed, bins=200)
plt.plot()

偏差値 57.8らしい 精進せねば

ヒストグラムはこんな感じ(x軸は秒)
download.png

7
4
2

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
7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?