都是老生常谈的问题. 吐槽外还包含哪些事情有意义. 主要内容看原文链接.
概率图模型基本概念
只涉及概念和记号, 不涉及算法.
Directed graphs are useful for expressing causal relationships between random variables, whereas undirected graphs are better suited to expressing soft constraints between random variables. For the purposes of solving inference problems, it is often convenient to convert both directed and undirected graphs into a different representation called a factor graph.
到达时间预测两则: Uber 和美团
Uber: DeepETA (Transformer)
参考
- Xinyu Hu, Olcay Cirit, Tanmay Binaykiya, and Ramit Hora. (2022, Feb 10). DeepETA: How Uber Predicts Arrival Times Using Deep Learning. Uber Engineering.
预测到达时间 (ETA, estimated time of arrival) 显然对 Uber 很重要 (最高 QPS 的服务). 传统方法把道路网分割为小路段, 每个路段表示为图中的带权边, 找出图中最短路径即得 ETA. 为考虑别的因素, 用机器学习预测 “真实到达时间和传统方法得到的 ETA” 的差值 (residual).
之前用 XGB ensemble. Eventually, we reached a point where increasing the dataset and model size using XGBoost became untenable. (为啥不行?) We decided to explore deep learning because of the relative ease of scaling to large datasets using data-parallel SGD. (树模型应该也有并行算法?)
目标有三个
- 时延: 毫秒级
- 准确度: MAE 要胜过 XGB
- 通用性: 用于 Uber 所有业务线
SimCSE: simple contrastive sentence embedding
参考
- Gao, T., Yao, X., & Chen, D. (2021). Simcse: Simple contrastive learning of sentence embeddings. arXiv preprint arXiv:2104.08821.
- Wang, T., & Isola, P. (2020, November). Understanding contrastive representation learning through alignment and uniformity on the hypersphere. In International Conference on Machine Learning (pp. 9929-9939). PMLR.
《下一代书店》笔记
赵慧. (2018). 下一代书店. 东方出版社.
上一代书店什么样?
以巴诺书店 (Barnes & Noble) 为例,
- 选址: 占据好位置.
- 库存和内部陈设足够丰富: 分类书架, 畅销书和推荐书的专门摆放位, 热门 IP 周边等.
- 不少非书籍类商品: 旗下电子书, 文创等.
- 名号大 (美国最大连锁书店), 与星巴克独家合作, 还经常举办活动.
唯一的问题是, 越来越少的消费者在这里买书. 书架或结账的前台很少有人, 客人都在儿童教育图书和星巴克咖啡附近.
吞食润滑剂是否安全?
吞食润滑剂是否安全?
- 原文: Is Lube Safe to Swallow?
- 原作者: webPOISONCONTROL, a project under the auspices of the National Capital Poison Center in Washington, DC.
参考文献见原文末尾 references
The Bottom Line
人体润滑剂种类繁多, 但只要正确使用, 一般都是安全的. 最常见的不良反应是刺激性 (irritation), 而中毒的可能性不大, 取决于具体的有效成分, 有效成分的浓度, 接触量的大小和接触途径. 为防止不良反应, 请遵循制造商提供的使用指南.
逻辑回归复习: 为什么不用 OLS
把 logisitic 翻译成逻辑并不恰当, 但就先这么用了.
A quick go through
有很多路径可以得到逻辑回归, 最直接地, 它是广义线性模型, 假设 log odds 可以线性表示 (从而决策边界是线性的), 即
\[\log \frac{\mathbb P (Y = 1 \mid X)}{\mathbb P (Y = 0 \mid X)} = \beta'X,\]其中 $Y \in \{0, 1\}$, 随机向量 $X = (1, X_2, \dots, X_{p+1})’$, 参数 $\beta = (\beta_1, \dots, \beta_{p+1})’$. 用极大似然估计参数, 用 Newton 法计算优化问题. 类似地容易推广到 softmax 形式.
Motivation 我认为可以这样理解: (1) 决策边界是线性的, 于是有右边项 $\beta’X$; (2) 两个概率之比大于某个阈值则预测为其中一个, 而由于概率非负, 所以最便利的让 odds 非负的办法是写为 $\exp(\beta’X)$, 或者其他任何单调变化都可以. 最后两个概率之和为 1 天然成立.
周志华西瓜书上把动机说为用 sigmoid 逼近阶梯函数, 虽然 sigmoid 可以, 但并不必要.
Java 初体验: 线性回归系数的检验
翻阅了 官方 tutorial.
与 Python 比较
new相当于在 Python 中显式地调用__init__方法.import好像没有 Python 灵活, 比如a.b.c, 只能导入 fully qualified name (一个具体的类) 或者一个库下所有的类, 而不能像 Python 一样from a import b然后再用b.c.- 没有默认参数 (可以用函数重载实现), 没有位置参数 (传参感觉不方便读 raw text?).
- 方法命名习惯用动词开头, camelCase.
- “only public methods are allowed to be called on class instance.” Why subclass in another package cannot access a protected method?
LightGBM
主论文
- Ke, G., Meng, Q., Finley, T., Wang, T., Chen, W., Ma, W., … & Liu, T. Y. (2017). Lightgbm: A highly efficient gradient boosting decision tree. Advances in neural information processing systems, 30, 3146-3154.
LGB 的 light 指它比之前的 GBDT 实现 (比如 XGB) 更快. 核心是加速 GBDT 最耗时的求特征分裂点的部分 (时间复杂度 $O(\#\text{samples}\times\#\text{features})$ 或 histogram-based 的 $O(\#\text{bins}\times\#\text{features})$), 提出 Gradient-based One-Side Sampling (GOSS) 和 Exclusive Feature Bundling (EFB). 其中前者减少需要考虑的样本数 (主要考虑梯度大的样本), 后者压缩特征数, 从而实现加速. 结果除了速度, 精度也往往有提升.
Python 第三方库杂录
大多是常用第三方库.
其他库
unyt
2022/7/7
涉及到浮点数的单位相等判断会有问题, 参考 issue#238
Pandas
Cookbook
2020/5/30
pipeline (df.pipe), 临时列 (df.assign) 等
- peter. (2022). Cookbook
- data school. (2018). What’s the future of the pandas library?
- Sin-Yi Chou. (2019). Pandas - Pipe Method. 用装饰器辅助 debug
groupby 默认会排序
2022/4/25
sort : bool, default True
Sort group keys. Get better performance by turning this off. Note this does not influence the order of observations within each group. Groupby preserves the order of rows within each group.