Tag: python
-
Updated
Timezone in Python: Offset-naive and Offset-aware datetimes
Category: Python
You should always store datetimes in UTC and convert to proper timezone on display.
-
Updated
Build a recommender system with Spark: Content-based and Elasticsearch
在本篇文章中,我們以 Candidate Generation 階段常用的方法之一:Content-based recommendation 基於內容的推薦為例,利用 Elasticsearch 的 More Like This query 建立一個 GitHub repositories 的推薦系統,以用戶最近打星過的 repo 作為輸入數據,比對出相似的其他 repo 作為候選物品集。
-
Updated
-
Updated
Build a recommender system with Spark: Implicit ALS
Category: AI, Big Data, Python
在本篇文章中,我們以 Candidate Generation 階段常用的方法之一:Collaborative Filtering 協同過濾演算法為例,利用 Apache Spark 的 ALS (Alternating Least Squares) 模型建立一個 GitHub repositories 的推薦系統,以用戶對 repo 的打星紀錄作為訓練數據,推薦出用戶可能會感興趣的其他 repo 作為候選物品集。
-
Updated
Generate negative samples for recommender system?
Category: AI
對 implicit feedback 的 ALS 來說,手動加入負樣本(Rui = 0 的樣本)是沒有意義的,因為 missing value / non-observed value 對該演算法來說本來就是 0,表示用戶確實沒有對該物品做出行為,也就是 Pui = 0 沒有偏好。
-
Updated
Spark ML cookbook (Python)
Category: AI, Big Data, Python
As of Spark 2.0, the RDD-based APIs in the spark.mllib package have entered maintenance mode. The primary Machine Learning API for Spark is now the DataFrame-based API in the spark.ml package.
-
Updated
Spark SQL cookbook (Python)
Category: AI, Big Data, Python
Spark SQL is a Spark module for structured data processing. Unlike the basic Spark RDD API, the interfaces provided by Spark SQL provide Spark with more information about the structure of both the data and the computation being performed.
-
Updated
Spark RDD methods (Python /
Scala) Category: AI, Big Data, Python
以下的 methods 有些是所有 RDD 都能用,有些則是 PairRDD 才有的功能。然後因為在不同的 projects 我先後用了 Spark 的 Python API 和 Scala API,所以以下的內容可能會混雜著兩者的範例。Scala API 要特別注意每個 method 接受和回傳的 type 的差異;Python API 就沒有這種限制了,畢竟是動態語言。
-
Updated
Setup Spark on macOS
Category: AI, Big Data, Python
Install Spark on macOS with Homebrew or the pre-built tarball. You need Java 8 JDK first.
-
Updated
Functional Programming in Python
Category: Python
map() 會讓 list 的每一個元素都會各自經過 func(x) 去處理,最後得到的會是一個新的數量相同的 list。