Return-Path: X-Original-To: apmail-spark-issues-archive@minotaur.apache.org Delivered-To: apmail-spark-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1188F187CE for ; Tue, 28 Jul 2015 19:13:05 +0000 (UTC) Received: (qmail 80826 invoked by uid 500); 28 Jul 2015 19:13:04 -0000 Delivered-To: apmail-spark-issues-archive@spark.apache.org Received: (qmail 80798 invoked by uid 500); 28 Jul 2015 19:13:04 -0000 Mailing-List: contact issues-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@spark.apache.org Received: (qmail 80788 invoked by uid 99); 28 Jul 2015 19:13:04 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2015 19:13:04 +0000 Date: Tue, 28 Jul 2015 19:13:04 +0000 (UTC) From: "Joseph K. Bradley (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (SPARK-9277) SparseVector constructor must throw an error when declared number of elements less than array length MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/SPARK-9277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14644871#comment-14644871 ] Joseph K. Bradley commented on SPARK-9277: ------------------------------------------ I think a constant-time check is OK, but scanning the full array is too expensive. We want construction to be constant-time (a simple copying of a reference). > SparseVector constructor must throw an error when declared number of elements less than array length > ---------------------------------------------------------------------------------------------------- > > Key: SPARK-9277 > URL: https://issues.apache.org/jira/browse/SPARK-9277 > Project: Spark > Issue Type: Bug > Components: MLlib > Affects Versions: 1.3.1 > Reporter: Andrey Vykhodtsev > Priority: Minor > Labels: starter > Attachments: SparseVector test.html, SparseVector test.ipynb > > > I found that one can create SparseVector inconsistently and it will lead to an Java error in runtime, for example when training LogisticRegressionWithSGD. > Here is the test case: > In [2]: > sc.version > Out[2]: > u'1.3.1' > In [13]: > from pyspark.mllib.linalg import SparseVector > from pyspark.mllib.regression import LabeledPoint > from pyspark.mllib.classification import LogisticRegressionWithSGD > In [3]: > x = SparseVector(2, {1:1, 2:2, 3:3, 4:4, 5:5}) > In [10]: > l = LabeledPoint(0, x) > In [12]: > r = sc.parallelize([l]) > In [14]: > m = LogisticRegressionWithSGD.train(r) > Error: > Py4JJavaError: An error occurred while calling o86.trainLogisticRegressionModelWithSGD. > : org.apache.spark.SparkException: Job aborted due to stage failure: Task 7 in stage 11.0 failed 1 times, most recent failure: Lost task 7.0 in stage 11.0 (TID 47, localhost): java.lang.ArrayIndexOutOfBoundsException: 2 > Attached is the notebook with the scenario and the full message -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org