Skip to content

Instantly share code, notes, and snippets.

View prs-watch's full-sized avatar

hctaw-srp prs-watch

View GitHub Profile
.stream-item, .rpl {
background-color: black;
color: yellow;
border-bottom: 2px dashed yellow;
}
.prf-actions, .prf-meta, .social-proof-container {
background-color: black;
color: yellow;
border: 1px solid yellow;
}
using HTTP, CSV, DataFrames
URL_FORMAT_STR = "https://baseballsavant.mlb.com/statcast_search/csv?all=true&hfPT=&hfAB=&hfBBT=&hfPR=&hfZ=&stadium=&hfBBL=&hfNewZones=&hfGT=R%7CPO%7CS%7C=&hfSea=&hfSit=&player_type=pitcher&hfOuts=&opponent=&pitcher_throws=&batter_stands=&hfSA=&game_date_gt={start_dt}&game_date_lt={end_dt}&team=&position=&hfRO=&home_road=&hfFlag=&metric_1=&hfInn=&min_pitches=0&min_results=0&group_by=name&sort_col=pitches&player_event_sort=h_launch_speed&sort_order=desc&min_abs=0&type=details&"
function statcast(start_dt=nothing, end_dt=nothing)
if start_dt === nothing
start_dt = string(today())
end
if end_dt === nothing
end_dt = start_dt

トラッキングデータによるパフォーマンス予測

フロー

  • データを抜く・トラッキングデータDBを立てる
  • リーグスタッツで予測値と実測値の補正パラメータを作る
  • 選手単位で分布パラメータ(代表値・歪度・尖度)を取得して、パフォーマンス予測
@prs-watch
prs-watch / merge-gif.py
Last active January 17, 2021 13:43
GIFをマージしてくれるオレオレスクリプト
#!/usr/bin/env python
# coding: utf-8
"""
GIFマージスクリプト
## 仕様
- マージしてサイズが大きくなることを回避するため、(9/10)^(n-1)のサイズにする. (マージ量が増えるとどんどん小さいGIFになる)
## 処理フロー

自分なりにUIフレームワーク決めのロジックをまとめたのでメモ書き。 UIフレームワークの大別とそのメリデメをまとめた上で、自分なりの決めのロジックを整理した。

UIフレームワーク大別

コンポーネントライブラリ

CSSJavaScriptによって作られたUIコンポーネントを提供する。

  • Vuetify
@prs-watch
prs-watch / mlb_dot_com_prospect_list_expander.js
Created March 1, 2020 12:05
Expand MLB.com Prospect List without clicking "Load More" button
// ==UserScript==
// @name MLB.com Prospect List Expander
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Expand MLB.com Prospect List without clicking "Load More" button.
// @author prs-watch
// @match https://www.mlb.com/prospects/*
// @grant none
// ==/UserScript==
@prs-watch
prs-watch / dockerfile-generator.py
Created August 11, 2019 11:38
Script to generate Dockerfile from container.
#!/usr/bin/env python
# coding: utf-8
import docker
import jsondiff as jd
import re
import uuid
CLIENT = docker.from_env(timeout=600)
# meta information
FROM jupyter/minimal-notebook
LABEL maintainer="prs-watch"
# setting command
RUN pip install -U jupyterlab==0.35.6
RUN jupyter labextension install jupyterlab_voyager
RUN jupyter labextension install @jupyterlab/plotly-extension
# at directory where this Dockerfile exists..
import pandas as pd
import umap
from pyclustering.cluster import xmeans
class FGClusterExecuter:
"""
FanGraphs stats clustering class
"""
@classmethod
import sys
import requests
from requests_oauthlib import OAuth1 as oauth
import webbrowser
class Settings:
"""
アプリケーションを登録すると取得出来る認証情報を保持するプロパティクラス。
"""
CLIENT_ID = 'XXX'