You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by praveen S <my...@gmail.com> on 2015/08/07 08:55:57 UTC
StringIndexer + VectorAssembler equivalent to HashingTF?
Is StringIndexer + VectorAssembler equivalent to HashingTF while converting
the document for analysis?
Re: StringIndexer + VectorAssembler equivalent to HashingTF?
Posted by Peter Rudenko <pe...@gmail.com>.
No, here's an example:
COL1 COL2
a one
b two
a two
c three
StringIndexer.setInputCol(COL1).setOutputCol(SI1) ->
(0-> a, 1->b,2->c)
SI1
0
1
0
2
StringIndexer.setInputCol(COL2).setOutputCol(SI2) ->
(0-> one, 1->two, 2->three)
SI1
0
1
1
2
VectorAssembler.setInputCols(SI1, SI2).setOutputCol(features) ->
features
00
11
01
22
HashingTF.setNumFeatures(2).setInputCol(COL1).setOutputCol(HT1)
bucket1 bucket2
a,a,b c
HT1
3 //Hash collision
3
3
1
Thanks,
Peter Rudenko
On 2015-08-07 09:55, praveen S wrote:
>
> Is StringIndexer + VectorAssembler equivalent to HashingTF while
> converting the document for analysis?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org