You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mahout.apache.org by Karl Wettin <ka...@gmail.com> on 2008/06/27 19:09:17 UTC

Feature names and class feature values

I think it makes sense to optinally store something like Map</**column  
name*/String, /**column index*/Integer> and Map</**column index*/ 
Integer, Map</*class value*/String, Double>> in AbstractMatrix.

         karl

Re: Feature names and class feature values

Posted by Isabel Drost <ap...@isabel-drost.de>.
On Tuesday 01 July 2008, Ted Dunning wrote:
> This is the most important comment in the conversation so far.
>
> The cost for matrix implementors should be nil, there should be no cost for
> users who don't use the features and the benefit should apply to all users
> who need it.

+1 from my side.

Isabel

-- 
I'll pretend to trust you if you'll pretend to trust me.
  |\      _,,,---,,_       Web:   <http://www.isabel-drost.de>
  /,`.-'`'    -.  ;-;;,_
 |,4-  ) )-,_..;\ (  `'-'
'---''(_/--'  `-'\_) (fL)  IM:  <xm...@spaceboyz.net>

Re: Feature names and class feature values

Posted by Ted Dunning <te...@gmail.com>.
This is the most important comment in the conversation so far.

The cost for matrix implementors should be nil, there should be no cost for
users who don't use the features and the benefit should apply to all users
who need it.

On Tue, Jul 1, 2008 at 10:31 AM, Jeff Eastman <jd...@windwardsolutions.com>
wrote:

> ...
>
> I think this can all be implemented at the abstract level in a
> straightforward manner. Are people in favor of this?
>
>

Re: Feature names and class feature values

Posted by Jeff Eastman <jd...@windwardsolutions.com>.
Labels will of course impact the serialized representations, which may 
be your point. For other applications building vectors from scratch, 
won't they need a bindLabel() method?

Another omission from the interface below is the ability to determine 
the label that is bound to a particular index. Perhaps an individual 
call would be sufficient:

public String getLabel(int index) throws UnboundLabelException;

... or also one that just returns the underlying map:

public Map<String, Integer> getLabels();

I think this can all be implemented at the abstract level in a 
straightforward manner. Are people in favor of this?

Jeff

Ted Dunning wrote:
> That is exactly what I was suggesting on the accessors.  Generally, I have
> found that an explicit bind is not used by applications since the code that
> read the matrix will add the labels, but clearly it is needed by the read
> code.
>
> On Tue, Jul 1, 2008 at 8:43 AM, Jeff Eastman <jd...@windwardsolutions.com>
> wrote:
>
>   
>> If it is implemented lazily, matrix and vector labeling can be done without
>> overhead if it is not used. I tend to agree with Ted on this point. Jumping
>> to an implementation strategy, would it make sense to separate the binding
>> of labels with indices such as:
>>
>> interface Vector {
>> ...
>>
>> public void bindLabel(int index, String label) throws
>> AlreadyBoundException;
>>
>> /* so that these might also be added? */
>>
>> public double get(String label) throws IndexException,
>> UnboundLabelException;
>> public set(String label,  double value)  throws IndexException,
>> UnboundLabelException;
>>
>> }
>>
>> Jeff
>>
>>
>> Ted Dunning wrote:
>>
>>     
>>> I agree that it is good to have an unlabeled matrix, but I think it is
>>> important to have a labeled one as a fairly primitive structure.  With
>>> sparse matrices, you have to have a label of some kind and it is
>>> incredibly
>>> convenient to have that label mean something in the outside world.
>>>
>>> I have experimented with API's where you read and write matrices via a
>>> labeling map that extends if you encounter new words.  That works and
>>> leaves
>>> the matrix unlabeled, but it is sooo easy to get wrong.  It also makes
>>> debugging more confusing because data structures have different values
>>> depending on what order you read them in.
>>>
>>> I have also experimented with an API that keeps the labels on the
>>> matrix/vector.  R works similarly with its data-frame structure.  Having
>>> those labels go along for the ride is absolutely heavenly when you are
>>> debugging code.  In work I have been doing just now, I am building
>>> interaction models.  Having intelligible labels on all the terms makes
>>> things much easier to deal with.
>>>
>>> This comparison of experiences makes me feel pretty strongly that it would
>>> be good to have a primitive labeled matrix.
>>>
>>> On Mon, Jun 30, 2008 at 10:04 PM, Isabel Drost <
>>> apache_mahout@isabel-drost.de> wrote:
>>>
>>>
>>>
>>>       
>>>> It is also nice to be able to have a matrix with columns labeled by terms
>>>>         
>>>>> that you multiply by a query that has components labeled by the same
>>>>> terms.  These mappings should all be below the covers.
>>>>>
>>>>>
>>>>>           
>>>> I think it would be a good idea not to stuff all that logic into the
>>>> matrix
>>>> but offer different labeling strategies.
>>>>
>>>>
>>>>
>>>>
>>>>         
>>>
>>>       
>>     
>
>
>   


Re: Feature names and class feature values

Posted by Ted Dunning <te...@gmail.com>.
That is exactly what I was suggesting on the accessors.  Generally, I have
found that an explicit bind is not used by applications since the code that
read the matrix will add the labels, but clearly it is needed by the read
code.

On Tue, Jul 1, 2008 at 8:43 AM, Jeff Eastman <jd...@windwardsolutions.com>
wrote:

> If it is implemented lazily, matrix and vector labeling can be done without
> overhead if it is not used. I tend to agree with Ted on this point. Jumping
> to an implementation strategy, would it make sense to separate the binding
> of labels with indices such as:
>
> interface Vector {
> ...
>
> public void bindLabel(int index, String label) throws
> AlreadyBoundException;
>
> /* so that these might also be added? */
>
> public double get(String label) throws IndexException,
> UnboundLabelException;
> public set(String label,  double value)  throws IndexException,
> UnboundLabelException;
>
> }
>
> Jeff
>
>
> Ted Dunning wrote:
>
>> I agree that it is good to have an unlabeled matrix, but I think it is
>> important to have a labeled one as a fairly primitive structure.  With
>> sparse matrices, you have to have a label of some kind and it is
>> incredibly
>> convenient to have that label mean something in the outside world.
>>
>> I have experimented with API's where you read and write matrices via a
>> labeling map that extends if you encounter new words.  That works and
>> leaves
>> the matrix unlabeled, but it is sooo easy to get wrong.  It also makes
>> debugging more confusing because data structures have different values
>> depending on what order you read them in.
>>
>> I have also experimented with an API that keeps the labels on the
>> matrix/vector.  R works similarly with its data-frame structure.  Having
>> those labels go along for the ride is absolutely heavenly when you are
>> debugging code.  In work I have been doing just now, I am building
>> interaction models.  Having intelligible labels on all the terms makes
>> things much easier to deal with.
>>
>> This comparison of experiences makes me feel pretty strongly that it would
>> be good to have a primitive labeled matrix.
>>
>> On Mon, Jun 30, 2008 at 10:04 PM, Isabel Drost <
>> apache_mahout@isabel-drost.de> wrote:
>>
>>
>>
>>> It is also nice to be able to have a matrix with columns labeled by terms
>>>> that you multiply by a query that has components labeled by the same
>>>> terms.  These mappings should all be below the covers.
>>>>
>>>>
>>> I think it would be a good idea not to stuff all that logic into the
>>> matrix
>>> but offer different labeling strategies.
>>>
>>>
>>>
>>>
>>
>>
>>
>
>


-- 
ted

Re: Feature names and class feature values

Posted by Jeff Eastman <jd...@windwardsolutions.com>.
If it is implemented lazily, matrix and vector labeling can be done 
without overhead if it is not used. I tend to agree with Ted on this 
point. Jumping to an implementation strategy, would it make sense to 
separate the binding of labels with indices such as:

interface Vector {
...

public void bindLabel(int index, String label) throws AlreadyBoundException;

/* so that these might also be added? */

public double get(String label) throws IndexException, 
UnboundLabelException;
public set(String label,  double value)  throws IndexException, 
UnboundLabelException;

}

Jeff

Ted Dunning wrote:
> I agree that it is good to have an unlabeled matrix, but I think it is
> important to have a labeled one as a fairly primitive structure.  With
> sparse matrices, you have to have a label of some kind and it is incredibly
> convenient to have that label mean something in the outside world.
>
> I have experimented with API's where you read and write matrices via a
> labeling map that extends if you encounter new words.  That works and leaves
> the matrix unlabeled, but it is sooo easy to get wrong.  It also makes
> debugging more confusing because data structures have different values
> depending on what order you read them in.
>
> I have also experimented with an API that keeps the labels on the
> matrix/vector.  R works similarly with its data-frame structure.  Having
> those labels go along for the ride is absolutely heavenly when you are
> debugging code.  In work I have been doing just now, I am building
> interaction models.  Having intelligible labels on all the terms makes
> things much easier to deal with.
>
> This comparison of experiences makes me feel pretty strongly that it would
> be good to have a primitive labeled matrix.
>
> On Mon, Jun 30, 2008 at 10:04 PM, Isabel Drost <
> apache_mahout@isabel-drost.de> wrote:
>
>   
>>> It is also nice to be able to have a matrix with columns labeled by terms
>>> that you multiply by a query that has components labeled by the same
>>> terms.  These mappings should all be below the covers.
>>>       
>> I think it would be a good idea not to stuff all that logic into the matrix
>> but offer different labeling strategies.
>>
>>
>>     
>
>   


Re: Feature names and class feature values

Posted by Ted Dunning <te...@gmail.com>.
I agree that it is good to have an unlabeled matrix, but I think it is
important to have a labeled one as a fairly primitive structure.  With
sparse matrices, you have to have a label of some kind and it is incredibly
convenient to have that label mean something in the outside world.

I have experimented with API's where you read and write matrices via a
labeling map that extends if you encounter new words.  That works and leaves
the matrix unlabeled, but it is sooo easy to get wrong.  It also makes
debugging more confusing because data structures have different values
depending on what order you read them in.

I have also experimented with an API that keeps the labels on the
matrix/vector.  R works similarly with its data-frame structure.  Having
those labels go along for the ride is absolutely heavenly when you are
debugging code.  In work I have been doing just now, I am building
interaction models.  Having intelligible labels on all the terms makes
things much easier to deal with.

This comparison of experiences makes me feel pretty strongly that it would
be good to have a primitive labeled matrix.

On Mon, Jun 30, 2008 at 10:04 PM, Isabel Drost <
apache_mahout@isabel-drost.de> wrote:

> > It is also nice to be able to have a matrix with columns labeled by terms
> > that you multiply by a query that has components labeled by the same
> > terms.  These mappings should all be below the covers.
>
> I think it would be a good idea not to stuff all that logic into the matrix
> but offer different labeling strategies.
>
>

Re: Feature names and class feature values

Posted by Isabel Drost <ap...@isabel-drost.de>.
On Monday 30 June 2008, Ted Dunning wrote:
> Karl Wettin wrote:
> > Should they be a part of the matrix or is there some reason for having
> > them as aggregated strategies? 
>
> I think that this becomes very important when you have several matrices and
> it becomes hard to keep track of which mapping table to use.
>
> It is also nice to be able to have a matrix with columns labelled by terms
> that you multiply by a query that has components labelled by the same
> terms.  These mappings should all be below the covers.

I think it would be a good idea not to stuff all that logic into the matrix 
but offer different labeling strategies.

Isabel

-- 
We have met the enemy, and he is us.		-- Walt Kelly
  |\      _,,,---,,_       Web:   <http://www.isabel-drost.de>
  /,`.-'`'    -.  ;-;;,_
 |,4-  ) )-,_..;\ (  `'-'
'---''(_/--'  `-'\_) (fL)  IM:  <xm...@spaceboyz.net>

Re: Feature names and class feature values

Posted by Ted Dunning <te...@gmail.com>.
I think that this becomes very important when you have several matrices and
it becomes hard to keep track of which mapping table to use.

It is also nice to be able to have a matrix with columns labelled by terms
that you multiply by a query that has components labelled by the same
terms.  These mappings should all be below the covers.

On Mon, Jun 30, 2008 at 1:42 PM, Isabel Drost <ap...@isabel-drost.de>
wrote:

> On Monday 30 June 2008, Karl Wettin wrote:
> > 29 jun 2008 kl. 00.20 skrev Ted Dunning:
> > > We were talking about this same sort of capability early on.
> > >
> > > I think that matrix rows and columns should be allowed to have
> > > String names as well as integer indexes.
> >
> > Is there a reason for them to be serialized in some smart way, something
> > like preparing them for for huge pre-feature selected vectors, or so?
>
> Sounds reasonable to me. For feature selection it might be nice to have a
> way
> of storing the feature names only - so when generating vectors for new
> instances one can take into account only those features that turned out to
> be
> relevant - what do you think?
>
> Isabel
>
> --
> Be careful!  Is it classified?
>  |\      _,,,---,,_       Web:   <http://www.isabel-drost.de>
>  /,`.-'`'    -.  ;-;;,_
>  |,4-  ) )-,_..;\ (  `'-'
> '---''(_/--'  `-'\_) (fL)  IM:  <xm...@spaceboyz.net>
>



-- 
ted

Re: Feature names and class feature values

Posted by Isabel Drost <ap...@isabel-drost.de>.
On Monday 30 June 2008, Karl Wettin wrote:
> 29 jun 2008 kl. 00.20 skrev Ted Dunning:
> > We were talking about this same sort of capability early on.
> >
> > I think that matrix rows and columns should be allowed to have
> > String names as well as integer indexes.
>
> Is there a reason for them to be serialized in some smart way, something
> like preparing them for for huge pre-feature selected vectors, or so?

Sounds reasonable to me. For feature selection it might be nice to have a way 
of storing the feature names only - so when generating vectors for new 
instances one can take into account only those features that turned out to be 
relevant - what do you think?

Isabel

-- 
Be careful!  Is it classified?
  |\      _,,,---,,_       Web:   <http://www.isabel-drost.de>
  /,`.-'`'    -.  ;-;;,_
 |,4-  ) )-,_..;\ (  `'-'
'---''(_/--'  `-'\_) (fL)  IM:  <xm...@spaceboyz.net>

Re: Feature names and class feature values

Posted by Karl Wettin <ka...@gmail.com>.
29 jun 2008 kl. 00.20 skrev Ted Dunning:

> We were talking about this same sort of capability early on.
>
> I think that matrix rows and columns should be allowed to have  
> String names
> as well as integer indexes.

Would it have to be more advanced than the two maps suggested? Should  
they be a part of the matrix or is there some reason for having them  
as aggregated strategies? Is there a reason for them to be serialized  
in some smart way, something like preparing them for for huge pre- 
feature selected vectors, or so?



         karl


> On Sat, Jun 28, 2008 at 9:54 AM, Karl Wettin <ka...@gmail.com>  
> wrote:
>
>>
>> 27 jun 2008 kl. 20.54 skrev Isabel Drost:
>>
>> On Friday 27 June 2008, Karl Wettin wrote:
>>>
>>>> I think it makes sense to optinally store something like Map</ 
>>>> **column
>>>> name*/String, /**column index*/Integer> and Map</**column index*/
>>>> Integer, Map</*class value*/String, Double>> in AbstractMatrix.
>>>>
>>>
>>>
>>> Maybe it is just too late that I read this mail - but I do not  
>>> really
>>> understand what you want to store in these maps. Could you please  
>>> provide
>>> a
>>> little more detail on what you want to use these maps for?
>>>
>>
>> These would be optional matrix headers.
>>
>> I want the possibillity to map a name to the integer column index
>> and for columns that contain class values I want to map string  
>> values to
>> double values.
>>
>> Consider the following matrix:
>>
>> 0      | 1   | 2      |
>> Gender | Age | Name   |
>> (class)|     | (class)|
>> -----------------------
>>
>> Where class feature 0 is associated with {female=0, male=1}
>> and class feature 2 is associated with {eric=0, jan=1, isabel=2,  
>> karl=3}
>>
>>
>>       karl
>>
>>
>>
>
>
> -- 
> ted


Re: Feature names and class feature values

Posted by Ted Dunning <te...@gmail.com>.
We were talking about this same sort of capability early on.

I think that matrix rows and columns should be allowed to have String names
as well as integer indexes.

On Sat, Jun 28, 2008 at 9:54 AM, Karl Wettin <ka...@gmail.com> wrote:

>
> 27 jun 2008 kl. 20.54 skrev Isabel Drost:
>
>  On Friday 27 June 2008, Karl Wettin wrote:
>>
>>> I think it makes sense to optinally store something like Map</**column
>>> name*/String, /**column index*/Integer> and Map</**column index*/
>>> Integer, Map</*class value*/String, Double>> in AbstractMatrix.
>>>
>>
>>
>> Maybe it is just too late that I read this mail - but I do not really
>> understand what you want to store in these maps. Could you please provide
>> a
>> little more detail on what you want to use these maps for?
>>
>
> These would be optional matrix headers.
>
> I want the possibillity to map a name to the integer column index
> and for columns that contain class values I want to map string values to
> double values.
>
> Consider the following matrix:
>
> 0      | 1   | 2      |
> Gender | Age | Name   |
> (class)|     | (class)|
> -----------------------
>
> Where class feature 0 is associated with {female=0, male=1}
> and class feature 2 is associated with {eric=0, jan=1, isabel=2, karl=3}
>
>
>        karl
>
>
>


-- 
ted

Re: Feature names and class feature values

Posted by Isabel Drost <ap...@isabel-drost.de>.
On Saturday 28 June 2008, Karl Wettin wrote:
> These would be optional matrix headers.
>
> I want the possibillity to map a name to the integer column index
> and for columns that contain class values I want to map string values
> to double values.

Ah - now I understand. I remember a discussion on this topic early on as 
well - but I think back then we did not come to a final conclusion. Maybe now 
that we have the real need for headers we can come up with better interfaces 
and implementations.

Isabel

-- 
BOFH excuse #170:popper unable to process jumbo kernel
  |\      _,,,---,,_       Web:   <http://www.isabel-drost.de>
  /,`.-'`'    -.  ;-;;,_
 |,4-  ) )-,_..;\ (  `'-'
'---''(_/--'  `-'\_) (fL)  IM:  <xm...@spaceboyz.net>

Re: Feature names and class feature values

Posted by Karl Wettin <ka...@gmail.com>.
27 jun 2008 kl. 20.54 skrev Isabel Drost:

> On Friday 27 June 2008, Karl Wettin wrote:
>> I think it makes sense to optinally store something like Map</ 
>> **column
>> name*/String, /**column index*/Integer> and Map</**column index*/
>> Integer, Map</*class value*/String, Double>> in AbstractMatrix.
>
>
> Maybe it is just too late that I read this mail - but I do not really
> understand what you want to store in these maps. Could you please  
> provide a
> little more detail on what you want to use these maps for?

These would be optional matrix headers.

I want the possibillity to map a name to the integer column index
and for columns that contain class values I want to map string values  
to double values.

Consider the following matrix:

0      | 1   | 2      |
Gender | Age | Name   |
(class)|     | (class)|
-----------------------

Where class feature 0 is associated with {female=0, male=1}
and class feature 2 is associated with {eric=0, jan=1, isabel=2, karl=3}


         karl



Re: Feature names and class feature values

Posted by Isabel Drost <ap...@isabel-drost.de>.
On Friday 27 June 2008, Karl Wettin wrote:
> I think it makes sense to optinally store something like Map</**column
> name*/String, /**column index*/Integer> and Map</**column index*/
> Integer, Map</*class value*/String, Double>> in AbstractMatrix.


Maybe it is just too late that I read this mail - but I do not really 
understand what you want to store in these maps. Could you please provide a 
little more detail on what you want to use these maps for?

Isabel


-- 
Youth had been a habit of hers so long that she could not part with it.
  |\      _,,,---,,_       Web:   <http://www.isabel-drost.de>
  /,`.-'`'    -.  ;-;;,_
 |,4-  ) )-,_..;\ (  `'-'
'---''(_/--'  `-'\_) (fL)  IM:  <xm...@spaceboyz.net>