Skip to content

Instantly share code, notes, and snippets.

@sizhky
sizhky / spec.json
Created July 4, 2021 05:26
Vega-Lite spec from Sun Jul 04 2021
{
"config": {"view": {"continuousWidth": 400, "continuousHeight": 300}},
"layer": [
{
"mark": {"type": "line", "interpolate": "basis"},
"encoding": {
"color": {"type": "nominal", "field": "category"},
"x": {"type": "quantitative", "field": "th"},
"y": {"type": "quantitative", "field": "y"}
},
@sizhky
sizhky / data.csv
Created July 4, 2021 06:36
Breast cancer dataset
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 33 columns, instead of 32 in line 1.
"id","diagnosis","radius_mean","texture_mean","perimeter_mean","area_mean","smoothness_mean","compactness_mean","concavity_mean","concave points_mean","symmetry_mean","fractal_dimension_mean","radius_se","texture_se","perimeter_se","area_se","smoothness_se","compactness_se","concavity_se","concave points_se","symmetry_se","fractal_dimension_se","radius_worst","texture_worst","perimeter_worst","area_worst","smoothness_worst","compactness_worst","concavity_worst","concave points_worst","symmetry_worst","fractal_dimension_worst",
842302,M,17.99,10.38,122.8,1001,0.1184,0.2776,0.3001,0.1471,0.2419,0.07871,1.095,0.9053,8.589,153.4,0.006399,0.04904,0.05373,0.01587,0.03003,0.006193,25.38,17.33,184.6,2019,0.1622,0.6656,0.7119,0.2654,0.4601,0.1189
842517,M,20.57,17.77,132.9,1326,0.08474,0.07864,0.0869,0.07017,0.1812,0.05667,0.5435,0.7339,3.398,74.08,0.005225,0.01308,0.0186,0.0134,0.01389,0.003532,24.99,23.41,158.8,1956,0.1238,0.1866,0.2416,0.186,0.275,0.08902
84300903,M,19.69,21.25,130,1203,0.1096,0.1599,0.1974,0.1279,
sepal.length sepal.width petal.length petal.width Name
5.1 3.5 1.4 .2 Setosa
4.9 3 1.4 .2 Setosa
4.7 3.2 1.3 .2 Setosa
4.6 3.1 1.5 .2 Setosa
5 3.6 1.4 .2 Setosa
5.4 3.9 1.7 .4 Setosa
4.6 3.4 1.4 .3 Setosa
5 3.4 1.5 .2 Setosa
4.4 2.9 1.4 .2 Setosa
AtBat Hits HmRun Runs RBI Walks Years CAtBat CHits CHmRun CRuns CRBI CWalks League Division PutOuts Assists Errors Salary NewLeague
293 66 1 30 29 14 1 293 66 1 30 29 14 A E 446 33 20 NA A
315 81 7 24 38 39 14 3449 835 69 321 414 375 N W 632 43 10 475 N
479 130 18 66 72 76 3 1624 457 63 224 266 263 A W 880 82 14 480 A
496 141 20 65 78 37 11 5628 1575 225 828 838 354 N E 200 11 3 500 N
321 87 10 39 42 30 2 396 101 12 48 46 33 N E 805 40 4 91.5 N
594 169 4 74 51 35 11 4408 1133 19 501 336 194 A W 282 421 25 750 A
185 37 1 23 8 21 2 214 42 1 30 9 24 N E 76 127 7 70 A
298 73 0 24 24 7 3 509 108 0 41 37 12 A W 121 283 9 100 A
323 81 6 26 32 8 2 341 86 6 32 34 8 N W 143 290 19 75 N
@sizhky
sizhky / classes
Created August 22, 2021 10:34
coco-things
background
person
bicycle
car
motorcycle
airplane
bus
train
truck
boat
@sizhky
sizhky / GitCommitEmoji.md
Last active November 11, 2021 09:57 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
def add_datepart(df, fldname, drop=True, time=False):
"Helper function that adds columns relevant to a date."
fld = df[fldname]
fld_dtype = fld.dtype
if isinstance(fld_dtype, pd.core.dtypes.dtypes.DatetimeTZDtype):
fld_dtype = np.datetime64
if not np.issubdtype(fld_dtype, np.datetime64):
df[fldname] = fld = pd.to_datetime(fld, infer_datetime_format=True)
targ_pre = re.sub('[Dd]ate$', '', fldname)
@sizhky
sizhky / io.py
Created November 11, 2021 15:16
io
from torch_snippets import *
def io(func):
def inner(*args, **kwargs):
Info(f'\nargs: {args}\nkwargs: {kwargs}', depth=1)
o = func(*args, **kwargs)
Info(f'\noutput: {o}', depth=1)
return o
return inner
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 17 columns, instead of 11 in line 5.
id,city,date,player_of_match,venue,neutral_venue,team1,team2,toss_winner,toss_decision,winner,result,result_margin,eliminator,method,umpire1,umpire2
335982,Bangalore,2008-04-18,BB McCullum,M Chinnaswamy Stadium,0,Royal Challengers Bangalore,Kolkata Knight Riders,Royal Challengers Bangalore,field,Kolkata Knight Riders,runs,140,N,NA,Asad Rauf,RE Koertzen
335983,Chandigarh,2008-04-19,MEK Hussey,"Punjab Cricket Association Stadium, Mohali",0,Kings XI Punjab,Chennai Super Kings,Chennai Super Kings,bat,Chennai Super Kings,runs,33,N,NA,MR Benson,SL Shastri
335984,Delhi,2008-04-19,MF Maharoof,Feroz Shah Kotla,0,Delhi Daredevils,Rajasthan Royals,Rajasthan Royals,bat,Delhi Daredevils,wickets,9,N,NA,Aleem Dar,GA Pratapkumar
335985,Mumbai,2008-04-20,MV Boucher,Wankhede Stadium,0,Mumbai Indians,Royal Challengers Bangalore,Mumbai Indians,bat,Royal Challengers Bangalore,wickets,5,N,NA,SJ Davis,DJ Harper
335986,Kolkata,2008-04-20,DJ Hussey,Eden Gardens,0,Kolkata Knight Riders,Deccan Chargers,Deccan Chargers,bat,Kolkata Knigh
@sizhky
sizhky / .gitignore
Created November 10, 2022 09:47
Python's gitignore
# Data
*.csv
*.png
*.jpg
*.jpeg
*.pdf
*.json
# Byte-compiled / optimized / DLL files
__pycache__/