Hi Ricardo,
instead of filtering header just remove the header of your file.

In your code you create a filter for the header but you don't use it to
compute parsedData.

val parsedData = filter_data.map(s => Vectors.dense(s.split(',').
map(_.toDouble))).cache()

2015-05-19 21:23 GMT+02:00 Stephen Boesch <java...@gmail.com>:

> Hi Ricardo,
>  providing the error output would help . But in any case you need to do a
> collect() on the rdd returned from computeCost.
>
> 2015-05-19 11:59 GMT-07:00 Ricardo Goncalves da Silva <
> ricardog.si...@telefonica.com>:
>
>  Hi,
>>
>>
>>
>> Can anybody see what’s wrong in this piece of code:
>>
>>
>>
>>
>>
>> ./bin/spark-shell --num-executors 2 --executor-memory 512m --master
>> yarn-client
>>
>> import org.apache.spark.mllib.clustering.KMeans
>>
>> import org.apache.spark.mllib.linalg.Vectors
>>
>>
>>
>>
>>
>> val data = sc.textFile("/user/p_loadbd/fraude5.csv").map(x =>
>> x.toLowerCase.split(',')).map(x => x(0)+","+x(1))
>>
>> val header = data.first()
>>
>> val filter_data = data.filter(x => x != header)
>>
>> val parsedData = data.map(s =>
>> Vectors.dense(s.split(',').map(_.toDouble))).cache()
>>
>>
>>
>> val numClusters = 2
>>
>> val numIterations = 20
>>
>> val clusters = KMeans.train(parsedData, numClusters, numIterations)
>>
>>
>>
>> val WSSSE = clusters.computeCost(parsedData)
>>
>> println("Within Set Sum of Squared Errors = " + WSSSE)
>>
>>
>>
>> Thanks.
>>
>>
>>
>>
>>
>> [image: Descrição: Descrição: Descrição:
>> cid:image002.jpg@01CC89A8.2B628650]
>>
>> *Ricardo Goncalves da Silva*
>> Lead Data Scientist *|* Seção de Desenvolvimento de Sistemas de
>>
>> Business Intelligence – Projetos de Inovação *| *IDPB02
>>
>> Av. Eng. Luis Carlos Berrini, 1.376 – 7º – 04571-000 - SP
>>
>> ricardog.si...@telefonica.com *|* www.telefonica.com.br
>>
>> Tel +55 11 3430 4955 *| *Cel +55 11 94292 9526
>>
>>
>>
>>
>>
>> ------------------------------
>>
>> Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario,
>> puede contener información privilegiada o confidencial y es para uso
>> exclusivo de la persona o entidad de destino. Si no es usted. el
>> destinatario indicado, queda notificado de que la lectura, utilización,
>> divulgación y/o copia sin autorización puede estar prohibida en virtud de
>> la legislación vigente. Si ha recibido este mensaje por error, le rogamos
>> que nos lo comunique inmediatamente por esta misma vía y proceda a su
>> destrucción.
>>
>> The information contained in this transmission is privileged and
>> confidential information intended only for the use of the individual or
>> entity named above. If the reader of this message is not the intended
>> recipient, you are hereby notified that any dissemination, distribution or
>> copying of this communication is strictly prohibited. If you have received
>> this transmission in error, do not read it. Please immediately reply to the
>> sender that you have received this communication in error and then delete
>> it.
>>
>> Esta mensagem e seus anexos se dirigem exclusivamente ao seu
>> destinatário, pode conter informação privilegiada ou confidencial e é para
>> uso exclusivo da pessoa ou entidade de destino. Se não é vossa senhoria o
>> destinatário indicado, fica notificado de que a leitura, utilização,
>> divulgação e/ou cópia sem autorização pode estar proibida em virtude da
>> legislação vigente. Se recebeu esta mensagem por erro, rogamos-lhe que nos
>> o comunique imediatamente por esta mesma via e proceda a sua destruição
>>
>
>


-- 
Romain Sagean

Reply via email to