core.matrix documentation and incanter support

76 views
Skip to first unread message

David Iba

unread,
Apr 3, 2014, 2:51:46 AM4/3/14
to numerica...@googlegroups.com
Hi all,

I'm a newbie just getting started learning clojure with the intent of using it for a project involving some heavy machine-learning & data analysis.  A couple questions I was hoping this group could help me out with:

1) I saw there was plans for incanter to support core.matrix... has that happened yet?

2) Is there someplace with documentation for the various functions available in core.matrix?  For example, I was trying to figure out how to set the ith row of matrix M to vector v -- I saw the "mset!" function for setting a scalar value in a matrix, but couldn't find any documentation about its use to see if it could be used for entire rows/cols of a matrix... I suppose you could do something like:

(map #(mset! M i %1 %2) (range (-> M shape second)) v)

but I was curious if there was a better/built-in way.

3) What tools/resources would you recommend for mastering core.matrix and/or incanter?

Thanks,
David

Mike Anderson

unread,
Apr 3, 2014, 3:42:41 AM4/3/14
to numerica...@googlegroups.com
On Thursday, 3 April 2014 14:51:46 UTC+8, David Iba wrote:
Hi all,

I'm a newbie just getting started learning clojure with the intent of using it for a project involving some heavy machine-learning & data analysis.  A couple questions I was hoping this group could help me out with:

Hi David, welcome to the Clojure Numerics world!
 

1) I saw there was plans for incanter to support core.matrix... has that happened yet?

Not yet. I did some experiments here to test feasibility of this (answer: looks entirely feasible but lots of details to get right), but it's not complete:

Hopefully we may get a Google Summer of Code student to take this on?
 

2) Is there someplace with documentation for the various functions available in core.matrix?  For example, I was trying to figure out how to set the ith row of matrix M to vector v -- I saw the "mset!" function for setting a scalar value in a matrix, but couldn't find any documentation about its use to see if it could be used for entire rows/cols of a matrix... I suppose you could do something like:


Currently the official documentation is the docstrings. 

There is also some documentation in the Wiki: https://github.com/mikera/core.matrix/wiki
  

(map #(mset! M i %1 %2) (range (-> M shape second)) v)

but I was curious if there was a better/built-in way.

There's "set-row" in the API to do exactly this:

(set-row [[1 2] [3 4]] 0 [9 9])
=> [[9 9] [3 4]]

P.S. normally you should avoid mutating arrays unless you absolutely need to (typically for speed). Clojure style is definitely to prefer using objects in an immutable way, even if they are actually mutable.
 

3) What tools/resources would you recommend for mastering core.matrix and/or incanter?


In addition to the links above, I think my Clojure Conj talk does a reasonable job of explaining the core.matrix concepts: 

Incanter has some quite good examples in the Wiki:

David Iba

unread,
Apr 3, 2014, 2:03:34 PM4/3/14
to numerica...@googlegroups.com
Great, thanks!  I'll check out those links.

Also, any idea why I'm getting this error trying to pretty-print a matrix:

> (use 'clojure.core.matrix)
> (use 'clojure.core.matrix.operators)
> (set-current-implementation :vectorz) 
> (pm (matrix [[1 2] [3 4]]))
UnknownFormatConversionException Conversion = '5'  java.util.Formatter.checkText (Formatter.java:2519)

Mike Anderson

unread,
Apr 3, 2014, 8:44:49 PM4/3/14
to numerica...@googlegroups.com
Ah yes, that's a known bug:


I hope to fix this for the next release of vectorz-clj
Reply all
Reply to author
Forward
0 new messages