Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

algos + tests + docu #138

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

FWurmbach
Copy link

No description provided.

ext-B (remove nil? (for [concept-B (concepts B)] (if (and (not-empty (first concept-B)) (not-empty (second concept-B))) (first concept-B))))]
(* (/ 1 (count ext-A)) (clojure.core.reducers/reduce + (for [ext-a ext-A] (apply max (helper-eval ext-a ext-B)))))))

(defn jaccard-index
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a Jaccard-Index within metrics.clj . Either use this one or relocate both into math/utils.clj

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it

[A B]
(difference (incidence-relation (normalize-context A)) (incidence-relation (normalize-context B))))

(defn concept-ratio
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name and defintion is weired, since the function does not know anything about concepts or contexts. Inline (double ... ) and put a fitting comment there

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was once used to determine the ratio of two different sets but was not actually used. Must've slipped when I cleaned the code

@@ -0,0 +1,927 @@
(ns conexp.fca.factorization
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add copyright notice

(is (= water-tiling (context water-tiling-test))))

(deftest test-topfiberm
(is (= water-test-topfiberm (context water-test-topfiberm-test))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symbols unresolved

[a]
(into [] (apply map vector a)))

(defn make-matrix-from-context
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have a string to 1/0 conversion here? Seems like a function from conexp.io.contexts should have been used

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't found any context -> 1/0-matrix conversion

(make-context-from-matrix
(first (context-size context))
(second (context-size context))
(into [] (flatten (make-matrix-from-context (context-to-string context))))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependence on context-to-string to create an incidence matrix may case side effects. Maybe a representation as used in the fast namespace is better.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; helper functions

(defn make-matrix-from-concept
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant this be done with the map function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the best I came up with :D

(defn normalize-context
[context]
(make-context-from-matrix
(first (context-size context))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

count objects
count attributes

;; Unite-Operator for 2 matrices
(defn- unite
[A B]
(loop [i 0 C []]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isnt this a some ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this does the same as sum, tailored for the use-case here


(defn convert-context-to-matrix
[context]
(into [] (flatten (make-matrix-from-context (context-to-string (normalize-context context))))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependence on context-to-string to create an incidence matrix may case side effects. Maybe a representation as used in the fast namespace is better.

Copy link
Collaborator

@hirthjo hirthjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR need some refactoring.

  • Remove undesirable dependencies
  • Refactor loop/recurs to some, map etc
  • Add speaking variable names
  • Add Doc Strings to function on what inputs are expected, what the outputs are and links to the papers where the algorithms were introduced

Every algorithm except asso and topfiberm need a context and a number k to produce factorizations.

```clj
(:context (apply ->factorization-record (topfiberm water-context k tp SR)));; tp is a threshold from 0 to 1, Sr is a search radius
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The factorization record should be the default return type for all factorization methods.

@hirthjo
Copy link
Collaborator

hirthjo commented Jun 13, 2024

One of the tests fails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants