You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spark.apache.org by Nick Pentreath <ni...@gmail.com> on 2013/07/24 10:46:17 UTC

Machine Learning on Spark [long rambling discussion email]

Hi dev team

(Apologies for a long email!)

Firstly great news about the inclusion of MLlib into the Spark project!

I've been working on a concept and some code for a machine learning library
on Spark, and so of course there is a lot of overlap between MLlib and what
I've been doing.

I wanted to throw this out there and (a) ask a couple of design and roadmap
questions about MLLib, and (b) talk about how to work together / integrate
my ideas (if at all :)

*Some questions*
*
*
1. What is the general design idea behind MLLib - is it aimed at being a
collection of algorithms, ie a library? Or is it aimed at being a "Mahout
for Spark", i.e. something that can be used as a library as well as a set
of tools for things like running jobs, feature extraction, text processing
etc?
2. How married are we to keeping it within the Spark project? While I
understand the reasoning behind it I am not convinced it's best. But I
guess we can wait and see how it develops
3. Some of the original test code I saw around the Block ALS did use Breeze
(https://github.com/dlwh/breeze) for some of the linear algebra. Now I see
everything is using JBLAS directly and Array[Double]. Is there a specific
reason for this? Is it aimed at creating a separation whereby the linear
algebra backend could be switched out? Scala 2.10 issues?
4. Since Spark is meant to be nicely compatible with Hadoop, do we care
about compatibility/integration with Mahout? This may also encourage Mahout
developers to switch over and contribute their expertise (see for example
Dmitry's work at:
https://github.com/dlyubimov/mahout-commits/commits/dev-0.8.x-scala/math-scala,
where he is doing a Scala/Spark DSL around mahout-math matrices and
distributed operations). Potentially even using mahout-math for linear
algebra routines?
5. Is there a roadmap? (I've checked the JIRA which does have a few
intended models etc). Who are the devs most involved in this project?
6. What are thoughts around API design for models?

*Some thoughts*
*
*
So, over the past couple of months I have been working on a machine
learning library. Initially it was for my own use but I've added a few
things and was starting to think about releasing it (though it's not nearly
ready). The model that I really needed first was ALS for doing
recommendations. So I have ported the ALS code from Mahout to Spark. Well,
"ported" in some sense - mostly I copied the algorithm and data
distribution design, using Spark's primitives and Breeze for all the linear
algebra.

I found it pretty straightforward to port over. So far I have done local
testing only on the Movielens datasets. I have found my RMSE results to
match that of Mahout's. Overall interestingly the wall clock performance is
not as dissimilar as I would have expected. But I would like to now do some
larger-scale tests on a cluster to really do a good comparison.

Obviously with Spark's Block ALS model, my version is now somewhat
superfluous since I expect (and have so far seen in my simple local
experiments) that the block model will significantly outperform. I will
probably be porting my use case over to this in due time once I've done
further testing.

I also found Breeze to be very nice to work with and like the DSL - hence
my question about why not use that? (Especially now that Breeze is actually
just breeze-math and breeze-viz).

Anyway, I then added KMeans (basically just the Spark example with some
Breeze tweaks), and started working on a Linear Model framework. I've also
added a simple framework for arg parsing and config (using Twitter
Algebird's Args and Typesafe Config), and have started on feature
extraction stuff - of particular interest will be text feature extraction
and feature hashing.

This is roughly the idea for a machine learning library on Spark that I
have - call it a design or manifesto or whatever:

- Library available and consistent across Scala, Java and Python (as much
as possible in any event)
- A core library and also a set of stuff for easily running models based on
standard input formats etc
- Standardised model API (even across languages) to the extent possible.
I've based mine so far on Python's scikit-learn (.fit(), .predict() etc).
Why? I believe it's a major strength of scikit-learn, that its API is so
clean, simple and consistent. Plus, for the Python version of the lib,
scikit-learn will no doubt be used wherever possible to avoid re-creating
code
- Models to be included initially:
  - ALS
  - Possibly co-occurrence recommendation stuff similar to Mahout's Taste
  - Clustering (K-Means and others potentially)
  - Linear Models - the idea here is to have something very close to Vowpal
Wabbit, ie a generic SGD engine with various Loss Functions, learning rate
paradigms etc. Furthermore this would allow other models similar to VW such
as online versions of matrix factorisation, neural nets and learning
reductions
  - Possibly Decision Trees / Random Forests
- Some utilities for feature extraction (hashing in particular), and to
make running jobs easy (integration with Spark's ./run etc?)
- Stuff for making pipelining easy (like scikit-learn) and for doing things
like cross-validation in a principled (and parallel) way
- Clean and easy integration with Spark Streaming for online models (e.g. a
linear SGD can be called with fit() on batch data, and then fit() and/or
fit/predict() on streaming data to learn further online etc).
- Interactivity provided by shells (IPython, Spark shell) and also plotting
capability (Matplotlib, and Breeze Viz)
- For Scala, integration with Shark via sql2rdd etc.
- I'd like to create something similar to Scalding's Matrix API based on
RDDs for representing distributed matrices, as well as integrate the ideas
of Dmitry and Mahout's DistributedRowMatrix etc

Here is a rough outline of the model API I have used at the moment:
https://gist.github.com/MLnick/6068841. This works nicely for ALS,
clustering, linear models etc.

So as you can see, mostly overlapping with what MLlib already has or has
planned in some way, but my main aim is frankly to have consistency in the
API, some level of abstraction but to keep things as simple as possible (ie
let Spark handle the complex stuff), and thus hopefully avoid things
becoming just a somewhat haphazard collection of models that is not that
simple to figure out how to use - which is unfortunately what I believe has
happened to Mahout.

So the question then is, how to work together or integrate? I see 3 options:

1. I go my own way (not very appealing obviously)
2. Contribute what I have (or as much as makes sense) to MLlib
3. Create my project as a "front-end" or "wrapper" around MLlib as the
core, effectively providing the API and workflow interface but using MLlib
as the model engine.

#2 is appealing but then a lot depends on the API and framework design and
how much what I have in mind is compatible with the rest of the devs etc
#3 now that I have written it, starts to sound pretty interesting -
potentially we're looking at a "front-end" that could in fact execute
models on Spark (or other engines like Hadoop/Mahout, GraphX etc), while
providing workflows for pipelining transformations, feature extraction,
testing and cross-validation, and data viz.

But of course #3 starts sounding somewhat like what MLBase is aiming to be
(I think)!

At this point I'm willing to show out what I have done so far on a
selective basis - be warned though it is rough and not finished and
somewhat clunky perhaps as it's my first attempt at a library/framework, if
it makes sense. Especially because really the main thing I did was the ALS
port, and with MLlib's version of ALS that may be less useful now in any
case.

It may be that none of this is that useful to others anyway which is fine
as I'll keep developing tools that I need and potentially they will be
useful at some point.

Thoughts, feedback, comments, discussion? I really want to jump into MLlib
and get involved in contributing to standardised machine learning on Spark!

Nick

Re: Machine Learning on Spark [long rambling discussion email]

Posted by Dmitriy Lyubimov <dl...@gmail.com>.
On Wed, Jul 24, 2013 at 11:47 AM, Reynold Xin <rx...@cs.berkeley.edu> wrote:

> On Wed, Jul 24, 2013 at 1:46 AM, Nick Pentreath <nick.pentreath@gmail.com
> >wrote:
>
> >
> > I also found Breeze to be very nice to work with and like the DSL - hence
> > my question about why not use that? (Especially now that Breeze is
> actually
> > just breeze-math and breeze-viz).
> >
>
>
> Matei addressed this from a higher level. I want to provide a little bit
> more context. A common properties of a lot of high level Scala DSL
> libraries is that simple operators tend to have high virtual function
> overheads and also create a lot of temporary objects. And because the level
> of abstraction is so high, it is fairly hard to debug / optimize
> performance.
>

I was *kinda* worried about it too.

But like it often happens, it would seem to me we are worrying about
somethign that will never compare with the bulk computation.

Consider this fragment (it is from one of the flavors of weighted ALS with
weighted regularization) :


        val cholArg =  icVtV + (vBlockForC.t %*%: diagv(d)) %*% vBlockForC
+ diag(n_u * lambda, k)


yes we  just created a few object references here for GC with scala
implicit conversions while having million flops behind the scene sent to
FPU meanwhile AND we  have optimized left-multiply (%*%: operator)  with a
diagonal matrix as well as made use of symmetric matrix optimizations in a
very scala way. And it looks just like what R folks would understand. The
benefits of DSL clearly outweigh whatever claimed overhead exists IMO.
Can't deny i find it subjectively more elegant than
vblock.transpose().times(....new DiagonalMatrix (n_u*lambda,k) ... )


As far as Mahout abstraction quality (and i am assuming we are talking
about in-core lin alg support here, cause there's much more else), this is
debatable but that's why i actually started doing DSL in the first place.
DSL should iron a lot of that out, as we have seen, and bring it closer to
R/matlab look&feel.

But there are other important factors about Mahout's in-core support.

I did my honest homework for my project trying to pick on in-core linear
algebra, and i was not stuck on Mahout in-core support at all. I actually
really wanted to find something a bit more mature for in-core algebra.

In my search, I failed to find a project to address the following two major
problems for in-core BLAS:

1) naturally embedded support for sparse matrices and optimizations aimed
degenerate nature of zero elements. No other project quite doing it to the
same degree. apache-math sparse matrices are deprecated and said to be
broken. JBLAS/ LAPACK doesn't have degenerate element optimizations at all.
Breeze lacks consistency in Matrix abstraction between sparse and dense
matrices. etc. etc.

2) Kind of extension of the 1, wide range of matrix support optimized for
various speicific solver computations -- diagonal, upper/lower triangulars,
symmetric parsimonious, pivoted, rowwise vs. column wise vs. open addressed
sparse matrices etc. etc. especially with the latest effort there. Nobody
came close to that variety and ease of sparse operation optimizations in my
(however brief) search.

it is kinda raw at times, but nothing that i can't handle.

But i totally agree that any sort of such environment is not part of spark.
It makes some pragmatic tasks very addressable though and i can see a
roadmap where i could mix Mahout's distributed solvers with sparks freely
until i have a chance to port/create more what i need on spark side without
any additional format/conversion issues.




>
>
>
> --
> Reynold Xin, AMPLab, UC Berkeley
> http://rxin.org
>

Re: Machine Learning on Spark [long rambling discussion email]

Posted by Patrick Wendell <pw...@gmail.com>.
---
sent from my phone
On Jul 25, 2013 6:44 AM, "Nick Pentreath" <ni...@gmail.com> wrote:

> Hi
>
> Ok, that all makes sense. I can see the benefit of good standard libraries
> definitely, and I guess the pieces that felt "missing" to me were what you
> are describing as MLI and MLOptimizer.
>
> It seems like the aims of MLI are very much in line with what I have/had in
> mind for a ML library/framework. It seems the goals overlap quite a lot.
>
> I guess one "frustration" I have had is that there are all these great BDAS
> projects, but we never really know when they will be released and what they
> will look like until they are. In this particular case I couldn't wait for
> MLlib so ended up doing some work myself to port Mahout's ALS and of course
> have ended up duplicating effort (which is not a problem as it was
> necessary at the time and has been a great learning experience).
>
> Similarly for GraphX, I would like to develop a project for a Spark-based
> version of Faunus (https://github.com/thinkaurelius/faunus) for batch
> processing of data in our Titan graph DB. For now I am working with
> Bagel-based primitives and Spark RDDs directly, but would love to use
> GraphX, but have no idea when it will be released and have little
> involvement until it is.
>
> (I use "frustration" in the nicest way here - I love the BDAS concepts and
> all the projects coming out, I just want them all to be released NOW!! :)
>
> So yes I would love to be involved in MLlib and MLI work to the extent I
> can assist and the work is aligned with what I need currently in my
> projects (this is just from a time allocation viewpoint - I'm sure much of
> it will be complementary).
>
> Anyway, it seems to me the best course of action is as follows:
>
>    - I'll get involved in MLlib and see how I can contribute there. Some
>    things that jump out:
>
>
>    - implicit preference capability for ALS model since as far as I can see
>       currently it handles explicit prefs only? (Implicit prefs here:
>       http://68.180.206.246/files/HuKorenVolinsky-ICDM08.pdf which is
>       typically better if we don't have actual rating data but instead
> "view",
>       "click", "play" or whatever)
>       - RMSE and other evaluation metrics for ALS as well as test/train
>       split / cross-val stuff?
>       - linear model additions, like new loss functions for hinge loss,
>       least squares etc for SGD, as well as learning rate stuff (
>       http://arxiv.org/pdf/1305.6646) and regularisers (L1/L2/Elasic Net)
> -
>       i.e. bring the SGD stuff in line with Vowpal Wabbit / sklearn (if
> that's
>       desirable, my view is yes)
>       - what about sparse weight and feature vectors for linear models/SGD?
>       Together with hashing allows very large models while still being
> efficient,
>       and with L1 reg is particularly useful.
>       - finally what about online models? ie SGD models currently are
>       "static" ie once trained can only predict, whereas SGD can of course
> keep
>       learning. Or does one simply re-train with the previous initial
> weight
>       vector (I guess that can work just as well)... Also on this
> topic training
>       / predicting on Streams as well as RDDs
>    - I can put up what I have done to a BitBucket account and grant access
>    to whichever devs would like to take a look. The only reason I don't
> just
>    throw it up on GitHub is that frankly it is not really ready and is not
> a
>    fully-fledged project yet (I think anyway). Possibly some of this can be
>    useful (not that there's all that much there apart from the ALS (but it
>    does solve for both explicit and implicit preference data as per
> Mahout's
>    implementation), KMeans (simpler than the one in MLlib as I didn't yet
> get
>    around to doing KMeans++ init) and the arg-parsing / jobrunner (which
> may
>    or may not be interesting both for ML and for Spark jobs in general)).
>
> Let me know your thoughts
> Nick
>
>
> On Wed, Jul 24, 2013 at 10:09 PM, Ameet Talwalkar
> <am...@eecs.berkeley.edu>wrote:
>
> > Hi Nick,
> >
> > Thanks for your email, and it's great to see such excitement around this
> > work!  Matei and Reynold already addressed the motivation behind MLlib as
> > well as our reasons for not using Breeze, and I'd like to give you some
> > background about MLbase, and discuss how it may fit with your interests.
> >
> > There are three components of MLbase:
> >
> > 1) MLlib: As Matei mentioned, this is an ML library in Spark with core ML
> > kernels and solid implementations of common algorithms that can be used
> > easily by Java/Python and also called into by higher-level systems (e.g.
> > MLI, Shark, PySpark).
> >
> > 2) MLI: this is an ML API that provides a common interface for ML
> > algorithms (the same interface used in MLlib), and introduces high-level
> > abstractions to simplify feature extraction / exploration and ML
> algorithm
> > development.  These abstractions leverage the kernels in MLlib when
> > possible, and also introduce additional kernels.  This work also
> includes a
> > library written against the MLI.  The MLI is currently written against
> > Spark, but is designed to be platform independent, so that code written
> > against MLI could be run on different engines (e.g., Hadoop, GraphX,
> etc.).
> >
> >
> > 3) ML Optimizer: This piece automates the task of model selection.  The
> > optimizer can be viewed as a search problem over feature extraction /
> > algorithms included in the MLI library, and is in part based on efficient
> > cross validation. This work is under active development but is in an
> > earlier stage of development than MLlib and MLI.
> >
> > (note: MLlib will be included with the Spark codebase, while the MLI and
> ML
> > Optimizer will live in separate repositories.)
> >
> > As far as I can tell (though please correct me if I've misunderstood)
> your
> > main goals include:
> >
> > i) "consistency in the API"
> > ii) "some level of abstraction but to keep things as simple as possible"
> > iii) "execute models on Spark ... while providing workflows for
> pipelining
> > transformations, feature extraction, testing and cross-validation, and
> data
> > viz."
> >
> > The MLI (and to some extent the ML Optimizer) is very much in line with
> > these goals, and it would be great if you were interested in contributing
> > to it.  MLI is a private repository right now, but we'll make it public
> > soon though, and Evan Sparks or I will let you know when we do so.
> >
> > Thanks again for getting in touch with us!
> >
> > -Ameet
> >
> >
> > On Wed, Jul 24, 2013 at 11:47 AM, Reynold Xin <rx...@cs.berkeley.edu>
> > wrote:
> >
> > > On Wed, Jul 24, 2013 at 1:46 AM, Nick Pentreath <
> > nick.pentreath@gmail.com
> > > >wrote:
> > >
> > > >
> > > > I also found Breeze to be very nice to work with and like the DSL -
> > hence
> > > > my question about why not use that? (Especially now that Breeze is
> > > actually
> > > > just breeze-math and breeze-viz).
> > > >
> > >
> > >
> > > Matei addressed this from a higher level. I want to provide a little
> bit
> > > more context. A common properties of a lot of high level Scala DSL
> > > libraries is that simple operators tend to have high virtual function
> > > overheads and also create a lot of temporary objects. And because the
> > level
> > > of abstraction is so high, it is fairly hard to debug / optimize
> > > performance.
> > >
> > >
> > >
> > >
> > > --
> > > Reynold Xin, AMPLab, UC Berkeley
> > > http://rxin.org
> > >
> >
>

Re: Machine Learning on Spark [long rambling discussion email]

Posted by Nick Pentreath <ni...@gmail.com>.
Cool I totally understand the constraints you're under and it's not really a criticism at all - the amplab projects are all awesome!


If I can find ways to help then all the better
—
Sent from Mailbox for iPhone

On Thu, Jul 25, 2013 at 10:04 PM, Matei Zaharia <ma...@gmail.com>
wrote:

> I fully agree that we need to be clearer with the timelines in AMP Lab. One thing is that many of these are still research projects, so it's hard to predict when they will be ready for prime-time. Usually with all the things we officially announce (e.g. MLlib, GraphX), and especially the things we put in the Spark codebase, the team behind them really wants to make them widely available and has committed to spend the engineering to make them usable in real applications (as opposed to prototyping and moving on). But even then it can take some time to get the first release out. Hopefully we'll improve our communication about this through more careful tracking in JIRA.
> Matei
> On Jul 25, 2013, at 11:41 AM, Ameet Talwalkar <am...@eecs.berkeley.edu> wrote:
>> Hi Nick,
>> 
>> I can understand your 'frustration' -- my hope is that having discussions
>> (like the one we're having now) via this mailing list will help mitigate
>> duplicate work moving forward.
>> 
>> Regarding your detailed comments, we are aiming to include various
>> components that you mentioned in our release (basic evaluation for
>> collaborative filtering, linear model additions, and basic support for
>> sparse vectors/features).  One particularly interesting avenue that is not
>> on our immediate roadmap is adding implicit feedback for matrix
>> factorization.  Algorithms like SVD++ are often used in practice, and it
>> would be great to add them to the MLI library (and perhaps also MLlib).
>> 
>> -Ameet
>> 
>> 
>> On Thu, Jul 25, 2013 at 6:44 AM, Nick Pentreath <ni...@gmail.com>wrote:
>> 
>>> Hi
>>> 
>>> Ok, that all makes sense. I can see the benefit of good standard libraries
>>> definitely, and I guess the pieces that felt "missing" to me were what you
>>> are describing as MLI and MLOptimizer.
>>> 
>>> It seems like the aims of MLI are very much in line with what I have/had in
>>> mind for a ML library/framework. It seems the goals overlap quite a lot.
>>> 
>>> I guess one "frustration" I have had is that there are all these great BDAS
>>> projects, but we never really know when they will be released and what they
>>> will look like until they are. In this particular case I couldn't wait for
>>> MLlib so ended up doing some work myself to port Mahout's ALS and of course
>>> have ended up duplicating effort (which is not a problem as it was
>>> necessary at the time and has been a great learning experience).
>>> 
>>> Similarly for GraphX, I would like to develop a project for a Spark-based
>>> version of Faunus (https://github.com/thinkaurelius/faunus) for batch
>>> processing of data in our Titan graph DB. For now I am working with
>>> Bagel-based primitives and Spark RDDs directly, but would love to use
>>> GraphX, but have no idea when it will be released and have little
>>> involvement until it is.
>>> 
>>> (I use "frustration" in the nicest way here - I love the BDAS concepts and
>>> all the projects coming out, I just want them all to be released NOW!! :)
>>> 
>>> So yes I would love to be involved in MLlib and MLI work to the extent I
>>> can assist and the work is aligned with what I need currently in my
>>> projects (this is just from a time allocation viewpoint - I'm sure much of
>>> it will be complementary).
>>> 
>>> Anyway, it seems to me the best course of action is as follows:
>>> 
>>>   - I'll get involved in MLlib and see how I can contribute there. Some
>>>   things that jump out:
>>> 
>>> 
>>>   - implicit preference capability for ALS model since as far as I can see
>>>      currently it handles explicit prefs only? (Implicit prefs here:
>>>      http://68.180.206.246/files/HuKorenVolinsky-ICDM08.pdf which is
>>>      typically better if we don't have actual rating data but instead
>>> "view",
>>>      "click", "play" or whatever)
>> 
>>      - RMSE and other evaluation metrics for ALS as well as test/train
>>>      split / cross-val stuff?
>> 
>>      - linear model additions, like new loss functions for hinge loss,
>>>      least squares etc for SGD, as well as learning rate stuff (
>>>      http://arxiv.org/pdf/1305.6646) and regularisers (L1/L2/Elasic Net)
>>> -
>>>      i.e. bring the SGD stuff in line with Vowpal Wabbit / sklearn (if
>>> that's
>>>      desirable, my view is yes)
>> 
>>      - what about sparse weight and feature vectors for linear models/SGD?
>>>      Together with hashing allows very large models while still being
>>> efficient,
>>>      and with L1 reg is particularly useful.
>> 
>>      - finally what about online models? ie SGD models currently are
>>>      "static" ie once trained can only predict, whereas SGD can of course
>>> keep
>>>      learning. Or does one simply re-train with the previous initial
>>> weight
>>>      vector (I guess that can work just as well)... Also on this
>>> topic training
>>>      / predicting on Streams as well as RDDs
>>>   - I can put up what I have done to a BitBucket account and grant access
>>>   to whichever devs would like to take a look. The only reason I don't
>>> just
>>>   throw it up on GitHub is that frankly it is not really ready and is not
>>> a
>>>   fully-fledged project yet (I think anyway). Possibly some of this can be
>>>   useful (not that there's all that much there apart from the ALS (but it
>>>   does solve for both explicit and implicit preference data as per
>>> Mahout's
>>>   implementation), KMeans (simpler than the one in MLlib as I didn't yet
>>> get
>>>   around to doing KMeans++ init) and the arg-parsing / jobrunner (which
>>> may
>>>   or may not be interesting both for ML and for Spark jobs in general)).
>>> 
>>> Let me know your thoughts
>>> Nick
>>> 
>>> 
>>> On Wed, Jul 24, 2013 at 10:09 PM, Ameet Talwalkar
>>> <am...@eecs.berkeley.edu>wrote:
>>> 
>>>> Hi Nick,
>>>> 
>>>> Thanks for your email, and it's great to see such excitement around this
>>>> work!  Matei and Reynold already addressed the motivation behind MLlib as
>>>> well as our reasons for not using Breeze, and I'd like to give you some
>>>> background about MLbase, and discuss how it may fit with your interests.
>>>> 
>>>> There are three components of MLbase:
>>>> 
>>>> 1) MLlib: As Matei mentioned, this is an ML library in Spark with core ML
>>>> kernels and solid implementations of common algorithms that can be used
>>>> easily by Java/Python and also called into by higher-level systems (e.g.
>>>> MLI, Shark, PySpark).
>>>> 
>>>> 2) MLI: this is an ML API that provides a common interface for ML
>>>> algorithms (the same interface used in MLlib), and introduces high-level
>>>> abstractions to simplify feature extraction / exploration and ML
>>> algorithm
>>>> development.  These abstractions leverage the kernels in MLlib when
>>>> possible, and also introduce additional kernels.  This work also
>>> includes a
>>>> library written against the MLI.  The MLI is currently written against
>>>> Spark, but is designed to be platform independent, so that code written
>>>> against MLI could be run on different engines (e.g., Hadoop, GraphX,
>>> etc.).
>>>> 
>>>> 
>>>> 3) ML Optimizer: This piece automates the task of model selection.  The
>>>> optimizer can be viewed as a search problem over feature extraction /
>>>> algorithms included in the MLI library, and is in part based on efficient
>>>> cross validation. This work is under active development but is in an
>>>> earlier stage of development than MLlib and MLI.
>>>> 
>>>> (note: MLlib will be included with the Spark codebase, while the MLI and
>>> ML
>>>> Optimizer will live in separate repositories.)
>>>> 
>>>> As far as I can tell (though please correct me if I've misunderstood)
>>> your
>>>> main goals include:
>>>> 
>>>> i) "consistency in the API"
>>>> ii) "some level of abstraction but to keep things as simple as possible"
>>>> iii) "execute models on Spark ... while providing workflows for
>>> pipelining
>>>> transformations, feature extraction, testing and cross-validation, and
>>> data
>>>> viz."
>>>> 
>>>> The MLI (and to some extent the ML Optimizer) is very much in line with
>>>> these goals, and it would be great if you were interested in contributing
>>>> to it.  MLI is a private repository right now, but we'll make it public
>>>> soon though, and Evan Sparks or I will let you know when we do so.
>>>> 
>>>> Thanks again for getting in touch with us!
>>>> 
>>>> -Ameet
>>>> 
>>>> 
>>>> On Wed, Jul 24, 2013 at 11:47 AM, Reynold Xin <rx...@cs.berkeley.edu>
>>>> wrote:
>>>> 
>>>>> On Wed, Jul 24, 2013 at 1:46 AM, Nick Pentreath <
>>>> nick.pentreath@gmail.com
>>>>>> wrote:
>>>>> 
>>>>>> 
>>>>>> I also found Breeze to be very nice to work with and like the DSL -
>>>> hence
>>>>>> my question about why not use that? (Especially now that Breeze is
>>>>> actually
>>>>>> just breeze-math and breeze-viz).
>>>>>> 
>>>>> 
>>>>> 
>>>>> Matei addressed this from a higher level. I want to provide a little
>>> bit
>>>>> more context. A common properties of a lot of high level Scala DSL
>>>>> libraries is that simple operators tend to have high virtual function
>>>>> overheads and also create a lot of temporary objects. And because the
>>>> level
>>>>> of abstraction is so high, it is fairly hard to debug / optimize
>>>>> performance.
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> --
>>>>> Reynold Xin, AMPLab, UC Berkeley
>>>>> http://rxin.org
>>>>> 
>>>> 
>>> 

Re: Machine Learning on Spark [long rambling discussion email]

Posted by Matei Zaharia <ma...@gmail.com>.
I fully agree that we need to be clearer with the timelines in AMP Lab. One thing is that many of these are still research projects, so it's hard to predict when they will be ready for prime-time. Usually with all the things we officially announce (e.g. MLlib, GraphX), and especially the things we put in the Spark codebase, the team behind them really wants to make them widely available and has committed to spend the engineering to make them usable in real applications (as opposed to prototyping and moving on). But even then it can take some time to get the first release out. Hopefully we'll improve our communication about this through more careful tracking in JIRA.

Matei

On Jul 25, 2013, at 11:41 AM, Ameet Talwalkar <am...@eecs.berkeley.edu> wrote:

> Hi Nick,
> 
> I can understand your 'frustration' -- my hope is that having discussions
> (like the one we're having now) via this mailing list will help mitigate
> duplicate work moving forward.
> 
> Regarding your detailed comments, we are aiming to include various
> components that you mentioned in our release (basic evaluation for
> collaborative filtering, linear model additions, and basic support for
> sparse vectors/features).  One particularly interesting avenue that is not
> on our immediate roadmap is adding implicit feedback for matrix
> factorization.  Algorithms like SVD++ are often used in practice, and it
> would be great to add them to the MLI library (and perhaps also MLlib).
> 
> -Ameet
> 
> 
> On Thu, Jul 25, 2013 at 6:44 AM, Nick Pentreath <ni...@gmail.com>wrote:
> 
>> Hi
>> 
>> Ok, that all makes sense. I can see the benefit of good standard libraries
>> definitely, and I guess the pieces that felt "missing" to me were what you
>> are describing as MLI and MLOptimizer.
>> 
>> It seems like the aims of MLI are very much in line with what I have/had in
>> mind for a ML library/framework. It seems the goals overlap quite a lot.
>> 
>> I guess one "frustration" I have had is that there are all these great BDAS
>> projects, but we never really know when they will be released and what they
>> will look like until they are. In this particular case I couldn't wait for
>> MLlib so ended up doing some work myself to port Mahout's ALS and of course
>> have ended up duplicating effort (which is not a problem as it was
>> necessary at the time and has been a great learning experience).
>> 
>> Similarly for GraphX, I would like to develop a project for a Spark-based
>> version of Faunus (https://github.com/thinkaurelius/faunus) for batch
>> processing of data in our Titan graph DB. For now I am working with
>> Bagel-based primitives and Spark RDDs directly, but would love to use
>> GraphX, but have no idea when it will be released and have little
>> involvement until it is.
>> 
>> (I use "frustration" in the nicest way here - I love the BDAS concepts and
>> all the projects coming out, I just want them all to be released NOW!! :)
>> 
>> So yes I would love to be involved in MLlib and MLI work to the extent I
>> can assist and the work is aligned with what I need currently in my
>> projects (this is just from a time allocation viewpoint - I'm sure much of
>> it will be complementary).
>> 
>> Anyway, it seems to me the best course of action is as follows:
>> 
>>   - I'll get involved in MLlib and see how I can contribute there. Some
>>   things that jump out:
>> 
>> 
>>   - implicit preference capability for ALS model since as far as I can see
>>      currently it handles explicit prefs only? (Implicit prefs here:
>>      http://68.180.206.246/files/HuKorenVolinsky-ICDM08.pdf which is
>>      typically better if we don't have actual rating data but instead
>> "view",
>>      "click", "play" or whatever)
> 
>      - RMSE and other evaluation metrics for ALS as well as test/train
>>      split / cross-val stuff?
> 
>      - linear model additions, like new loss functions for hinge loss,
>>      least squares etc for SGD, as well as learning rate stuff (
>>      http://arxiv.org/pdf/1305.6646) and regularisers (L1/L2/Elasic Net)
>> -
>>      i.e. bring the SGD stuff in line with Vowpal Wabbit / sklearn (if
>> that's
>>      desirable, my view is yes)
> 
>      - what about sparse weight and feature vectors for linear models/SGD?
>>      Together with hashing allows very large models while still being
>> efficient,
>>      and with L1 reg is particularly useful.
> 
>      - finally what about online models? ie SGD models currently are
>>      "static" ie once trained can only predict, whereas SGD can of course
>> keep
>>      learning. Or does one simply re-train with the previous initial
>> weight
>>      vector (I guess that can work just as well)... Also on this
>> topic training
>>      / predicting on Streams as well as RDDs
>>   - I can put up what I have done to a BitBucket account and grant access
>>   to whichever devs would like to take a look. The only reason I don't
>> just
>>   throw it up on GitHub is that frankly it is not really ready and is not
>> a
>>   fully-fledged project yet (I think anyway). Possibly some of this can be
>>   useful (not that there's all that much there apart from the ALS (but it
>>   does solve for both explicit and implicit preference data as per
>> Mahout's
>>   implementation), KMeans (simpler than the one in MLlib as I didn't yet
>> get
>>   around to doing KMeans++ init) and the arg-parsing / jobrunner (which
>> may
>>   or may not be interesting both for ML and for Spark jobs in general)).
>> 
>> Let me know your thoughts
>> Nick
>> 
>> 
>> On Wed, Jul 24, 2013 at 10:09 PM, Ameet Talwalkar
>> <am...@eecs.berkeley.edu>wrote:
>> 
>>> Hi Nick,
>>> 
>>> Thanks for your email, and it's great to see such excitement around this
>>> work!  Matei and Reynold already addressed the motivation behind MLlib as
>>> well as our reasons for not using Breeze, and I'd like to give you some
>>> background about MLbase, and discuss how it may fit with your interests.
>>> 
>>> There are three components of MLbase:
>>> 
>>> 1) MLlib: As Matei mentioned, this is an ML library in Spark with core ML
>>> kernels and solid implementations of common algorithms that can be used
>>> easily by Java/Python and also called into by higher-level systems (e.g.
>>> MLI, Shark, PySpark).
>>> 
>>> 2) MLI: this is an ML API that provides a common interface for ML
>>> algorithms (the same interface used in MLlib), and introduces high-level
>>> abstractions to simplify feature extraction / exploration and ML
>> algorithm
>>> development.  These abstractions leverage the kernels in MLlib when
>>> possible, and also introduce additional kernels.  This work also
>> includes a
>>> library written against the MLI.  The MLI is currently written against
>>> Spark, but is designed to be platform independent, so that code written
>>> against MLI could be run on different engines (e.g., Hadoop, GraphX,
>> etc.).
>>> 
>>> 
>>> 3) ML Optimizer: This piece automates the task of model selection.  The
>>> optimizer can be viewed as a search problem over feature extraction /
>>> algorithms included in the MLI library, and is in part based on efficient
>>> cross validation. This work is under active development but is in an
>>> earlier stage of development than MLlib and MLI.
>>> 
>>> (note: MLlib will be included with the Spark codebase, while the MLI and
>> ML
>>> Optimizer will live in separate repositories.)
>>> 
>>> As far as I can tell (though please correct me if I've misunderstood)
>> your
>>> main goals include:
>>> 
>>> i) "consistency in the API"
>>> ii) "some level of abstraction but to keep things as simple as possible"
>>> iii) "execute models on Spark ... while providing workflows for
>> pipelining
>>> transformations, feature extraction, testing and cross-validation, and
>> data
>>> viz."
>>> 
>>> The MLI (and to some extent the ML Optimizer) is very much in line with
>>> these goals, and it would be great if you were interested in contributing
>>> to it.  MLI is a private repository right now, but we'll make it public
>>> soon though, and Evan Sparks or I will let you know when we do so.
>>> 
>>> Thanks again for getting in touch with us!
>>> 
>>> -Ameet
>>> 
>>> 
>>> On Wed, Jul 24, 2013 at 11:47 AM, Reynold Xin <rx...@cs.berkeley.edu>
>>> wrote:
>>> 
>>>> On Wed, Jul 24, 2013 at 1:46 AM, Nick Pentreath <
>>> nick.pentreath@gmail.com
>>>>> wrote:
>>>> 
>>>>> 
>>>>> I also found Breeze to be very nice to work with and like the DSL -
>>> hence
>>>>> my question about why not use that? (Especially now that Breeze is
>>>> actually
>>>>> just breeze-math and breeze-viz).
>>>>> 
>>>> 
>>>> 
>>>> Matei addressed this from a higher level. I want to provide a little
>> bit
>>>> more context. A common properties of a lot of high level Scala DSL
>>>> libraries is that simple operators tend to have high virtual function
>>>> overheads and also create a lot of temporary objects. And because the
>>> level
>>>> of abstraction is so high, it is fairly hard to debug / optimize
>>>> performance.
>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> Reynold Xin, AMPLab, UC Berkeley
>>>> http://rxin.org
>>>> 
>>> 
>> 


Re: Machine Learning on Spark [long rambling discussion email]

Posted by Ameet Talwalkar <am...@eecs.berkeley.edu>.
Hi Nick,

I can understand your 'frustration' -- my hope is that having discussions
(like the one we're having now) via this mailing list will help mitigate
duplicate work moving forward.

Regarding your detailed comments, we are aiming to include various
components that you mentioned in our release (basic evaluation for
collaborative filtering, linear model additions, and basic support for
sparse vectors/features).  One particularly interesting avenue that is not
on our immediate roadmap is adding implicit feedback for matrix
factorization.  Algorithms like SVD++ are often used in practice, and it
would be great to add them to the MLI library (and perhaps also MLlib).

-Ameet


On Thu, Jul 25, 2013 at 6:44 AM, Nick Pentreath <ni...@gmail.com>wrote:

> Hi
>
> Ok, that all makes sense. I can see the benefit of good standard libraries
> definitely, and I guess the pieces that felt "missing" to me were what you
> are describing as MLI and MLOptimizer.
>
> It seems like the aims of MLI are very much in line with what I have/had in
> mind for a ML library/framework. It seems the goals overlap quite a lot.
>
> I guess one "frustration" I have had is that there are all these great BDAS
> projects, but we never really know when they will be released and what they
> will look like until they are. In this particular case I couldn't wait for
> MLlib so ended up doing some work myself to port Mahout's ALS and of course
> have ended up duplicating effort (which is not a problem as it was
> necessary at the time and has been a great learning experience).
>
> Similarly for GraphX, I would like to develop a project for a Spark-based
> version of Faunus (https://github.com/thinkaurelius/faunus) for batch
> processing of data in our Titan graph DB. For now I am working with
> Bagel-based primitives and Spark RDDs directly, but would love to use
> GraphX, but have no idea when it will be released and have little
> involvement until it is.
>
> (I use "frustration" in the nicest way here - I love the BDAS concepts and
> all the projects coming out, I just want them all to be released NOW!! :)
>
> So yes I would love to be involved in MLlib and MLI work to the extent I
> can assist and the work is aligned with what I need currently in my
> projects (this is just from a time allocation viewpoint - I'm sure much of
> it will be complementary).
>
> Anyway, it seems to me the best course of action is as follows:
>
>    - I'll get involved in MLlib and see how I can contribute there. Some
>    things that jump out:
>
>
>    - implicit preference capability for ALS model since as far as I can see
>       currently it handles explicit prefs only? (Implicit prefs here:
>       http://68.180.206.246/files/HuKorenVolinsky-ICDM08.pdf which is
>       typically better if we don't have actual rating data but instead
> "view",
>       "click", "play" or whatever)

      - RMSE and other evaluation metrics for ALS as well as test/train
>       split / cross-val stuff?

      - linear model additions, like new loss functions for hinge loss,
>       least squares etc for SGD, as well as learning rate stuff (
>       http://arxiv.org/pdf/1305.6646) and regularisers (L1/L2/Elasic Net)
> -
>       i.e. bring the SGD stuff in line with Vowpal Wabbit / sklearn (if
> that's
>       desirable, my view is yes)

      - what about sparse weight and feature vectors for linear models/SGD?
>       Together with hashing allows very large models while still being
> efficient,
>       and with L1 reg is particularly useful.

      - finally what about online models? ie SGD models currently are
>       "static" ie once trained can only predict, whereas SGD can of course
> keep
>       learning. Or does one simply re-train with the previous initial
> weight
>       vector (I guess that can work just as well)... Also on this
> topic training
>       / predicting on Streams as well as RDDs
>    - I can put up what I have done to a BitBucket account and grant access
>    to whichever devs would like to take a look. The only reason I don't
> just
>    throw it up on GitHub is that frankly it is not really ready and is not
> a
>    fully-fledged project yet (I think anyway). Possibly some of this can be
>    useful (not that there's all that much there apart from the ALS (but it
>    does solve for both explicit and implicit preference data as per
> Mahout's
>    implementation), KMeans (simpler than the one in MLlib as I didn't yet
> get
>    around to doing KMeans++ init) and the arg-parsing / jobrunner (which
> may
>    or may not be interesting both for ML and for Spark jobs in general)).
>
> Let me know your thoughts
> Nick
>
>
> On Wed, Jul 24, 2013 at 10:09 PM, Ameet Talwalkar
> <am...@eecs.berkeley.edu>wrote:
>
> > Hi Nick,
> >
> > Thanks for your email, and it's great to see such excitement around this
> > work!  Matei and Reynold already addressed the motivation behind MLlib as
> > well as our reasons for not using Breeze, and I'd like to give you some
> > background about MLbase, and discuss how it may fit with your interests.
> >
> > There are three components of MLbase:
> >
> > 1) MLlib: As Matei mentioned, this is an ML library in Spark with core ML
> > kernels and solid implementations of common algorithms that can be used
> > easily by Java/Python and also called into by higher-level systems (e.g.
> > MLI, Shark, PySpark).
> >
> > 2) MLI: this is an ML API that provides a common interface for ML
> > algorithms (the same interface used in MLlib), and introduces high-level
> > abstractions to simplify feature extraction / exploration and ML
> algorithm
> > development.  These abstractions leverage the kernels in MLlib when
> > possible, and also introduce additional kernels.  This work also
> includes a
> > library written against the MLI.  The MLI is currently written against
> > Spark, but is designed to be platform independent, so that code written
> > against MLI could be run on different engines (e.g., Hadoop, GraphX,
> etc.).
> >
> >
> > 3) ML Optimizer: This piece automates the task of model selection.  The
> > optimizer can be viewed as a search problem over feature extraction /
> > algorithms included in the MLI library, and is in part based on efficient
> > cross validation. This work is under active development but is in an
> > earlier stage of development than MLlib and MLI.
> >
> > (note: MLlib will be included with the Spark codebase, while the MLI and
> ML
> > Optimizer will live in separate repositories.)
> >
> > As far as I can tell (though please correct me if I've misunderstood)
> your
> > main goals include:
> >
> > i) "consistency in the API"
> > ii) "some level of abstraction but to keep things as simple as possible"
> > iii) "execute models on Spark ... while providing workflows for
> pipelining
> > transformations, feature extraction, testing and cross-validation, and
> data
> > viz."
> >
> > The MLI (and to some extent the ML Optimizer) is very much in line with
> > these goals, and it would be great if you were interested in contributing
> > to it.  MLI is a private repository right now, but we'll make it public
> > soon though, and Evan Sparks or I will let you know when we do so.
> >
> > Thanks again for getting in touch with us!
> >
> > -Ameet
> >
> >
> > On Wed, Jul 24, 2013 at 11:47 AM, Reynold Xin <rx...@cs.berkeley.edu>
> > wrote:
> >
> > > On Wed, Jul 24, 2013 at 1:46 AM, Nick Pentreath <
> > nick.pentreath@gmail.com
> > > >wrote:
> > >
> > > >
> > > > I also found Breeze to be very nice to work with and like the DSL -
> > hence
> > > > my question about why not use that? (Especially now that Breeze is
> > > actually
> > > > just breeze-math and breeze-viz).
> > > >
> > >
> > >
> > > Matei addressed this from a higher level. I want to provide a little
> bit
> > > more context. A common properties of a lot of high level Scala DSL
> > > libraries is that simple operators tend to have high virtual function
> > > overheads and also create a lot of temporary objects. And because the
> > level
> > > of abstraction is so high, it is fairly hard to debug / optimize
> > > performance.
> > >
> > >
> > >
> > >
> > > --
> > > Reynold Xin, AMPLab, UC Berkeley
> > > http://rxin.org
> > >
> >
>

Re: Machine Learning on Spark [long rambling discussion email]

Posted by Nick Pentreath <ni...@gmail.com>.
Hi

Ok, that all makes sense. I can see the benefit of good standard libraries
definitely, and I guess the pieces that felt "missing" to me were what you
are describing as MLI and MLOptimizer.

It seems like the aims of MLI are very much in line with what I have/had in
mind for a ML library/framework. It seems the goals overlap quite a lot.

I guess one "frustration" I have had is that there are all these great BDAS
projects, but we never really know when they will be released and what they
will look like until they are. In this particular case I couldn't wait for
MLlib so ended up doing some work myself to port Mahout's ALS and of course
have ended up duplicating effort (which is not a problem as it was
necessary at the time and has been a great learning experience).

Similarly for GraphX, I would like to develop a project for a Spark-based
version of Faunus (https://github.com/thinkaurelius/faunus) for batch
processing of data in our Titan graph DB. For now I am working with
Bagel-based primitives and Spark RDDs directly, but would love to use
GraphX, but have no idea when it will be released and have little
involvement until it is.

(I use "frustration" in the nicest way here - I love the BDAS concepts and
all the projects coming out, I just want them all to be released NOW!! :)

So yes I would love to be involved in MLlib and MLI work to the extent I
can assist and the work is aligned with what I need currently in my
projects (this is just from a time allocation viewpoint - I'm sure much of
it will be complementary).

Anyway, it seems to me the best course of action is as follows:

   - I'll get involved in MLlib and see how I can contribute there. Some
   things that jump out:


   - implicit preference capability for ALS model since as far as I can see
      currently it handles explicit prefs only? (Implicit prefs here:
      http://68.180.206.246/files/HuKorenVolinsky-ICDM08.pdf which is
      typically better if we don't have actual rating data but instead "view",
      "click", "play" or whatever)
      - RMSE and other evaluation metrics for ALS as well as test/train
      split / cross-val stuff?
      - linear model additions, like new loss functions for hinge loss,
      least squares etc for SGD, as well as learning rate stuff (
      http://arxiv.org/pdf/1305.6646) and regularisers (L1/L2/Elasic Net) -
      i.e. bring the SGD stuff in line with Vowpal Wabbit / sklearn (if that's
      desirable, my view is yes)
      - what about sparse weight and feature vectors for linear models/SGD?
      Together with hashing allows very large models while still being
efficient,
      and with L1 reg is particularly useful.
      - finally what about online models? ie SGD models currently are
      "static" ie once trained can only predict, whereas SGD can of course keep
      learning. Or does one simply re-train with the previous initial weight
      vector (I guess that can work just as well)... Also on this
topic training
      / predicting on Streams as well as RDDs
   - I can put up what I have done to a BitBucket account and grant access
   to whichever devs would like to take a look. The only reason I don't just
   throw it up on GitHub is that frankly it is not really ready and is not a
   fully-fledged project yet (I think anyway). Possibly some of this can be
   useful (not that there's all that much there apart from the ALS (but it
   does solve for both explicit and implicit preference data as per Mahout's
   implementation), KMeans (simpler than the one in MLlib as I didn't yet get
   around to doing KMeans++ init) and the arg-parsing / jobrunner (which may
   or may not be interesting both for ML and for Spark jobs in general)).

Let me know your thoughts
Nick


On Wed, Jul 24, 2013 at 10:09 PM, Ameet Talwalkar
<am...@eecs.berkeley.edu>wrote:

> Hi Nick,
>
> Thanks for your email, and it's great to see such excitement around this
> work!  Matei and Reynold already addressed the motivation behind MLlib as
> well as our reasons for not using Breeze, and I'd like to give you some
> background about MLbase, and discuss how it may fit with your interests.
>
> There are three components of MLbase:
>
> 1) MLlib: As Matei mentioned, this is an ML library in Spark with core ML
> kernels and solid implementations of common algorithms that can be used
> easily by Java/Python and also called into by higher-level systems (e.g.
> MLI, Shark, PySpark).
>
> 2) MLI: this is an ML API that provides a common interface for ML
> algorithms (the same interface used in MLlib), and introduces high-level
> abstractions to simplify feature extraction / exploration and ML algorithm
> development.  These abstractions leverage the kernels in MLlib when
> possible, and also introduce additional kernels.  This work also includes a
> library written against the MLI.  The MLI is currently written against
> Spark, but is designed to be platform independent, so that code written
> against MLI could be run on different engines (e.g., Hadoop, GraphX, etc.).
>
>
> 3) ML Optimizer: This piece automates the task of model selection.  The
> optimizer can be viewed as a search problem over feature extraction /
> algorithms included in the MLI library, and is in part based on efficient
> cross validation. This work is under active development but is in an
> earlier stage of development than MLlib and MLI.
>
> (note: MLlib will be included with the Spark codebase, while the MLI and ML
> Optimizer will live in separate repositories.)
>
> As far as I can tell (though please correct me if I've misunderstood) your
> main goals include:
>
> i) "consistency in the API"
> ii) "some level of abstraction but to keep things as simple as possible"
> iii) "execute models on Spark ... while providing workflows for pipelining
> transformations, feature extraction, testing and cross-validation, and data
> viz."
>
> The MLI (and to some extent the ML Optimizer) is very much in line with
> these goals, and it would be great if you were interested in contributing
> to it.  MLI is a private repository right now, but we'll make it public
> soon though, and Evan Sparks or I will let you know when we do so.
>
> Thanks again for getting in touch with us!
>
> -Ameet
>
>
> On Wed, Jul 24, 2013 at 11:47 AM, Reynold Xin <rx...@cs.berkeley.edu>
> wrote:
>
> > On Wed, Jul 24, 2013 at 1:46 AM, Nick Pentreath <
> nick.pentreath@gmail.com
> > >wrote:
> >
> > >
> > > I also found Breeze to be very nice to work with and like the DSL -
> hence
> > > my question about why not use that? (Especially now that Breeze is
> > actually
> > > just breeze-math and breeze-viz).
> > >
> >
> >
> > Matei addressed this from a higher level. I want to provide a little bit
> > more context. A common properties of a lot of high level Scala DSL
> > libraries is that simple operators tend to have high virtual function
> > overheads and also create a lot of temporary objects. And because the
> level
> > of abstraction is so high, it is fairly hard to debug / optimize
> > performance.
> >
> >
> >
> >
> > --
> > Reynold Xin, AMPLab, UC Berkeley
> > http://rxin.org
> >
>

Re: Machine Learning on Spark [long rambling discussion email]

Posted by Ameet Talwalkar <am...@eecs.berkeley.edu>.
Hi Nick,

Thanks for your email, and it's great to see such excitement around this
work!  Matei and Reynold already addressed the motivation behind MLlib as
well as our reasons for not using Breeze, and I'd like to give you some
background about MLbase, and discuss how it may fit with your interests.

There are three components of MLbase:

1) MLlib: As Matei mentioned, this is an ML library in Spark with core ML
kernels and solid implementations of common algorithms that can be used
easily by Java/Python and also called into by higher-level systems (e.g.
MLI, Shark, PySpark).

2) MLI: this is an ML API that provides a common interface for ML
algorithms (the same interface used in MLlib), and introduces high-level
abstractions to simplify feature extraction / exploration and ML algorithm
development.  These abstractions leverage the kernels in MLlib when
possible, and also introduce additional kernels.  This work also includes a
library written against the MLI.  The MLI is currently written against
Spark, but is designed to be platform independent, so that code written
against MLI could be run on different engines (e.g., Hadoop, GraphX, etc.).


3) ML Optimizer: This piece automates the task of model selection.  The
optimizer can be viewed as a search problem over feature extraction /
algorithms included in the MLI library, and is in part based on efficient
cross validation. This work is under active development but is in an
earlier stage of development than MLlib and MLI.

(note: MLlib will be included with the Spark codebase, while the MLI and ML
Optimizer will live in separate repositories.)

As far as I can tell (though please correct me if I've misunderstood) your
main goals include:

i) "consistency in the API"
ii) "some level of abstraction but to keep things as simple as possible"
iii) "execute models on Spark ... while providing workflows for pipelining
transformations, feature extraction, testing and cross-validation, and data
viz."

The MLI (and to some extent the ML Optimizer) is very much in line with
these goals, and it would be great if you were interested in contributing
to it.  MLI is a private repository right now, but we'll make it public
soon though, and Evan Sparks or I will let you know when we do so.

Thanks again for getting in touch with us!

-Ameet


On Wed, Jul 24, 2013 at 11:47 AM, Reynold Xin <rx...@cs.berkeley.edu> wrote:

> On Wed, Jul 24, 2013 at 1:46 AM, Nick Pentreath <nick.pentreath@gmail.com
> >wrote:
>
> >
> > I also found Breeze to be very nice to work with and like the DSL - hence
> > my question about why not use that? (Especially now that Breeze is
> actually
> > just breeze-math and breeze-viz).
> >
>
>
> Matei addressed this from a higher level. I want to provide a little bit
> more context. A common properties of a lot of high level Scala DSL
> libraries is that simple operators tend to have high virtual function
> overheads and also create a lot of temporary objects. And because the level
> of abstraction is so high, it is fairly hard to debug / optimize
> performance.
>
>
>
>
> --
> Reynold Xin, AMPLab, UC Berkeley
> http://rxin.org
>

Re: Machine Learning on Spark [long rambling discussion email]

Posted by Reynold Xin <rx...@cs.berkeley.edu>.
On Wed, Jul 24, 2013 at 1:46 AM, Nick Pentreath <ni...@gmail.com>wrote:

>
> I also found Breeze to be very nice to work with and like the DSL - hence
> my question about why not use that? (Especially now that Breeze is actually
> just breeze-math and breeze-viz).
>


Matei addressed this from a higher level. I want to provide a little bit
more context. A common properties of a lot of high level Scala DSL
libraries is that simple operators tend to have high virtual function
overheads and also create a lot of temporary objects. And because the level
of abstraction is so high, it is fairly hard to debug / optimize
performance.




--
Reynold Xin, AMPLab, UC Berkeley
http://rxin.org

Re: Machine Learning on Spark [long rambling discussion email]

Posted by Matei Zaharia <ma...@gmail.com>.
BTW I should also add about Mahout that it might also make sense for Mahout to call MLlib internally. I just haven't looked into it enough to decide whether we'd want to provide more than input/output wrappers. But it would certainly be great to have Mahout people help out with MLlib in some way.

Matei

On Jul 24, 2013, at 11:39 AM, Matei Zaharia <ma...@gmail.com> wrote:

> Hey Nick,
> 
> Thanks for your interest in this stuff! I'm going to let the MLbase team answer this in more detail, but just some quick answers on the first part of your email:
> 
> - From my point of view, the ML library in Spark is meant to be just a library of "kernel" functions you can call, not a complete ETL and data format system like Mahout. The goal was to have good implementations of common algorithms that different higher-level systems (e.g. MLbase, Shark, PySpark) can call into.
> 
> - We wanted to try keeping this in Spark initially to make it a kind of "standard library". This is something that can help ensure it becomes high-quality over time and keep it supported by the project. If you think about it, projects like R and Matlab are very strong primarily because they have great standard libraries. This was also one of the things we thought would differentiate us from Hadoop and Mahout. However, we will of course see how things go and separate it out if it needs a faster dev cycle.
> 
> - I haven't worried much about compatibility with Mahout because I'm not sure Mahout is too widely used and I'm not sure its abstractions are best. Mahout is very tied to HDFS, SequenceFiles, etc. We will of course try to interoperate well with data from Mahout, but at least as far as I was concerned, I wanted an API that makes sense for Spark users.
> 
> - Something that's maybe not clear about the MLlib API is that we also want it to be used easily from Java and Python. So we've explicitly avoided having very high-level types or using Scala-specific features, in order to get something that will be simple to call from these languages. This does leave room for wrappers that provide higher-level interfaces.
> 
> In any case, if you like this "kernel" design for MLlib, it would be great to get more people contributing to it, or to get it used in other projects. I'll let the MLbase folks talk about higher-level interfaces -- this is definitely something they want to do, but they might be able to use help. In any case though, sharing the low-level kernels across Spark projects would make a lot of sense.
> 
> Matei
> 
> On Jul 24, 2013, at 1:46 AM, Nick Pentreath <ni...@gmail.com> wrote:
> 
>> Hi dev team
>> 
>> (Apologies for a long email!)
>> 
>> Firstly great news about the inclusion of MLlib into the Spark project!
>> 
>> I've been working on a concept and some code for a machine learning library
>> on Spark, and so of course there is a lot of overlap between MLlib and what
>> I've been doing.
>> 
>> I wanted to throw this out there and (a) ask a couple of design and roadmap
>> questions about MLLib, and (b) talk about how to work together / integrate
>> my ideas (if at all :)
>> 
>> *Some questions*
>> *
>> *
>> 1. What is the general design idea behind MLLib - is it aimed at being a
>> collection of algorithms, ie a library? Or is it aimed at being a "Mahout
>> for Spark", i.e. something that can be used as a library as well as a set
>> of tools for things like running jobs, feature extraction, text processing
>> etc?
>> 2. How married are we to keeping it within the Spark project? While I
>> understand the reasoning behind it I am not convinced it's best. But I
>> guess we can wait and see how it develops
>> 3. Some of the original test code I saw around the Block ALS did use Breeze
>> (https://github.com/dlwh/breeze) for some of the linear algebra. Now I see
>> everything is using JBLAS directly and Array[Double]. Is there a specific
>> reason for this? Is it aimed at creating a separation whereby the linear
>> algebra backend could be switched out? Scala 2.10 issues?
>> 4. Since Spark is meant to be nicely compatible with Hadoop, do we care
>> about compatibility/integration with Mahout? This may also encourage Mahout
>> developers to switch over and contribute their expertise (see for example
>> Dmitry's work at:
>> https://github.com/dlyubimov/mahout-commits/commits/dev-0.8.x-scala/math-scala,
>> where he is doing a Scala/Spark DSL around mahout-math matrices and
>> distributed operations). Potentially even using mahout-math for linear
>> algebra routines?
>> 5. Is there a roadmap? (I've checked the JIRA which does have a few
>> intended models etc). Who are the devs most involved in this project?
>> 6. What are thoughts around API design for models?
>> 
>> *Some thoughts*
>> *
>> *
>> So, over the past couple of months I have been working on a machine
>> learning library. Initially it was for my own use but I've added a few
>> things and was starting to think about releasing it (though it's not nearly
>> ready). The model that I really needed first was ALS for doing
>> recommendations. So I have ported the ALS code from Mahout to Spark. Well,
>> "ported" in some sense - mostly I copied the algorithm and data
>> distribution design, using Spark's primitives and Breeze for all the linear
>> algebra.
>> 
>> I found it pretty straightforward to port over. So far I have done local
>> testing only on the Movielens datasets. I have found my RMSE results to
>> match that of Mahout's. Overall interestingly the wall clock performance is
>> not as dissimilar as I would have expected. But I would like to now do some
>> larger-scale tests on a cluster to really do a good comparison.
>> 
>> Obviously with Spark's Block ALS model, my version is now somewhat
>> superfluous since I expect (and have so far seen in my simple local
>> experiments) that the block model will significantly outperform. I will
>> probably be porting my use case over to this in due time once I've done
>> further testing.
>> 
>> I also found Breeze to be very nice to work with and like the DSL - hence
>> my question about why not use that? (Especially now that Breeze is actually
>> just breeze-math and breeze-viz).
>> 
>> Anyway, I then added KMeans (basically just the Spark example with some
>> Breeze tweaks), and started working on a Linear Model framework. I've also
>> added a simple framework for arg parsing and config (using Twitter
>> Algebird's Args and Typesafe Config), and have started on feature
>> extraction stuff - of particular interest will be text feature extraction
>> and feature hashing.
>> 
>> This is roughly the idea for a machine learning library on Spark that I
>> have - call it a design or manifesto or whatever:
>> 
>> - Library available and consistent across Scala, Java and Python (as much
>> as possible in any event)
>> - A core library and also a set of stuff for easily running models based on
>> standard input formats etc
>> - Standardised model API (even across languages) to the extent possible.
>> I've based mine so far on Python's scikit-learn (.fit(), .predict() etc).
>> Why? I believe it's a major strength of scikit-learn, that its API is so
>> clean, simple and consistent. Plus, for the Python version of the lib,
>> scikit-learn will no doubt be used wherever possible to avoid re-creating
>> code
>> - Models to be included initially:
>> - ALS
>> - Possibly co-occurrence recommendation stuff similar to Mahout's Taste
>> - Clustering (K-Means and others potentially)
>> - Linear Models - the idea here is to have something very close to Vowpal
>> Wabbit, ie a generic SGD engine with various Loss Functions, learning rate
>> paradigms etc. Furthermore this would allow other models similar to VW such
>> as online versions of matrix factorisation, neural nets and learning
>> reductions
>> - Possibly Decision Trees / Random Forests
>> - Some utilities for feature extraction (hashing in particular), and to
>> make running jobs easy (integration with Spark's ./run etc?)
>> - Stuff for making pipelining easy (like scikit-learn) and for doing things
>> like cross-validation in a principled (and parallel) way
>> - Clean and easy integration with Spark Streaming for online models (e.g. a
>> linear SGD can be called with fit() on batch data, and then fit() and/or
>> fit/predict() on streaming data to learn further online etc).
>> - Interactivity provided by shells (IPython, Spark shell) and also plotting
>> capability (Matplotlib, and Breeze Viz)
>> - For Scala, integration with Shark via sql2rdd etc.
>> - I'd like to create something similar to Scalding's Matrix API based on
>> RDDs for representing distributed matrices, as well as integrate the ideas
>> of Dmitry and Mahout's DistributedRowMatrix etc
>> 
>> Here is a rough outline of the model API I have used at the moment:
>> https://gist.github.com/MLnick/6068841. This works nicely for ALS,
>> clustering, linear models etc.
>> 
>> So as you can see, mostly overlapping with what MLlib already has or has
>> planned in some way, but my main aim is frankly to have consistency in the
>> API, some level of abstraction but to keep things as simple as possible (ie
>> let Spark handle the complex stuff), and thus hopefully avoid things
>> becoming just a somewhat haphazard collection of models that is not that
>> simple to figure out how to use - which is unfortunately what I believe has
>> happened to Mahout.
>> 
>> So the question then is, how to work together or integrate? I see 3 options:
>> 
>> 1. I go my own way (not very appealing obviously)
>> 2. Contribute what I have (or as much as makes sense) to MLlib
>> 3. Create my project as a "front-end" or "wrapper" around MLlib as the
>> core, effectively providing the API and workflow interface but using MLlib
>> as the model engine.
>> 
>> #2 is appealing but then a lot depends on the API and framework design and
>> how much what I have in mind is compatible with the rest of the devs etc
>> #3 now that I have written it, starts to sound pretty interesting -
>> potentially we're looking at a "front-end" that could in fact execute
>> models on Spark (or other engines like Hadoop/Mahout, GraphX etc), while
>> providing workflows for pipelining transformations, feature extraction,
>> testing and cross-validation, and data viz.
>> 
>> But of course #3 starts sounding somewhat like what MLBase is aiming to be
>> (I think)!
>> 
>> At this point I'm willing to show out what I have done so far on a
>> selective basis - be warned though it is rough and not finished and
>> somewhat clunky perhaps as it's my first attempt at a library/framework, if
>> it makes sense. Especially because really the main thing I did was the ALS
>> port, and with MLlib's version of ALS that may be less useful now in any
>> case.
>> 
>> It may be that none of this is that useful to others anyway which is fine
>> as I'll keep developing tools that I need and potentially they will be
>> useful at some point.
>> 
>> Thoughts, feedback, comments, discussion? I really want to jump into MLlib
>> and get involved in contributing to standardised machine learning on Spark!
>> 
>> Nick
> 


Re: Machine Learning on Spark [long rambling discussion email]

Posted by Matei Zaharia <ma...@gmail.com>.
Hey Nick,

Thanks for your interest in this stuff! I'm going to let the MLbase team answer this in more detail, but just some quick answers on the first part of your email:

- From my point of view, the ML library in Spark is meant to be just a library of "kernel" functions you can call, not a complete ETL and data format system like Mahout. The goal was to have good implementations of common algorithms that different higher-level systems (e.g. MLbase, Shark, PySpark) can call into.

- We wanted to try keeping this in Spark initially to make it a kind of "standard library". This is something that can help ensure it becomes high-quality over time and keep it supported by the project. If you think about it, projects like R and Matlab are very strong primarily because they have great standard libraries. This was also one of the things we thought would differentiate us from Hadoop and Mahout. However, we will of course see how things go and separate it out if it needs a faster dev cycle.

- I haven't worried much about compatibility with Mahout because I'm not sure Mahout is too widely used and I'm not sure its abstractions are best. Mahout is very tied to HDFS, SequenceFiles, etc. We will of course try to interoperate well with data from Mahout, but at least as far as I was concerned, I wanted an API that makes sense for Spark users.

- Something that's maybe not clear about the MLlib API is that we also want it to be used easily from Java and Python. So we've explicitly avoided having very high-level types or using Scala-specific features, in order to get something that will be simple to call from these languages. This does leave room for wrappers that provide higher-level interfaces.

In any case, if you like this "kernel" design for MLlib, it would be great to get more people contributing to it, or to get it used in other projects. I'll let the MLbase folks talk about higher-level interfaces -- this is definitely something they want to do, but they might be able to use help. In any case though, sharing the low-level kernels across Spark projects would make a lot of sense.

Matei

On Jul 24, 2013, at 1:46 AM, Nick Pentreath <ni...@gmail.com> wrote:

> Hi dev team
> 
> (Apologies for a long email!)
> 
> Firstly great news about the inclusion of MLlib into the Spark project!
> 
> I've been working on a concept and some code for a machine learning library
> on Spark, and so of course there is a lot of overlap between MLlib and what
> I've been doing.
> 
> I wanted to throw this out there and (a) ask a couple of design and roadmap
> questions about MLLib, and (b) talk about how to work together / integrate
> my ideas (if at all :)
> 
> *Some questions*
> *
> *
> 1. What is the general design idea behind MLLib - is it aimed at being a
> collection of algorithms, ie a library? Or is it aimed at being a "Mahout
> for Spark", i.e. something that can be used as a library as well as a set
> of tools for things like running jobs, feature extraction, text processing
> etc?
> 2. How married are we to keeping it within the Spark project? While I
> understand the reasoning behind it I am not convinced it's best. But I
> guess we can wait and see how it develops
> 3. Some of the original test code I saw around the Block ALS did use Breeze
> (https://github.com/dlwh/breeze) for some of the linear algebra. Now I see
> everything is using JBLAS directly and Array[Double]. Is there a specific
> reason for this? Is it aimed at creating a separation whereby the linear
> algebra backend could be switched out? Scala 2.10 issues?
> 4. Since Spark is meant to be nicely compatible with Hadoop, do we care
> about compatibility/integration with Mahout? This may also encourage Mahout
> developers to switch over and contribute their expertise (see for example
> Dmitry's work at:
> https://github.com/dlyubimov/mahout-commits/commits/dev-0.8.x-scala/math-scala,
> where he is doing a Scala/Spark DSL around mahout-math matrices and
> distributed operations). Potentially even using mahout-math for linear
> algebra routines?
> 5. Is there a roadmap? (I've checked the JIRA which does have a few
> intended models etc). Who are the devs most involved in this project?
> 6. What are thoughts around API design for models?
> 
> *Some thoughts*
> *
> *
> So, over the past couple of months I have been working on a machine
> learning library. Initially it was for my own use but I've added a few
> things and was starting to think about releasing it (though it's not nearly
> ready). The model that I really needed first was ALS for doing
> recommendations. So I have ported the ALS code from Mahout to Spark. Well,
> "ported" in some sense - mostly I copied the algorithm and data
> distribution design, using Spark's primitives and Breeze for all the linear
> algebra.
> 
> I found it pretty straightforward to port over. So far I have done local
> testing only on the Movielens datasets. I have found my RMSE results to
> match that of Mahout's. Overall interestingly the wall clock performance is
> not as dissimilar as I would have expected. But I would like to now do some
> larger-scale tests on a cluster to really do a good comparison.
> 
> Obviously with Spark's Block ALS model, my version is now somewhat
> superfluous since I expect (and have so far seen in my simple local
> experiments) that the block model will significantly outperform. I will
> probably be porting my use case over to this in due time once I've done
> further testing.
> 
> I also found Breeze to be very nice to work with and like the DSL - hence
> my question about why not use that? (Especially now that Breeze is actually
> just breeze-math and breeze-viz).
> 
> Anyway, I then added KMeans (basically just the Spark example with some
> Breeze tweaks), and started working on a Linear Model framework. I've also
> added a simple framework for arg parsing and config (using Twitter
> Algebird's Args and Typesafe Config), and have started on feature
> extraction stuff - of particular interest will be text feature extraction
> and feature hashing.
> 
> This is roughly the idea for a machine learning library on Spark that I
> have - call it a design or manifesto or whatever:
> 
> - Library available and consistent across Scala, Java and Python (as much
> as possible in any event)
> - A core library and also a set of stuff for easily running models based on
> standard input formats etc
> - Standardised model API (even across languages) to the extent possible.
> I've based mine so far on Python's scikit-learn (.fit(), .predict() etc).
> Why? I believe it's a major strength of scikit-learn, that its API is so
> clean, simple and consistent. Plus, for the Python version of the lib,
> scikit-learn will no doubt be used wherever possible to avoid re-creating
> code
> - Models to be included initially:
>  - ALS
>  - Possibly co-occurrence recommendation stuff similar to Mahout's Taste
>  - Clustering (K-Means and others potentially)
>  - Linear Models - the idea here is to have something very close to Vowpal
> Wabbit, ie a generic SGD engine with various Loss Functions, learning rate
> paradigms etc. Furthermore this would allow other models similar to VW such
> as online versions of matrix factorisation, neural nets and learning
> reductions
>  - Possibly Decision Trees / Random Forests
> - Some utilities for feature extraction (hashing in particular), and to
> make running jobs easy (integration with Spark's ./run etc?)
> - Stuff for making pipelining easy (like scikit-learn) and for doing things
> like cross-validation in a principled (and parallel) way
> - Clean and easy integration with Spark Streaming for online models (e.g. a
> linear SGD can be called with fit() on batch data, and then fit() and/or
> fit/predict() on streaming data to learn further online etc).
> - Interactivity provided by shells (IPython, Spark shell) and also plotting
> capability (Matplotlib, and Breeze Viz)
> - For Scala, integration with Shark via sql2rdd etc.
> - I'd like to create something similar to Scalding's Matrix API based on
> RDDs for representing distributed matrices, as well as integrate the ideas
> of Dmitry and Mahout's DistributedRowMatrix etc
> 
> Here is a rough outline of the model API I have used at the moment:
> https://gist.github.com/MLnick/6068841. This works nicely for ALS,
> clustering, linear models etc.
> 
> So as you can see, mostly overlapping with what MLlib already has or has
> planned in some way, but my main aim is frankly to have consistency in the
> API, some level of abstraction but to keep things as simple as possible (ie
> let Spark handle the complex stuff), and thus hopefully avoid things
> becoming just a somewhat haphazard collection of models that is not that
> simple to figure out how to use - which is unfortunately what I believe has
> happened to Mahout.
> 
> So the question then is, how to work together or integrate? I see 3 options:
> 
> 1. I go my own way (not very appealing obviously)
> 2. Contribute what I have (or as much as makes sense) to MLlib
> 3. Create my project as a "front-end" or "wrapper" around MLlib as the
> core, effectively providing the API and workflow interface but using MLlib
> as the model engine.
> 
> #2 is appealing but then a lot depends on the API and framework design and
> how much what I have in mind is compatible with the rest of the devs etc
> #3 now that I have written it, starts to sound pretty interesting -
> potentially we're looking at a "front-end" that could in fact execute
> models on Spark (or other engines like Hadoop/Mahout, GraphX etc), while
> providing workflows for pipelining transformations, feature extraction,
> testing and cross-validation, and data viz.
> 
> But of course #3 starts sounding somewhat like what MLBase is aiming to be
> (I think)!
> 
> At this point I'm willing to show out what I have done so far on a
> selective basis - be warned though it is rough and not finished and
> somewhat clunky perhaps as it's my first attempt at a library/framework, if
> it makes sense. Especially because really the main thing I did was the ALS
> port, and with MLlib's version of ALS that may be less useful now in any
> case.
> 
> It may be that none of this is that useful to others anyway which is fine
> as I'll keep developing tools that I need and potentially they will be
> useful at some point.
> 
> Thoughts, feedback, comments, discussion? I really want to jump into MLlib
> and get involved in contributing to standardised machine learning on Spark!
> 
> Nick


Re: Machine Learning on Spark [long rambling discussion email]

Posted by Dmitriy Lyubimov <dl...@gmail.com>.
On Wed, Jul 24, 2013 at 1:46 AM, Nick Pentreath <ni...@gmail.com>wrote:

> Hi dev team
>
> (Apologies for a long email!)
>
> Firstly great news about the inclusion of MLlib into the Spark project!
>
> I've been working on a concept and some code for a machine learning library
> on Spark, and so of course there is a lot of overlap between MLlib and what
> I've been doing.
>
> I wanted to throw this out there and (a) ask a couple of design and roadmap
> questions about MLLib, and (b) talk about how to work together / integrate
> my ideas (if at all :)
>
> *Some questions*
> *
> *
> 1. What is the general design idea behind MLLib - is it aimed at being a
> collection of algorithms, ie a library? Or is it aimed at being a "Mahout
> for Spark", i.e. something that can be used as a library as well as a set
> of tools for things like running jobs, feature extraction, text processing
> etc?
> 2. How married are we to keeping it within the Spark project? While I
> understand the reasoning behind it I am not convinced it's best. But I
> guess we can wait and see how it develops
> 3. Some of the original test code I saw around the Block ALS did use Breeze
> (https://github.com/dlwh/breeze) for some of the linear algebra. Now I see
> everything is using JBLAS directly and Array[Double]. Is there a specific
> reason for this? Is it aimed at creating a separation whereby the linear
> algebra backend could be switched out? Scala 2.10 issues?
> 4. Since Spark is meant to be nicely compatible with Hadoop, do we care
> about compatibility/integration with Mahout? This may also encourage Mahout
> developers to switch over and contribute their expertise (see for example
> Dmitry's work at:
>
> https://github.com/dlyubimov/mahout-commits/commits/dev-0.8.x-scala/math-scala
> ,
>

It's 0.9.x-scala branch now. We've released 0.8


> where he is doing a Scala/Spark DSL around mahout-math matrices and
> distributed operations). Potentially even using mahout-math for linear
> algebra routines?
> 5. Is there a roadmap? (I've checked the JIRA which does have a few
> intended models etc). Who are the devs most involved in this project?
> 6. What are thoughts around API design for models?
>
> *Some thoughts*
> *
> *
> So, over the past couple of months I have been working on a machine
> learning library. Initially it was for my own use but I've added a few
> things and was starting to think about releasing it (though it's not nearly
> ready). The model that I really needed first was ALS for doing
> recommendations. So I have ported the ALS code from Mahout to Spark. Well,
> "ported" in some sense - mostly I copied the algorithm and data
> distribution design, using Spark's primitives and Breeze for all the linear
> algebra.
>
> I found it pretty straightforward to port over. So far I have done local
> testing only on the Movielens datasets. I have found my RMSE results to
> match that of Mahout's. Overall interestingly the wall clock performance is
> not as dissimilar as I would have expected. But I would like to now do some
> larger-scale tests on a cluster to really do a good comparison.
>
> Obviously with Spark's Block ALS model, my version is now somewhat
> superfluous since I expect (and have so far seen in my simple local
> experiments) that the block model will significantly outperform. I will
> probably be porting my use case over to this in due time once I've done
> further testing.
>
> I also found Breeze to be very nice to work with and like the DSL - hence
> my question about why not use that? (Especially now that Breeze is actually
> just breeze-math and breeze-viz).
>
> Anyway, I then added KMeans (basically just the Spark example with some
> Breeze tweaks), and started working on a Linear Model framework. I've also
> added a simple framework for arg parsing and config (using Twitter
> Algebird's Args and Typesafe Config), and have started on feature
> extraction stuff - of particular interest will be text feature extraction
> and feature hashing.
>
> This is roughly the idea for a machine learning library on Spark that I
> have - call it a design or manifesto or whatever:
>
> - Library available and consistent across Scala, Java and Python (as much
> as possible in any event)
> - A core library and also a set of stuff for easily running models based on
> standard input formats etc
> - Standardised model API (even across languages) to the extent possible.
> I've based mine so far on Python's scikit-learn (.fit(), .predict() etc).
> Why? I believe it's a major strength of scikit-learn, that its API is so
> clean, simple and consistent. Plus, for the Python version of the lib,
> scikit-learn will no doubt be used wherever possible to avoid re-creating
> code
> - Models to be included initially:
>   - ALS
>   - Possibly co-occurrence recommendation stuff similar to Mahout's Taste
>   - Clustering (K-Means and others potentially)
>   - Linear Models - the idea here is to have something very close to Vowpal
> Wabbit, ie a generic SGD engine with various Loss Functions, learning rate
> paradigms etc. Furthermore this would allow other models similar to VW such
> as online versions of matrix factorisation, neural nets and learning
> reductions
>   - Possibly Decision Trees / Random Forests
> - Some utilities for feature extraction (hashing in particular), and to
> make running jobs easy (integration with Spark's ./run etc?)
> - Stuff for making pipelining easy (like scikit-learn) and for doing things
> like cross-validation in a principled (and parallel) way
> - Clean and easy integration with Spark Streaming for online models (e.g. a
> linear SGD can be called with fit() on batch data, and then fit() and/or
> fit/predict() on streaming data to learn further online etc).
> - Interactivity provided by shells (IPython, Spark shell) and also plotting
> capability (Matplotlib, and Breeze Viz)
> - For Scala, integration with Shark via sql2rdd etc.
> - I'd like to create something similar to Scalding's Matrix API based on
> RDDs for representing distributed matrices, as well as integrate the ideas
> of Dmitry and Mahout's DistributedRowMatrix etc
>
> Here is a rough outline of the model API I have used at the moment:
> https://gist.github.com/MLnick/6068841. This works nicely for ALS,
> clustering, linear models etc.
>
> So as you can see, mostly overlapping with what MLlib already has or has
> planned in some way, but my main aim is frankly to have consistency in the
> API, some level of abstraction but to keep things as simple as possible (ie
> let Spark handle the complex stuff), and thus hopefully avoid things
> becoming just a somewhat haphazard collection of models that is not that
> simple to figure out how to use - which is unfortunately what I believe has
> happened to Mahout.
>
> So the question then is, how to work together or integrate? I see 3
> options:
>
> 1. I go my own way (not very appealing obviously)
> 2. Contribute what I have (or as much as makes sense) to MLlib
> 3. Create my project as a "front-end" or "wrapper" around MLlib as the
> core, effectively providing the API and workflow interface but using MLlib
> as the model engine.
>
> #2 is appealing but then a lot depends on the API and framework design and
> how much what I have in mind is compatible with the rest of the devs etc
> #3 now that I have written it, starts to sound pretty interesting -
> potentially we're looking at a "front-end" that could in fact execute
> models on Spark (or other engines like Hadoop/Mahout, GraphX etc), while
> providing workflows for pipelining transformations, feature extraction,
> testing and cross-validation, and data viz.
>
> But of course #3 starts sounding somewhat like what MLBase is aiming to be
> (I think)!
>
> At this point I'm willing to show out what I have done so far on a
> selective basis - be warned though it is rough and not finished and
> somewhat clunky perhaps as it's my first attempt at a library/framework, if
> it makes sense. Especially because really the main thing I did was the ALS
> port, and with MLlib's version of ALS that may be less useful now in any
> case.
>
> It may be that none of this is that useful to others anyway which is fine
> as I'll keep developing tools that I need and potentially they will be
> useful at some point.
>
> Thoughts, feedback, comments, discussion? I really want to jump into MLlib
> and get involved in contributing to standardised machine learning on Spark!
>
> Nick
>