Skip to content

Commit

Permalink
Improved Documentation for Boolean Matrix Factorizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikNordmeyer committed Sep 13, 2024
1 parent 8fa76ff commit f84e102
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions src/main/clojure/conexp/fca/matrix_factorizations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
)


;;Hyper Algorithm
;; Hyper Algorithm
;; https://doi.org/10.1007/s10618-010-0203-9
;; Compare Algorithm 1


(defn- hyperrectangle-candidates [ctx min-supp]
Expand Down Expand Up @@ -123,7 +125,9 @@
)


;;topFiberM Algorithm
;; topFiberM Algorithm
;; https://doi.org/10.48550/arXiv.1903.10326
;; Compare Algorithm 1

(defn- process-object-fiber [X ctx obj tP] ;obj = object representing row Bi
"Lines 12 - 22. If best fiber is a row.
Expand Down Expand Up @@ -195,9 +199,7 @@

(let [sr (min search-limit (count (objects ctx)) (count (attributes ctx)))]

(loop [;As (into [] (repeat (count (objects ctx)) (into [] (repeat search-limit 0))))
;Bs (into [] (repeat search-limit (into [] (repeat (count (attributes ctx)) 0))))
As []
(loop [As []
Bs []
tf []
excluded-rows #{} ;objects representing excluded fibers
Expand Down Expand Up @@ -255,9 +257,11 @@


;; PaNDa Algorithm
;; https://doi.org/10.1137/1.9781611972801.15
;; Compare Algorithm 1

(defn outer-prod [v1 v2]
"computes the outer product of two vectors."
"Computes the outer product of two vectors."
(into [] (for [x v1]
(into [] (for [y v2] (* x y)))))
)
Expand Down Expand Up @@ -320,7 +324,7 @@


(defn- extend-core [core extension-list patterns ctx]

"Compare Algorithm 3."
(loop [remaining extension-list
current-core core]

Expand All @@ -343,7 +347,8 @@


(defn PaNDa [ctx k]

"ctx: Context to be decomposed.
k: Number of factors."
(let [obj-order (into [] (objects ctx))
attr-order (into [] (attributes ctx))]

Expand All @@ -367,9 +372,12 @@



;;Tiling Algorithm
;; Tiling Algorithm
;; Loosely based on https://doi.org/10.1007/978-3-540-30214-8_22

(defn tiling [ctx k]
"ctx: Context to be decomposed.
k: Number of factors."
(loop [factors #{}
counter 1
conc (concepts ctx)]
Expand All @@ -387,7 +395,9 @@
(second c)] [g m]))))))))
)

;;Grecond Algorithm
;; Grecond Algorithm
;; https://doi.org/10.1016/j.jcss.2009.05.002
;; Compare Algorithm 1

(defn object-concepts [ctx]
"Returns a set of all object-concepts of the specified context."
Expand Down Expand Up @@ -444,11 +454,14 @@
)

(defn grecond [ctx]
"ctx: Context to be decomposed."
(let [[S U F] (mandatory-factors ctx)]
(apply ->context-factorization (contexts-from-factors (remaining-factors S U F ctx) (objects ctx) (attributes ctx))))
)

;; GreEss Algorithm
;; https://doi.org/10.1016/j.jcss.2015.06.002
;; Compare Algorithm 1

(defalias o-d object-derivation)
(defalias a-d attribute-derivation)
Expand Down Expand Up @@ -574,11 +587,10 @@
(conj factors best-cand)))))
)





;; ASSO Algorithm
;; https://doi.org/10.1109/TKDE.2008.53
;; Compare Algorithm 1

(defn- column-association [M i j]
"Computes the confidence of an association between columns i and j of a matrix."
(let [dividend (scalar-product (matrix-column M i) (matrix-column M j))
Expand Down

0 comments on commit f84e102

Please sign in to comment.