mahout-user mailing list archives

Site index · List index
Message view
Top
From B & E <eja...@yahoo.com>
Subject Re: mahout matrix package
Date Wed, 25 Jan 2012 23:31:28 GMT
```thank you very much!

________________________________
From: Ted Dunning <ted.dunning@gmail.com>
To: B & E <ejawce@yahoo.com>
Cc: "user@mahout.apache.org" <user@mahout.apache.org>
Sent: Wednesday, January 25, 2012 1:39 PM
Subject: Re: mahout matrix package

On Wed, Jan 25, 2012 at 1:10 PM, B & E <ejawce@yahoo.com> wrote:

It's for part of a few straightforward matrix operations but over a very trivial size of matrix
(~ 10 x 5) within a mapper/reducer job.

Suppose you have

Matrix a;
Vector b;

and you want to solve for x such that a.times(x) = b, then this should work:

Matrix bMatrix = new Matrix(b.size(), 1).assignColumn(0, b);
Vector x = new QRDecomposition(a).solve(bMatrix).viewColumn(0);

There is a bit of mess here because there isn't a solve(Vector) method so we have to construct
a matrix and then get the required vector back out.

If you absolutely want the inverse over my suggestion that you don't want it, try this

Matrix inverse = new QRDecomposition(a).solve(new DiagonalMatrix(n))

You will have to pick the right n.

>
>For the inverse method, for now more like just looking for a handy brainless one liner
(since the matrix operations is trivial now).

There you go.

But do have a tradeoff concern in longer term when the matrix calculations becomes more involved
(in terms of complexity but not so much of size), would we have better off by using another
matrix package in the first place VS the out-of-box convenience to get some quick proof-of-concepts
now.

That is up to you.  I still don't know what you are doing and I don't know what your limits
are.  Mahout's math package is very good with sparse matrices and is moderate with dense
matrices.  It uses an API style that is really nice after you get to understand it, but it
has a learning curve.

>
>thanks.
>
>
>
>________________________________
> From: Ted Dunning <ted.dunning@gmail.com>
>To: user@mahout.apache.org
>Cc: B & E <ejawce@yahoo.com>
>Sent: Wednesday, January 25, 2012 3:18 AM
>Subject: Re: mahout matrix package
>
>
>Matrix inverse is almost never a good idea.  The same effect can usually be had using
a decomposition at far less cost.  For instance, for solving a linear system, QR decomposition
provides two sub-matrices that can easily have an inverse multiply operation applied to them
avoiding the need for actually computing the inverse.
>
>
>Can you say more about what you want to do?
>
>
>On Tue, Jan 24, 2012 at 11:47 PM, Raphael Cendrillon <cendrillon1978@gmail.com>
wrote:
>
>I believe matrix inversion in general may not be so easy to distributed within a map reduce
framework, however you could consider using the SSVD job to calculate an approximate matrix
inverse.
>>
>>
>>On 24 Jan, 2012, at 10:15 PM, B & E wrote:
>>
>>> Hi,
>>>
>>> I have a mahout newbie question -- I wanted to do some matrix operations in mahout
and just realized Mahout's matrix package doesn't seem to have any API on providing an inverse
of a matrix.
>>>
>>> Just curious was there a particular reason for such, or just so happens no code
was contributed to add that method to the matrix classes?
>>>
>>> thanks.
>>>
>>> Ejawce
>>
>>
>
>
>
```
Mime
• Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message