Skip to content

Commit

Permalink
updated API: protocol-based summary
Browse files Browse the repository at this point in the history
  • Loading branch information
daslu committed Dec 12, 2024
1 parent 28b3e76 commit 5c6e0ed
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/scicloj/tablemath/v1/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
[scicloj.kindly.v4.kind :as kind]
[scicloj.tablemath.v1.design-matrix :as dm]))

(defprotocol Summarizable
:extend-via-metadata true
(summary [this]))

(defn lm
"Linear model"
([dataset]
Expand All @@ -16,22 +20,20 @@
first)
ds-without-target (-> dataset
(tc/drop-columns [inference-column-name]))]
(reg/lm
;; ys
(get dataset inference-column-name)
;; xss
(tc/rows ds-without-target)
;; options
(merge {:names (-> ds-without-target
tc/column-names
vec)}
options)))))

(-> (reg/lm
;; ys
(get dataset inference-column-name)
;; xss
(tc/rows ds-without-target)
;; options
(merge {:names (-> ds-without-target
tc/column-names
vec)}
options))
(vary-meta assoc `summary #(kind/code
(with-out-str
(println %))) )))))

(defn summary [model]
(kind/code
(with-out-str
(println model))))

(defn create-design-matrix [ds targets-specs feature-specs]
(dm/create-design-matrix ds targets-specs feature-specs))

0 comments on commit 5c6e0ed

Please sign in to comment.