[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user asfgit closed the pull request at: https://github.com/apache/spark/pull/8102 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user jkbradley commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-139083436 LGTM. Merging with master. Thank you! --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-138812922 Merged build finished. Test PASSed. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user SparkQA commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-138812824 [Test build #42195 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/42195/console) for PR 8102 at commit [`67bf664`](https://github.com/apache/spark/commit/67bf6642d67c2ce53707a800652cd37f5db088c5). * This patch **passes all tests**. * This patch merges cleanly. * This patch adds the following public classes _(experimental)_: * `class VectorSlicer(JavaTransformer, HasInputCol, HasOutputCol):` --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-138812923 Test PASSed. Refer to this link for build results (access rights to CI server needed): https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/42195/ Test PASSed. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user SparkQA commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-138810764 [Test build #42195 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/42195/consoleFull) for PR 8102 at commit [`67bf664`](https://github.com/apache/spark/commit/67bf6642d67c2ce53707a800652cd37f5db088c5). --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-138810344 Merged build triggered. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-138810363 Merged build started. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132860927 Test PASSed. Refer to this link for build results (access rights to CI server needed): https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/41298/ Test PASSed. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132860925 Merged build finished. Test PASSed. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user SparkQA commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132860849 [Test build #41298 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/41298/console) for PR 8102 at commit [`879474d`](https://github.com/apache/spark/commit/879474da82f4692aeb875e68530e145fcb7f3c2e). * This patch **passes all tests**. * This patch merges cleanly. * This patch adds the following public classes _(experimental)_: * `class VectorSlicer(JavaTransformer, HasInputCol, HasOutputCol):` --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user SparkQA commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132857608 [Test build #41298 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/41298/consoleFull) for PR 8102 at commit [`879474d`](https://github.com/apache/spark/commit/879474da82f4692aeb875e68530e145fcb7f3c2e). --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132855718 Merged build started. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132855676 Merged build triggered. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user yanboliang commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132854062 Jenkins, test this please. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132560183 Build finished. Test FAILed. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132560185 Test FAILed. Refer to this link for build results (access rights to CI server needed): https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/41230/ Test FAILed. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user SparkQA commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132560134 **[Test build #41230 timed out](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/41230/console)** for PR 8102 at commit [`5d2f75b`](https://github.com/apache/spark/commit/5d2f75bdd4ab0592a630631299542771917c5f79) after a configured wait of `175m`. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132507685 Merged build finished. Test PASSed. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132507687 Test PASSed. Refer to this link for build results (access rights to CI server needed): https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/41232/ Test PASSed. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user SparkQA commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132507461 [Test build #41232 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/41232/console) for PR 8102 at commit [`879474d`](https://github.com/apache/spark/commit/879474da82f4692aeb875e68530e145fcb7f3c2e). * This patch **passes all tests**. * This patch merges cleanly. * This patch adds the following public classes _(experimental)_: * `class VectorSlicer(JavaTransformer, HasInputCol, HasOutputCol):` --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user SparkQA commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132502400 [Test build #41232 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/41232/consoleFull) for PR 8102 at commit [`879474d`](https://github.com/apache/spark/commit/879474da82f4692aeb875e68530e145fcb7f3c2e). --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132500987 Merged build started. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132500890 Merged build triggered. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user SparkQA commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132498799 [Test build #41230 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/41230/consoleFull) for PR 8102 at commit [`5d2f75b`](https://github.com/apache/spark/commit/5d2f75bdd4ab0592a630631299542771917c5f79). --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132498096 Build triggered. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132498127 Build started. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user jkbradley commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132345003 One more comment: need to add VectorSlicer to list ```__all__``` at top of file --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user jkbradley commented on a diff in the pull request: https://github.com/apache/spark/pull/8102#discussion_r37350810 --- Diff: python/pyspark/ml/feature.py --- @@ -950,6 +950,92 @@ class VectorIndexerModel(JavaModel): @inherit_doc +class VectorSlicer(JavaTransformer, HasInputCol, HasOutputCol): +""" +.. note:: Experimental + +This class takes a feature vector and outputs a new feature vector with a subarray +of the original features. + +The subset of features can be specified with either indices (`setIndices()`) +or names (`setNames()`). At least one feature must be selected. Duplicate features +are not allowed, so there can be no overlap between selected indices and names. + +The output vector will order features with the selected indices first (in the order given), +followed by the selected names (in the order given). + +>>> from pyspark.mllib.linalg import Vectors +>>> df = sqlContext.createDataFrame([ +... (Vectors.dense([-2.0, 2.3, 0.0, 0.0, 1.0]),), +... (Vectors.dense([0.0, 0.0, 0.0, 0.0, 0.0]),), +... (Vectors.dense([0.6, -1.1, -3.0, 4.5, 3.3]),)], ["features"]) +>>> vs = VectorSlicer(inputCol="features", outputCol="expected", indices=[1, 4]) +>>> vs.transform(df).head().expected +DenseVector([2.3, 1.0]) +""" + +# a placeholder to make it appear in the generated doc +indices = Param(Params._dummy(), "indices", "An array of indices to select features from " + +"a vector column. There can be no overlap with `names`.") +names = Param(Params._dummy(), "names", "An array of feature names to select features from " + + "a vector column. These names must be specified by ML " + + "`org.apache.spark.ml.attribute.Attribute`s. There can be no overlap with " + + "`indices`.") + +@keyword_only +def __init__(self, inputCol=None, outputCol=None, indices=[], names=[]): --- End diff -- In Python, we should avoid using mutable values ```[]``` as defaults. Let's use None. The Scala API should take care of the defaults. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user jkbradley commented on a diff in the pull request: https://github.com/apache/spark/pull/8102#discussion_r37350798 --- Diff: python/pyspark/ml/feature.py --- @@ -950,6 +950,92 @@ class VectorIndexerModel(JavaModel): @inherit_doc +class VectorSlicer(JavaTransformer, HasInputCol, HasOutputCol): +""" +.. note:: Experimental + +This class takes a feature vector and outputs a new feature vector with a subarray +of the original features. + +The subset of features can be specified with either indices (`setIndices()`) +or names (`setNames()`). At least one feature must be selected. Duplicate features +are not allowed, so there can be no overlap between selected indices and names. + +The output vector will order features with the selected indices first (in the order given), +followed by the selected names (in the order given). + +>>> from pyspark.mllib.linalg import Vectors +>>> df = sqlContext.createDataFrame([ +... (Vectors.dense([-2.0, 2.3, 0.0, 0.0, 1.0]),), +... (Vectors.dense([0.0, 0.0, 0.0, 0.0, 0.0]),), +... (Vectors.dense([0.6, -1.1, -3.0, 4.5, 3.3]),)], ["features"]) +>>> vs = VectorSlicer(inputCol="features", outputCol="expected", indices=[1, 4]) --- End diff -- Rename "expected" to "sliced" since this is an example --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user jkbradley commented on a diff in the pull request: https://github.com/apache/spark/pull/8102#discussion_r37350812 --- Diff: python/pyspark/ml/feature.py --- @@ -950,6 +950,92 @@ class VectorIndexerModel(JavaModel): @inherit_doc +class VectorSlicer(JavaTransformer, HasInputCol, HasOutputCol): +""" +.. note:: Experimental + +This class takes a feature vector and outputs a new feature vector with a subarray +of the original features. + +The subset of features can be specified with either indices (`setIndices()`) +or names (`setNames()`). At least one feature must be selected. Duplicate features +are not allowed, so there can be no overlap between selected indices and names. + +The output vector will order features with the selected indices first (in the order given), +followed by the selected names (in the order given). + +>>> from pyspark.mllib.linalg import Vectors +>>> df = sqlContext.createDataFrame([ +... (Vectors.dense([-2.0, 2.3, 0.0, 0.0, 1.0]),), +... (Vectors.dense([0.0, 0.0, 0.0, 0.0, 0.0]),), +... (Vectors.dense([0.6, -1.1, -3.0, 4.5, 3.3]),)], ["features"]) +>>> vs = VectorSlicer(inputCol="features", outputCol="expected", indices=[1, 4]) +>>> vs.transform(df).head().expected +DenseVector([2.3, 1.0]) +""" + +# a placeholder to make it appear in the generated doc +indices = Param(Params._dummy(), "indices", "An array of indices to select features from " + +"a vector column. There can be no overlap with `names`.") +names = Param(Params._dummy(), "names", "An array of feature names to select features from " + + "a vector column. These names must be specified by ML " + + "`org.apache.spark.ml.attribute.Attribute`s. There can be no overlap with " + + "`indices`.") + +@keyword_only +def __init__(self, inputCol=None, outputCol=None, indices=[], names=[]): +""" +__init__(self, inputCol=None, outputCol=None, indices=[], names=[]) +""" +super(VectorSlicer, self).__init__() +self._java_obj = self._new_java_obj("org.apache.spark.ml.feature.VectorSlicer", self.uid) +self.indices = Param(self, "indices", "An array of indices to select features from " + + "a vector column. There can be no overlap with `names`.") +self.names = Param(self, "names", "An array of feature names to select features from " + + "a vector column. These names must be specified by ML " + + "`org.apache.spark.ml.attribute.Attribute`s. There can be no overlap " + + "with `indices`.") +self._setDefault(indices=[], names=[]) --- End diff -- so no defaults here --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user jkbradley commented on a diff in the pull request: https://github.com/apache/spark/pull/8102#discussion_r37350805 --- Diff: python/pyspark/ml/feature.py --- @@ -950,6 +950,92 @@ class VectorIndexerModel(JavaModel): @inherit_doc +class VectorSlicer(JavaTransformer, HasInputCol, HasOutputCol): +""" +.. note:: Experimental + +This class takes a feature vector and outputs a new feature vector with a subarray +of the original features. + +The subset of features can be specified with either indices (`setIndices()`) +or names (`setNames()`). At least one feature must be selected. Duplicate features +are not allowed, so there can be no overlap between selected indices and names. + +The output vector will order features with the selected indices first (in the order given), +followed by the selected names (in the order given). + +>>> from pyspark.mllib.linalg import Vectors +>>> df = sqlContext.createDataFrame([ +... (Vectors.dense([-2.0, 2.3, 0.0, 0.0, 1.0]),), +... (Vectors.dense([0.0, 0.0, 0.0, 0.0, 0.0]),), +... (Vectors.dense([0.6, -1.1, -3.0, 4.5, 3.3]),)], ["features"]) +>>> vs = VectorSlicer(inputCol="features", outputCol="expected", indices=[1, 4]) +>>> vs.transform(df).head().expected +DenseVector([2.3, 1.0]) +""" + +# a placeholder to make it appear in the generated doc +indices = Param(Params._dummy(), "indices", "An array of indices to select features from " + +"a vector column. There can be no overlap with `names`.") +names = Param(Params._dummy(), "names", "An array of feature names to select features from " + + "a vector column. These names must be specified by ML " + + "`org.apache.spark.ml.attribute.Attribute`s. There can be no overlap with " + --- End diff -- No need for backtick within strings; the backtick is only for formatting generated API docs. (here and elsewhere) --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user jkbradley commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-132332280 reviewing now --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-130872240 Merged build finished. Test PASSed. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user SparkQA commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-130872159 [Test build #40826 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/40826/console) for PR 8102 at commit [`54bffab`](https://github.com/apache/spark/commit/54bffab42600aa184eb01134410f266199d19a97). * This patch **passes all tests**. * This patch merges cleanly. * This patch adds the following public classes _(experimental)_: * `class VectorSlicer(JavaTransformer, HasInputCol, HasOutputCol):` --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user SparkQA commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-130868979 [Test build #40826 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/40826/consoleFull) for PR 8102 at commit [`54bffab`](https://github.com/apache/spark/commit/54bffab42600aa184eb01134410f266199d19a97). --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-130868523 Merged build triggered. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user AmplabJenkins commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-130868536 Merged build started. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request: [SPARK-9772] [PySpark] [ML] Add Python API for...
Github user jkbradley commented on the pull request: https://github.com/apache/spark/pull/8102#issuecomment-130868338 test this please --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org