partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | DataFrameWriter.options | Adds output options for the underlying data source.
You can set the following option(s) for writing files:
* ``timeZone``: sets the string that indicates a timezone to be used to format
timestamps in the JSON/CSV datasources or partition values.
If it isn't set, it u... | python/pyspark/sql/readwriter.py | def options(self, **options):
"""Adds output options for the underlying data source.
You can set the following option(s) for writing files:
* ``timeZone``: sets the string that indicates a timezone to be used to format
timestamps in the JSON/CSV datasources or partition valu... | def options(self, **options):
"""Adds output options for the underlying data source.
You can set the following option(s) for writing files:
* ``timeZone``: sets the string that indicates a timezone to be used to format
timestamps in the JSON/CSV datasources or partition valu... | [
"Adds",
"output",
"options",
"for",
"the",
"underlying",
"data",
"source",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L632-L642 | [
"def",
"options",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"for",
"k",
"in",
"options",
":",
"self",
".",
"_jwrite",
"=",
"self",
".",
"_jwrite",
".",
"option",
"(",
"k",
",",
"to_str",
"(",
"options",
"[",
"k",
"]",
")",
")",
"return",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.partitionBy | Partitions the output by the given columns on the file system.
If specified, the output is laid out on the file system similar
to Hive's partitioning scheme.
:param cols: name of columns
>>> df.write.partitionBy('year', 'month').parquet(os.path.join(tempfile.mkdtemp(), 'data')) | python/pyspark/sql/readwriter.py | def partitionBy(self, *cols):
"""Partitions the output by the given columns on the file system.
If specified, the output is laid out on the file system similar
to Hive's partitioning scheme.
:param cols: name of columns
>>> df.write.partitionBy('year', 'month').parquet(os.path... | def partitionBy(self, *cols):
"""Partitions the output by the given columns on the file system.
If specified, the output is laid out on the file system similar
to Hive's partitioning scheme.
:param cols: name of columns
>>> df.write.partitionBy('year', 'month').parquet(os.path... | [
"Partitions",
"the",
"output",
"by",
"the",
"given",
"columns",
"on",
"the",
"file",
"system",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L645-L658 | [
"def",
"partitionBy",
"(",
"self",
",",
"*",
"cols",
")",
":",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
"and",
"isinstance",
"(",
"cols",
"[",
"0",
"]",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"cols",
"=",
"cols",
"[",
"0",
"]",
"self... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.sortBy | Sorts the output in each bucket by the given columns on the file system.
:param col: a name of a column, or a list of names.
:param cols: additional names (optional). If `col` is a list it should be empty.
>>> (df.write.format('parquet') # doctest: +SKIP
... .bucketBy(100, 'year',... | python/pyspark/sql/readwriter.py | def sortBy(self, col, *cols):
"""Sorts the output in each bucket by the given columns on the file system.
:param col: a name of a column, or a list of names.
:param cols: additional names (optional). If `col` is a list it should be empty.
>>> (df.write.format('parquet') # doctest: +SK... | def sortBy(self, col, *cols):
"""Sorts the output in each bucket by the given columns on the file system.
:param col: a name of a column, or a list of names.
:param cols: additional names (optional). If `col` is a list it should be empty.
>>> (df.write.format('parquet') # doctest: +SK... | [
"Sorts",
"the",
"output",
"in",
"each",
"bucket",
"by",
"the",
"given",
"columns",
"on",
"the",
"file",
"system",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L693-L715 | [
"def",
"sortBy",
"(",
"self",
",",
"col",
",",
"*",
"cols",
")",
":",
"if",
"isinstance",
"(",
"col",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"if",
"cols",
":",
"raise",
"ValueError",
"(",
"\"col is a {0} but cols are not empty\"",
".",
"format",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.save | Saves the contents of the :class:`DataFrame` to a data source.
The data source is specified by the ``format`` and a set of ``options``.
If ``format`` is not specified, the default data source configured by
``spark.sql.sources.default`` will be used.
:param path: the path in a Hadoop su... | python/pyspark/sql/readwriter.py | def save(self, path=None, format=None, mode=None, partitionBy=None, **options):
"""Saves the contents of the :class:`DataFrame` to a data source.
The data source is specified by the ``format`` and a set of ``options``.
If ``format`` is not specified, the default data source configured by
... | def save(self, path=None, format=None, mode=None, partitionBy=None, **options):
"""Saves the contents of the :class:`DataFrame` to a data source.
The data source is specified by the ``format`` and a set of ``options``.
If ``format`` is not specified, the default data source configured by
... | [
"Saves",
"the",
"contents",
"of",
"the",
":",
"class",
":",
"DataFrame",
"to",
"a",
"data",
"source",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L718-L747 | [
"def",
"save",
"(",
"self",
",",
"path",
"=",
"None",
",",
"format",
"=",
"None",
",",
"mode",
"=",
"None",
",",
"partitionBy",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"mode",
"(",
"mode",
")",
".",
"options",
"(",
"*",
"*... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.insertInto | Inserts the content of the :class:`DataFrame` to the specified table.
It requires that the schema of the class:`DataFrame` is the same as the
schema of the table.
Optionally overwriting any existing data. | python/pyspark/sql/readwriter.py | def insertInto(self, tableName, overwrite=False):
"""Inserts the content of the :class:`DataFrame` to the specified table.
It requires that the schema of the class:`DataFrame` is the same as the
schema of the table.
Optionally overwriting any existing data.
"""
self._jw... | def insertInto(self, tableName, overwrite=False):
"""Inserts the content of the :class:`DataFrame` to the specified table.
It requires that the schema of the class:`DataFrame` is the same as the
schema of the table.
Optionally overwriting any existing data.
"""
self._jw... | [
"Inserts",
"the",
"content",
"of",
"the",
":",
"class",
":",
"DataFrame",
"to",
"the",
"specified",
"table",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L750-L758 | [
"def",
"insertInto",
"(",
"self",
",",
"tableName",
",",
"overwrite",
"=",
"False",
")",
":",
"self",
".",
"_jwrite",
".",
"mode",
"(",
"\"overwrite\"",
"if",
"overwrite",
"else",
"\"append\"",
")",
".",
"insertInto",
"(",
"tableName",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.saveAsTable | Saves the content of the :class:`DataFrame` as the specified table.
In the case the table already exists, behavior of this function depends on the
save mode, specified by the `mode` function (default to throwing an exception).
When `mode` is `Overwrite`, the schema of the :class:`DataFrame` doe... | python/pyspark/sql/readwriter.py | def saveAsTable(self, name, format=None, mode=None, partitionBy=None, **options):
"""Saves the content of the :class:`DataFrame` as the specified table.
In the case the table already exists, behavior of this function depends on the
save mode, specified by the `mode` function (default to throwin... | def saveAsTable(self, name, format=None, mode=None, partitionBy=None, **options):
"""Saves the content of the :class:`DataFrame` as the specified table.
In the case the table already exists, behavior of this function depends on the
save mode, specified by the `mode` function (default to throwin... | [
"Saves",
"the",
"content",
"of",
"the",
":",
"class",
":",
"DataFrame",
"as",
"the",
"specified",
"table",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L761-L786 | [
"def",
"saveAsTable",
"(",
"self",
",",
"name",
",",
"format",
"=",
"None",
",",
"mode",
"=",
"None",
",",
"partitionBy",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"mode",
"(",
"mode",
")",
".",
"options",
"(",
"*",
"*",
"opti... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.json | Saves the content of the :class:`DataFrame` in JSON format
(`JSON Lines text format or newline-delimited JSON <http://jsonlines.org/>`_) at the
specified path.
:param path: the path in any Hadoop supported file system
:param mode: specifies the behavior of the save operation when data a... | python/pyspark/sql/readwriter.py | def json(self, path, mode=None, compression=None, dateFormat=None, timestampFormat=None,
lineSep=None, encoding=None):
"""Saves the content of the :class:`DataFrame` in JSON format
(`JSON Lines text format or newline-delimited JSON <http://jsonlines.org/>`_) at the
specified path.
... | def json(self, path, mode=None, compression=None, dateFormat=None, timestampFormat=None,
lineSep=None, encoding=None):
"""Saves the content of the :class:`DataFrame` in JSON format
(`JSON Lines text format or newline-delimited JSON <http://jsonlines.org/>`_) at the
specified path.
... | [
"Saves",
"the",
"content",
"of",
"the",
":",
"class",
":",
"DataFrame",
"in",
"JSON",
"format",
"(",
"JSON",
"Lines",
"text",
"format",
"or",
"newline",
"-",
"delimited",
"JSON",
"<http",
":",
"//",
"jsonlines",
".",
"org",
"/",
">",
"_",
")",
"at",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L789-L826 | [
"def",
"json",
"(",
"self",
",",
"path",
",",
"mode",
"=",
"None",
",",
"compression",
"=",
"None",
",",
"dateFormat",
"=",
"None",
",",
"timestampFormat",
"=",
"None",
",",
"lineSep",
"=",
"None",
",",
"encoding",
"=",
"None",
")",
":",
"self",
".",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.parquet | Saves the content of the :class:`DataFrame` in Parquet format at the specified path.
:param path: the path in any Hadoop supported file system
:param mode: specifies the behavior of the save operation when data already exists.
* ``append``: Append contents of this :class:`DataFrame` to exi... | python/pyspark/sql/readwriter.py | def parquet(self, path, mode=None, partitionBy=None, compression=None):
"""Saves the content of the :class:`DataFrame` in Parquet format at the specified path.
:param path: the path in any Hadoop supported file system
:param mode: specifies the behavior of the save operation when data already e... | def parquet(self, path, mode=None, partitionBy=None, compression=None):
"""Saves the content of the :class:`DataFrame` in Parquet format at the specified path.
:param path: the path in any Hadoop supported file system
:param mode: specifies the behavior of the save operation when data already e... | [
"Saves",
"the",
"content",
"of",
"the",
":",
"class",
":",
"DataFrame",
"in",
"Parquet",
"format",
"at",
"the",
"specified",
"path",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L829-L853 | [
"def",
"parquet",
"(",
"self",
",",
"path",
",",
"mode",
"=",
"None",
",",
"partitionBy",
"=",
"None",
",",
"compression",
"=",
"None",
")",
":",
"self",
".",
"mode",
"(",
"mode",
")",
"if",
"partitionBy",
"is",
"not",
"None",
":",
"self",
".",
"pa... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.text | Saves the content of the DataFrame in a text file at the specified path.
The text files will be encoded as UTF-8.
:param path: the path in any Hadoop supported file system
:param compression: compression codec to use when saving to file. This can be one of the
known ... | python/pyspark/sql/readwriter.py | def text(self, path, compression=None, lineSep=None):
"""Saves the content of the DataFrame in a text file at the specified path.
The text files will be encoded as UTF-8.
:param path: the path in any Hadoop supported file system
:param compression: compression codec to use when saving t... | def text(self, path, compression=None, lineSep=None):
"""Saves the content of the DataFrame in a text file at the specified path.
The text files will be encoded as UTF-8.
:param path: the path in any Hadoop supported file system
:param compression: compression codec to use when saving t... | [
"Saves",
"the",
"content",
"of",
"the",
"DataFrame",
"in",
"a",
"text",
"file",
"at",
"the",
"specified",
"path",
".",
"The",
"text",
"files",
"will",
"be",
"encoded",
"as",
"UTF",
"-",
"8",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L856-L871 | [
"def",
"text",
"(",
"self",
",",
"path",
",",
"compression",
"=",
"None",
",",
"lineSep",
"=",
"None",
")",
":",
"self",
".",
"_set_opts",
"(",
"compression",
"=",
"compression",
",",
"lineSep",
"=",
"lineSep",
")",
"self",
".",
"_jwrite",
".",
"text",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.csv | r"""Saves the content of the :class:`DataFrame` in CSV format at the specified path.
:param path: the path in any Hadoop supported file system
:param mode: specifies the behavior of the save operation when data already exists.
* ``append``: Append contents of this :class:`DataFrame` to exi... | python/pyspark/sql/readwriter.py | def csv(self, path, mode=None, compression=None, sep=None, quote=None, escape=None,
header=None, nullValue=None, escapeQuotes=None, quoteAll=None, dateFormat=None,
timestampFormat=None, ignoreLeadingWhiteSpace=None, ignoreTrailingWhiteSpace=None,
charToEscapeQuoteEscaping=None, encod... | def csv(self, path, mode=None, compression=None, sep=None, quote=None, escape=None,
header=None, nullValue=None, escapeQuotes=None, quoteAll=None, dateFormat=None,
timestampFormat=None, ignoreLeadingWhiteSpace=None, ignoreTrailingWhiteSpace=None,
charToEscapeQuoteEscaping=None, encod... | [
"r",
"Saves",
"the",
"content",
"of",
"the",
":",
"class",
":",
"DataFrame",
"in",
"CSV",
"format",
"at",
"the",
"specified",
"path",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L874-L945 | [
"def",
"csv",
"(",
"self",
",",
"path",
",",
"mode",
"=",
"None",
",",
"compression",
"=",
"None",
",",
"sep",
"=",
"None",
",",
"quote",
"=",
"None",
",",
"escape",
"=",
"None",
",",
"header",
"=",
"None",
",",
"nullValue",
"=",
"None",
",",
"es... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.orc | Saves the content of the :class:`DataFrame` in ORC format at the specified path.
:param path: the path in any Hadoop supported file system
:param mode: specifies the behavior of the save operation when data already exists.
* ``append``: Append contents of this :class:`DataFrame` to existin... | python/pyspark/sql/readwriter.py | def orc(self, path, mode=None, partitionBy=None, compression=None):
"""Saves the content of the :class:`DataFrame` in ORC format at the specified path.
:param path: the path in any Hadoop supported file system
:param mode: specifies the behavior of the save operation when data already exists.
... | def orc(self, path, mode=None, partitionBy=None, compression=None):
"""Saves the content of the :class:`DataFrame` in ORC format at the specified path.
:param path: the path in any Hadoop supported file system
:param mode: specifies the behavior of the save operation when data already exists.
... | [
"Saves",
"the",
"content",
"of",
"the",
":",
"class",
":",
"DataFrame",
"in",
"ORC",
"format",
"at",
"the",
"specified",
"path",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L948-L973 | [
"def",
"orc",
"(",
"self",
",",
"path",
",",
"mode",
"=",
"None",
",",
"partitionBy",
"=",
"None",
",",
"compression",
"=",
"None",
")",
":",
"self",
".",
"mode",
"(",
"mode",
")",
"if",
"partitionBy",
"is",
"not",
"None",
":",
"self",
".",
"partit... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DataFrameWriter.jdbc | Saves the content of the :class:`DataFrame` to an external database table via JDBC.
.. note:: Don't create too many partitions in parallel on a large cluster;
otherwise Spark might crash your external database systems.
:param url: a JDBC URL of the form ``jdbc:subprotocol:subname``
... | python/pyspark/sql/readwriter.py | def jdbc(self, url, table, mode=None, properties=None):
"""Saves the content of the :class:`DataFrame` to an external database table via JDBC.
.. note:: Don't create too many partitions in parallel on a large cluster;
otherwise Spark might crash your external database systems.
:par... | def jdbc(self, url, table, mode=None, properties=None):
"""Saves the content of the :class:`DataFrame` to an external database table via JDBC.
.. note:: Don't create too many partitions in parallel on a large cluster;
otherwise Spark might crash your external database systems.
:par... | [
"Saves",
"the",
"content",
"of",
"the",
":",
"class",
":",
"DataFrame",
"to",
"an",
"external",
"database",
"table",
"via",
"JDBC",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L976-L1000 | [
"def",
"jdbc",
"(",
"self",
",",
"url",
",",
"table",
",",
"mode",
"=",
"None",
",",
"properties",
"=",
"None",
")",
":",
"if",
"properties",
"is",
"None",
":",
"properties",
"=",
"dict",
"(",
")",
"jprop",
"=",
"JavaClass",
"(",
"\"java.util.Propertie... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | KinesisUtils.createStream | Create an input stream that pulls messages from a Kinesis stream. This uses the
Kinesis Client Library (KCL) to pull messages from Kinesis.
.. note:: The given AWS credentials will get saved in DStream checkpoints if checkpointing
is enabled. Make sure that your checkpoint directory is secu... | python/pyspark/streaming/kinesis.py | def createStream(ssc, kinesisAppName, streamName, endpointUrl, regionName,
initialPositionInStream, checkpointInterval,
storageLevel=StorageLevel.MEMORY_AND_DISK_2,
awsAccessKeyId=None, awsSecretKey=None, decoder=utf8_decoder,
stsAssume... | def createStream(ssc, kinesisAppName, streamName, endpointUrl, regionName,
initialPositionInStream, checkpointInterval,
storageLevel=StorageLevel.MEMORY_AND_DISK_2,
awsAccessKeyId=None, awsSecretKey=None, decoder=utf8_decoder,
stsAssume... | [
"Create",
"an",
"input",
"stream",
"that",
"pulls",
"messages",
"from",
"a",
"Kinesis",
"stream",
".",
"This",
"uses",
"the",
"Kinesis",
"Client",
"Library",
"(",
"KCL",
")",
"to",
"pull",
"messages",
"from",
"Kinesis",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/kinesis.py#L37-L98 | [
"def",
"createStream",
"(",
"ssc",
",",
"kinesisAppName",
",",
"streamName",
",",
"endpointUrl",
",",
"regionName",
",",
"initialPositionInStream",
",",
"checkpointInterval",
",",
"storageLevel",
"=",
"StorageLevel",
".",
"MEMORY_AND_DISK_2",
",",
"awsAccessKeyId",
"=... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | choose_jira_assignee | Prompt the user to choose who to assign the issue to in jira, given a list of candidates,
including the original reporter and all commentors | dev/merge_spark_pr.py | def choose_jira_assignee(issue, asf_jira):
"""
Prompt the user to choose who to assign the issue to in jira, given a list of candidates,
including the original reporter and all commentors
"""
while True:
try:
reporter = issue.fields.reporter
commentors = map(lambda x:... | def choose_jira_assignee(issue, asf_jira):
"""
Prompt the user to choose who to assign the issue to in jira, given a list of candidates,
including the original reporter and all commentors
"""
while True:
try:
reporter = issue.fields.reporter
commentors = map(lambda x:... | [
"Prompt",
"the",
"user",
"to",
"choose",
"who",
"to",
"assign",
"the",
"issue",
"to",
"in",
"jira",
"given",
"a",
"list",
"of",
"candidates",
"including",
"the",
"original",
"reporter",
"and",
"all",
"commentors"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/dev/merge_spark_pr.py#L325-L362 | [
"def",
"choose_jira_assignee",
"(",
"issue",
",",
"asf_jira",
")",
":",
"while",
"True",
":",
"try",
":",
"reporter",
"=",
"issue",
".",
"fields",
".",
"reporter",
"commentors",
"=",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"author",
",",
"issue",
"."... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | standardize_jira_ref | Standardize the [SPARK-XXXXX] [MODULE] prefix
Converts "[SPARK-XXX][mllib] Issue", "[MLLib] SPARK-XXX. Issue" or "SPARK XXX [MLLIB]: Issue" to
"[SPARK-XXX][MLLIB] Issue"
>>> standardize_jira_ref(
... "[SPARK-5821] [SQL] ParquetRelation2 CTAS should check if delete is successful")
'[SPARK-5821][... | dev/merge_spark_pr.py | def standardize_jira_ref(text):
"""
Standardize the [SPARK-XXXXX] [MODULE] prefix
Converts "[SPARK-XXX][mllib] Issue", "[MLLib] SPARK-XXX. Issue" or "SPARK XXX [MLLIB]: Issue" to
"[SPARK-XXX][MLLIB] Issue"
>>> standardize_jira_ref(
... "[SPARK-5821] [SQL] ParquetRelation2 CTAS should check ... | def standardize_jira_ref(text):
"""
Standardize the [SPARK-XXXXX] [MODULE] prefix
Converts "[SPARK-XXX][mllib] Issue", "[MLLib] SPARK-XXX. Issue" or "SPARK XXX [MLLIB]: Issue" to
"[SPARK-XXX][MLLIB] Issue"
>>> standardize_jira_ref(
... "[SPARK-5821] [SQL] ParquetRelation2 CTAS should check ... | [
"Standardize",
"the",
"[",
"SPARK",
"-",
"XXXXX",
"]",
"[",
"MODULE",
"]",
"prefix",
"Converts",
"[",
"SPARK",
"-",
"XXX",
"]",
"[",
"mllib",
"]",
"Issue",
"[",
"MLLib",
"]",
"SPARK",
"-",
"XXX",
".",
"Issue",
"or",
"SPARK",
"XXX",
"[",
"MLLIB",
"]... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/dev/merge_spark_pr.py#L374-L437 | [
"def",
"standardize_jira_ref",
"(",
"text",
")",
":",
"jira_refs",
"=",
"[",
"]",
"components",
"=",
"[",
"]",
"# If the string is compliant, no need to process any further",
"if",
"(",
"re",
".",
"search",
"(",
"r'^\\[SPARK-[0-9]{3,6}\\](\\[[A-Z0-9_\\s,]+\\] )+\\S+'",
",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | MLUtils._parse_libsvm_line | Parses a line in LIBSVM format into (label, indices, values). | python/pyspark/mllib/util.py | def _parse_libsvm_line(line):
"""
Parses a line in LIBSVM format into (label, indices, values).
"""
items = line.split(None)
label = float(items[0])
nnz = len(items) - 1
indices = np.zeros(nnz, dtype=np.int32)
values = np.zeros(nnz)
for i in xrange... | def _parse_libsvm_line(line):
"""
Parses a line in LIBSVM format into (label, indices, values).
"""
items = line.split(None)
label = float(items[0])
nnz = len(items) - 1
indices = np.zeros(nnz, dtype=np.int32)
values = np.zeros(nnz)
for i in xrange... | [
"Parses",
"a",
"line",
"in",
"LIBSVM",
"format",
"into",
"(",
"label",
"indices",
"values",
")",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L40-L53 | [
"def",
"_parse_libsvm_line",
"(",
"line",
")",
":",
"items",
"=",
"line",
".",
"split",
"(",
"None",
")",
"label",
"=",
"float",
"(",
"items",
"[",
"0",
"]",
")",
"nnz",
"=",
"len",
"(",
"items",
")",
"-",
"1",
"indices",
"=",
"np",
".",
"zeros",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | MLUtils._convert_labeled_point_to_libsvm | Converts a LabeledPoint to a string in LIBSVM format. | python/pyspark/mllib/util.py | def _convert_labeled_point_to_libsvm(p):
"""Converts a LabeledPoint to a string in LIBSVM format."""
from pyspark.mllib.regression import LabeledPoint
assert isinstance(p, LabeledPoint)
items = [str(p.label)]
v = _convert_to_vector(p.features)
if isinstance(v, SparseVecto... | def _convert_labeled_point_to_libsvm(p):
"""Converts a LabeledPoint to a string in LIBSVM format."""
from pyspark.mllib.regression import LabeledPoint
assert isinstance(p, LabeledPoint)
items = [str(p.label)]
v = _convert_to_vector(p.features)
if isinstance(v, SparseVecto... | [
"Converts",
"a",
"LabeledPoint",
"to",
"a",
"string",
"in",
"LIBSVM",
"format",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L56-L69 | [
"def",
"_convert_labeled_point_to_libsvm",
"(",
"p",
")",
":",
"from",
"pyspark",
".",
"mllib",
".",
"regression",
"import",
"LabeledPoint",
"assert",
"isinstance",
"(",
"p",
",",
"LabeledPoint",
")",
"items",
"=",
"[",
"str",
"(",
"p",
".",
"label",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | MLUtils.loadLibSVMFile | Loads labeled data in the LIBSVM format into an RDD of
LabeledPoint. The LIBSVM format is a text-based format used by
LIBSVM and LIBLINEAR. Each line represents a labeled sparse
feature vector using the following format:
label index1:value1 index2:value2 ...
where the indices a... | python/pyspark/mllib/util.py | def loadLibSVMFile(sc, path, numFeatures=-1, minPartitions=None):
"""
Loads labeled data in the LIBSVM format into an RDD of
LabeledPoint. The LIBSVM format is a text-based format used by
LIBSVM and LIBLINEAR. Each line represents a labeled sparse
feature vector using the followi... | def loadLibSVMFile(sc, path, numFeatures=-1, minPartitions=None):
"""
Loads labeled data in the LIBSVM format into an RDD of
LabeledPoint. The LIBSVM format is a text-based format used by
LIBSVM and LIBLINEAR. Each line represents a labeled sparse
feature vector using the followi... | [
"Loads",
"labeled",
"data",
"in",
"the",
"LIBSVM",
"format",
"into",
"an",
"RDD",
"of",
"LabeledPoint",
".",
"The",
"LIBSVM",
"format",
"is",
"a",
"text",
"-",
"based",
"format",
"used",
"by",
"LIBSVM",
"and",
"LIBLINEAR",
".",
"Each",
"line",
"represents"... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L73-L122 | [
"def",
"loadLibSVMFile",
"(",
"sc",
",",
"path",
",",
"numFeatures",
"=",
"-",
"1",
",",
"minPartitions",
"=",
"None",
")",
":",
"from",
"pyspark",
".",
"mllib",
".",
"regression",
"import",
"LabeledPoint",
"lines",
"=",
"sc",
".",
"textFile",
"(",
"path... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | MLUtils.saveAsLibSVMFile | Save labeled data in LIBSVM format.
:param data: an RDD of LabeledPoint to be saved
:param dir: directory to save the data
>>> from tempfile import NamedTemporaryFile
>>> from fileinput import input
>>> from pyspark.mllib.regression import LabeledPoint
>>> from glob imp... | python/pyspark/mllib/util.py | def saveAsLibSVMFile(data, dir):
"""
Save labeled data in LIBSVM format.
:param data: an RDD of LabeledPoint to be saved
:param dir: directory to save the data
>>> from tempfile import NamedTemporaryFile
>>> from fileinput import input
>>> from pyspark.mllib.reg... | def saveAsLibSVMFile(data, dir):
"""
Save labeled data in LIBSVM format.
:param data: an RDD of LabeledPoint to be saved
:param dir: directory to save the data
>>> from tempfile import NamedTemporaryFile
>>> from fileinput import input
>>> from pyspark.mllib.reg... | [
"Save",
"labeled",
"data",
"in",
"LIBSVM",
"format",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L126-L147 | [
"def",
"saveAsLibSVMFile",
"(",
"data",
",",
"dir",
")",
":",
"lines",
"=",
"data",
".",
"map",
"(",
"lambda",
"p",
":",
"MLUtils",
".",
"_convert_labeled_point_to_libsvm",
"(",
"p",
")",
")",
"lines",
".",
"saveAsTextFile",
"(",
"dir",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | MLUtils.loadLabeledPoints | Load labeled points saved using RDD.saveAsTextFile.
:param sc: Spark context
:param path: file or directory path in any Hadoop-supported file
system URI
:param minPartitions: min number of partitions
@return: labeled data stored as an RDD of LabeledPoint
>>... | python/pyspark/mllib/util.py | def loadLabeledPoints(sc, path, minPartitions=None):
"""
Load labeled points saved using RDD.saveAsTextFile.
:param sc: Spark context
:param path: file or directory path in any Hadoop-supported file
system URI
:param minPartitions: min number of partitions
... | def loadLabeledPoints(sc, path, minPartitions=None):
"""
Load labeled points saved using RDD.saveAsTextFile.
:param sc: Spark context
:param path: file or directory path in any Hadoop-supported file
system URI
:param minPartitions: min number of partitions
... | [
"Load",
"labeled",
"points",
"saved",
"using",
"RDD",
".",
"saveAsTextFile",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L151-L173 | [
"def",
"loadLabeledPoints",
"(",
"sc",
",",
"path",
",",
"minPartitions",
"=",
"None",
")",
":",
"minPartitions",
"=",
"minPartitions",
"or",
"min",
"(",
"sc",
".",
"defaultParallelism",
",",
"2",
")",
"return",
"callMLlibFunc",
"(",
"\"loadLabeledPoints\"",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | MLUtils.appendBias | Returns a new vector with `1.0` (bias) appended to
the end of the input vector. | python/pyspark/mllib/util.py | def appendBias(data):
"""
Returns a new vector with `1.0` (bias) appended to
the end of the input vector.
"""
vec = _convert_to_vector(data)
if isinstance(vec, SparseVector):
newIndices = np.append(vec.indices, len(vec))
newValues = np.append(vec.v... | def appendBias(data):
"""
Returns a new vector with `1.0` (bias) appended to
the end of the input vector.
"""
vec = _convert_to_vector(data)
if isinstance(vec, SparseVector):
newIndices = np.append(vec.indices, len(vec))
newValues = np.append(vec.v... | [
"Returns",
"a",
"new",
"vector",
"with",
"1",
".",
"0",
"(",
"bias",
")",
"appended",
"to",
"the",
"end",
"of",
"the",
"input",
"vector",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L177-L188 | [
"def",
"appendBias",
"(",
"data",
")",
":",
"vec",
"=",
"_convert_to_vector",
"(",
"data",
")",
"if",
"isinstance",
"(",
"vec",
",",
"SparseVector",
")",
":",
"newIndices",
"=",
"np",
".",
"append",
"(",
"vec",
".",
"indices",
",",
"len",
"(",
"vec",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | MLUtils.convertVectorColumnsToML | Converts vector columns in an input DataFrame from the
:py:class:`pyspark.mllib.linalg.Vector` type to the new
:py:class:`pyspark.ml.linalg.Vector` type under the `spark.ml`
package.
:param dataset:
input dataset
:param cols:
a list of vector columns to be co... | python/pyspark/mllib/util.py | def convertVectorColumnsToML(dataset, *cols):
"""
Converts vector columns in an input DataFrame from the
:py:class:`pyspark.mllib.linalg.Vector` type to the new
:py:class:`pyspark.ml.linalg.Vector` type under the `spark.ml`
package.
:param dataset:
input datase... | def convertVectorColumnsToML(dataset, *cols):
"""
Converts vector columns in an input DataFrame from the
:py:class:`pyspark.mllib.linalg.Vector` type to the new
:py:class:`pyspark.ml.linalg.Vector` type under the `spark.ml`
package.
:param dataset:
input datase... | [
"Converts",
"vector",
"columns",
"in",
"an",
"input",
"DataFrame",
"from",
"the",
":",
"py",
":",
"class",
":",
"pyspark",
".",
"mllib",
".",
"linalg",
".",
"Vector",
"type",
"to",
"the",
"new",
":",
"py",
":",
"class",
":",
"pyspark",
".",
"ml",
"."... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L201-L237 | [
"def",
"convertVectorColumnsToML",
"(",
"dataset",
",",
"*",
"cols",
")",
":",
"if",
"not",
"isinstance",
"(",
"dataset",
",",
"DataFrame",
")",
":",
"raise",
"TypeError",
"(",
"\"Input dataset must be a DataFrame but got {}.\"",
".",
"format",
"(",
"type",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | LinearDataGenerator.generateLinearInput | :param: intercept bias factor, the term c in X'w + c
:param: weights feature vector, the term w in X'w + c
:param: xMean Point around which the data X is centered.
:param: xVariance Variance of the given data
:param: nPoints Number of points to be generated
:param: seed ... | python/pyspark/mllib/util.py | def generateLinearInput(intercept, weights, xMean, xVariance,
nPoints, seed, eps):
"""
:param: intercept bias factor, the term c in X'w + c
:param: weights feature vector, the term w in X'w + c
:param: xMean Point around which the data X is centered.
... | def generateLinearInput(intercept, weights, xMean, xVariance,
nPoints, seed, eps):
"""
:param: intercept bias factor, the term c in X'w + c
:param: weights feature vector, the term w in X'w + c
:param: xMean Point around which the data X is centered.
... | [
":",
"param",
":",
"intercept",
"bias",
"factor",
"the",
"term",
"c",
"in",
"X",
"w",
"+",
"c",
":",
"param",
":",
"weights",
"feature",
"vector",
"the",
"term",
"w",
"in",
"X",
"w",
"+",
"c",
":",
"param",
":",
"xMean",
"Point",
"around",
"which",... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L471-L490 | [
"def",
"generateLinearInput",
"(",
"intercept",
",",
"weights",
",",
"xMean",
",",
"xVariance",
",",
"nPoints",
",",
"seed",
",",
"eps",
")",
":",
"weights",
"=",
"[",
"float",
"(",
"weight",
")",
"for",
"weight",
"in",
"weights",
"]",
"xMean",
"=",
"[... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | LinearDataGenerator.generateLinearRDD | Generate an RDD of LabeledPoints. | python/pyspark/mllib/util.py | def generateLinearRDD(sc, nexamples, nfeatures, eps,
nParts=2, intercept=0.0):
"""
Generate an RDD of LabeledPoints.
"""
return callMLlibFunc(
"generateLinearRDDWrapper", sc, int(nexamples), int(nfeatures),
float(eps), int(nParts), float(... | def generateLinearRDD(sc, nexamples, nfeatures, eps,
nParts=2, intercept=0.0):
"""
Generate an RDD of LabeledPoints.
"""
return callMLlibFunc(
"generateLinearRDDWrapper", sc, int(nexamples), int(nfeatures),
float(eps), int(nParts), float(... | [
"Generate",
"an",
"RDD",
"of",
"LabeledPoints",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L494-L501 | [
"def",
"generateLinearRDD",
"(",
"sc",
",",
"nexamples",
",",
"nfeatures",
",",
"eps",
",",
"nParts",
"=",
"2",
",",
"intercept",
"=",
"0.0",
")",
":",
"return",
"callMLlibFunc",
"(",
"\"generateLinearRDDWrapper\"",
",",
"sc",
",",
"int",
"(",
"nexamples",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | LinearRegressionWithSGD.train | Train a linear regression model using Stochastic Gradient
Descent (SGD). This solves the least squares regression
formulation
f(weights) = 1/(2n) ||A weights - y||^2
which is the mean squared error. Here the data matrix has n rows,
and the input RDD holds the set of rows of... | python/pyspark/mllib/regression.py | def train(cls, data, iterations=100, step=1.0, miniBatchFraction=1.0,
initialWeights=None, regParam=0.0, regType=None, intercept=False,
validateData=True, convergenceTol=0.001):
"""
Train a linear regression model using Stochastic Gradient
Descent (SGD). This solves t... | def train(cls, data, iterations=100, step=1.0, miniBatchFraction=1.0,
initialWeights=None, regParam=0.0, regType=None, intercept=False,
validateData=True, convergenceTol=0.001):
"""
Train a linear regression model using Stochastic Gradient
Descent (SGD). This solves t... | [
"Train",
"a",
"linear",
"regression",
"model",
"using",
"Stochastic",
"Gradient",
"Descent",
"(",
"SGD",
")",
".",
"This",
"solves",
"the",
"least",
"squares",
"regression",
"formulation"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/regression.py#L230-L291 | [
"def",
"train",
"(",
"cls",
",",
"data",
",",
"iterations",
"=",
"100",
",",
"step",
"=",
"1.0",
",",
"miniBatchFraction",
"=",
"1.0",
",",
"initialWeights",
"=",
"None",
",",
"regParam",
"=",
"0.0",
",",
"regType",
"=",
"None",
",",
"intercept",
"=",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | IsotonicRegressionModel.predict | Predict labels for provided features.
Using a piecewise linear function.
1) If x exactly matches a boundary then associated prediction
is returned. In case there are multiple predictions with the
same boundary then one of them is returned. Which one is
undefined (same as java.uti... | python/pyspark/mllib/regression.py | def predict(self, x):
"""
Predict labels for provided features.
Using a piecewise linear function.
1) If x exactly matches a boundary then associated prediction
is returned. In case there are multiple predictions with the
same boundary then one of them is returned. Which ... | def predict(self, x):
"""
Predict labels for provided features.
Using a piecewise linear function.
1) If x exactly matches a boundary then associated prediction
is returned. In case there are multiple predictions with the
same boundary then one of them is returned. Which ... | [
"Predict",
"labels",
"for",
"provided",
"features",
".",
"Using",
"a",
"piecewise",
"linear",
"function",
".",
"1",
")",
"If",
"x",
"exactly",
"matches",
"a",
"boundary",
"then",
"associated",
"prediction",
"is",
"returned",
".",
"In",
"case",
"there",
"are"... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/regression.py#L628-L651 | [
"def",
"predict",
"(",
"self",
",",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"RDD",
")",
":",
"return",
"x",
".",
"map",
"(",
"lambda",
"v",
":",
"self",
".",
"predict",
"(",
"v",
")",
")",
"return",
"np",
".",
"interp",
"(",
"x",
",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | IsotonicRegressionModel.save | Save an IsotonicRegressionModel. | python/pyspark/mllib/regression.py | def save(self, sc, path):
"""Save an IsotonicRegressionModel."""
java_boundaries = _py2java(sc, self.boundaries.tolist())
java_predictions = _py2java(sc, self.predictions.tolist())
java_model = sc._jvm.org.apache.spark.mllib.regression.IsotonicRegressionModel(
java_boundaries... | def save(self, sc, path):
"""Save an IsotonicRegressionModel."""
java_boundaries = _py2java(sc, self.boundaries.tolist())
java_predictions = _py2java(sc, self.predictions.tolist())
java_model = sc._jvm.org.apache.spark.mllib.regression.IsotonicRegressionModel(
java_boundaries... | [
"Save",
"an",
"IsotonicRegressionModel",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/regression.py#L654-L660 | [
"def",
"save",
"(",
"self",
",",
"sc",
",",
"path",
")",
":",
"java_boundaries",
"=",
"_py2java",
"(",
"sc",
",",
"self",
".",
"boundaries",
".",
"tolist",
"(",
")",
")",
"java_predictions",
"=",
"_py2java",
"(",
"sc",
",",
"self",
".",
"predictions",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | IsotonicRegressionModel.load | Load an IsotonicRegressionModel. | python/pyspark/mllib/regression.py | def load(cls, sc, path):
"""Load an IsotonicRegressionModel."""
java_model = sc._jvm.org.apache.spark.mllib.regression.IsotonicRegressionModel.load(
sc._jsc.sc(), path)
py_boundaries = _java2py(sc, java_model.boundaryVector()).toArray()
py_predictions = _java2py(sc, java_mode... | def load(cls, sc, path):
"""Load an IsotonicRegressionModel."""
java_model = sc._jvm.org.apache.spark.mllib.regression.IsotonicRegressionModel.load(
sc._jsc.sc(), path)
py_boundaries = _java2py(sc, java_model.boundaryVector()).toArray()
py_predictions = _java2py(sc, java_mode... | [
"Load",
"an",
"IsotonicRegressionModel",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/regression.py#L664-L670 | [
"def",
"load",
"(",
"cls",
",",
"sc",
",",
"path",
")",
":",
"java_model",
"=",
"sc",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"mllib",
".",
"regression",
".",
"IsotonicRegressionModel",
".",
"load",
"(",
"sc",
".",
"_jsc",
".",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | IsotonicRegression.train | Train an isotonic regression model on the given data.
:param data:
RDD of (label, feature, weight) tuples.
:param isotonic:
Whether this is isotonic (which is default) or antitonic.
(default: True) | python/pyspark/mllib/regression.py | def train(cls, data, isotonic=True):
"""
Train an isotonic regression model on the given data.
:param data:
RDD of (label, feature, weight) tuples.
:param isotonic:
Whether this is isotonic (which is default) or antitonic.
(default: True)
"""
... | def train(cls, data, isotonic=True):
"""
Train an isotonic regression model on the given data.
:param data:
RDD of (label, feature, weight) tuples.
:param isotonic:
Whether this is isotonic (which is default) or antitonic.
(default: True)
"""
... | [
"Train",
"an",
"isotonic",
"regression",
"model",
"on",
"the",
"given",
"data",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/regression.py#L699-L711 | [
"def",
"train",
"(",
"cls",
",",
"data",
",",
"isotonic",
"=",
"True",
")",
":",
"boundaries",
",",
"predictions",
"=",
"callMLlibFunc",
"(",
"\"trainIsotonicRegressionModel\"",
",",
"data",
".",
"map",
"(",
"_convert_to_vector",
")",
",",
"bool",
"(",
"isot... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | RowMatrix.columnSimilarities | Compute similarities between columns of this matrix.
The threshold parameter is a trade-off knob between estimate
quality and computational cost.
The default threshold setting of 0 guarantees deterministically
correct results, but uses the brute-force approach of computing
norm... | python/pyspark/mllib/linalg/distributed.py | def columnSimilarities(self, threshold=0.0):
"""
Compute similarities between columns of this matrix.
The threshold parameter is a trade-off knob between estimate
quality and computational cost.
The default threshold setting of 0 guarantees deterministically
correct res... | def columnSimilarities(self, threshold=0.0):
"""
Compute similarities between columns of this matrix.
The threshold parameter is a trade-off knob between estimate
quality and computational cost.
The default threshold setting of 0 guarantees deterministically
correct res... | [
"Compute",
"similarities",
"between",
"columns",
"of",
"this",
"matrix",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L201-L260 | [
"def",
"columnSimilarities",
"(",
"self",
",",
"threshold",
"=",
"0.0",
")",
":",
"java_sims_mat",
"=",
"self",
".",
"_java_matrix_wrapper",
".",
"call",
"(",
"\"columnSimilarities\"",
",",
"float",
"(",
"threshold",
")",
")",
"return",
"CoordinateMatrix",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | RowMatrix.tallSkinnyQR | Compute the QR decomposition of this RowMatrix.
The implementation is designed to optimize the QR decomposition
(factorization) for the RowMatrix of a tall and skinny shape.
Reference:
Paul G. Constantine, David F. Gleich. "Tall and skinny QR
factorizations in MapReduce archi... | python/pyspark/mllib/linalg/distributed.py | def tallSkinnyQR(self, computeQ=False):
"""
Compute the QR decomposition of this RowMatrix.
The implementation is designed to optimize the QR decomposition
(factorization) for the RowMatrix of a tall and skinny shape.
Reference:
Paul G. Constantine, David F. Gleich. "T... | def tallSkinnyQR(self, computeQ=False):
"""
Compute the QR decomposition of this RowMatrix.
The implementation is designed to optimize the QR decomposition
(factorization) for the RowMatrix of a tall and skinny shape.
Reference:
Paul G. Constantine, David F. Gleich. "T... | [
"Compute",
"the",
"QR",
"decomposition",
"of",
"this",
"RowMatrix",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L263-L301 | [
"def",
"tallSkinnyQR",
"(",
"self",
",",
"computeQ",
"=",
"False",
")",
":",
"decomp",
"=",
"JavaModelWrapper",
"(",
"self",
".",
"_java_matrix_wrapper",
".",
"call",
"(",
"\"tallSkinnyQR\"",
",",
"computeQ",
")",
")",
"if",
"computeQ",
":",
"java_Q",
"=",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | RowMatrix.computeSVD | Computes the singular value decomposition of the RowMatrix.
The given row matrix A of dimension (m X n) is decomposed into
U * s * V'T where
* U: (m X k) (left singular vectors) is a RowMatrix whose
columns are the eigenvectors of (A X A')
* s: DenseVector consisting of sq... | python/pyspark/mllib/linalg/distributed.py | def computeSVD(self, k, computeU=False, rCond=1e-9):
"""
Computes the singular value decomposition of the RowMatrix.
The given row matrix A of dimension (m X n) is decomposed into
U * s * V'T where
* U: (m X k) (left singular vectors) is a RowMatrix whose
columns a... | def computeSVD(self, k, computeU=False, rCond=1e-9):
"""
Computes the singular value decomposition of the RowMatrix.
The given row matrix A of dimension (m X n) is decomposed into
U * s * V'T where
* U: (m X k) (left singular vectors) is a RowMatrix whose
columns a... | [
"Computes",
"the",
"singular",
"value",
"decomposition",
"of",
"the",
"RowMatrix",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L304-L345 | [
"def",
"computeSVD",
"(",
"self",
",",
"k",
",",
"computeU",
"=",
"False",
",",
"rCond",
"=",
"1e-9",
")",
":",
"j_model",
"=",
"self",
".",
"_java_matrix_wrapper",
".",
"call",
"(",
"\"computeSVD\"",
",",
"int",
"(",
"k",
")",
",",
"bool",
"(",
"com... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | RowMatrix.multiply | Multiply this matrix by a local dense matrix on the right.
:param matrix: a local dense matrix whose number of rows must match the number of columns
of this matrix
:returns: :py:class:`RowMatrix`
>>> rm = RowMatrix(sc.parallelize([[0, 1], [2, 3]]))
>>> rm.multipl... | python/pyspark/mllib/linalg/distributed.py | def multiply(self, matrix):
"""
Multiply this matrix by a local dense matrix on the right.
:param matrix: a local dense matrix whose number of rows must match the number of columns
of this matrix
:returns: :py:class:`RowMatrix`
>>> rm = RowMatrix(sc.paral... | def multiply(self, matrix):
"""
Multiply this matrix by a local dense matrix on the right.
:param matrix: a local dense matrix whose number of rows must match the number of columns
of this matrix
:returns: :py:class:`RowMatrix`
>>> rm = RowMatrix(sc.paral... | [
"Multiply",
"this",
"matrix",
"by",
"a",
"local",
"dense",
"matrix",
"on",
"the",
"right",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L373-L389 | [
"def",
"multiply",
"(",
"self",
",",
"matrix",
")",
":",
"if",
"not",
"isinstance",
"(",
"matrix",
",",
"DenseMatrix",
")",
":",
"raise",
"ValueError",
"(",
"\"Only multiplication with DenseMatrix \"",
"\"is supported.\"",
")",
"j_model",
"=",
"self",
".",
"_jav... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SingularValueDecomposition.U | Returns a distributed matrix whose columns are the left
singular vectors of the SingularValueDecomposition if computeU was set to be True. | python/pyspark/mllib/linalg/distributed.py | def U(self):
"""
Returns a distributed matrix whose columns are the left
singular vectors of the SingularValueDecomposition if computeU was set to be True.
"""
u = self.call("U")
if u is not None:
mat_name = u.getClass().getSimpleName()
if mat_name... | def U(self):
"""
Returns a distributed matrix whose columns are the left
singular vectors of the SingularValueDecomposition if computeU was set to be True.
"""
u = self.call("U")
if u is not None:
mat_name = u.getClass().getSimpleName()
if mat_name... | [
"Returns",
"a",
"distributed",
"matrix",
"whose",
"columns",
"are",
"the",
"left",
"singular",
"vectors",
"of",
"the",
"SingularValueDecomposition",
"if",
"computeU",
"was",
"set",
"to",
"be",
"True",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L401-L414 | [
"def",
"U",
"(",
"self",
")",
":",
"u",
"=",
"self",
".",
"call",
"(",
"\"U\"",
")",
"if",
"u",
"is",
"not",
"None",
":",
"mat_name",
"=",
"u",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"if",
"mat_name",
"==",
"\"RowMatrix\"",
":... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | IndexedRowMatrix.rows | Rows of the IndexedRowMatrix stored as an RDD of IndexedRows.
>>> mat = IndexedRowMatrix(sc.parallelize([IndexedRow(0, [1, 2, 3]),
... IndexedRow(1, [4, 5, 6])]))
>>> rows = mat.rows
>>> rows.first()
IndexedRow(0, [1.0,2.0,3.0]) | python/pyspark/mllib/linalg/distributed.py | def rows(self):
"""
Rows of the IndexedRowMatrix stored as an RDD of IndexedRows.
>>> mat = IndexedRowMatrix(sc.parallelize([IndexedRow(0, [1, 2, 3]),
... IndexedRow(1, [4, 5, 6])]))
>>> rows = mat.rows
>>> rows.first()
Inde... | def rows(self):
"""
Rows of the IndexedRowMatrix stored as an RDD of IndexedRows.
>>> mat = IndexedRowMatrix(sc.parallelize([IndexedRow(0, [1, 2, 3]),
... IndexedRow(1, [4, 5, 6])]))
>>> rows = mat.rows
>>> rows.first()
Inde... | [
"Rows",
"of",
"the",
"IndexedRowMatrix",
"stored",
"as",
"an",
"RDD",
"of",
"IndexedRows",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L519-L535 | [
"def",
"rows",
"(",
"self",
")",
":",
"# We use DataFrames for serialization of IndexedRows from",
"# Java, so we first convert the RDD of rows to a DataFrame",
"# on the Scala/Java side. Then we map each Row in the",
"# DataFrame back to an IndexedRow on this side.",
"rows_df",
"=",
"callML... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | IndexedRowMatrix.toBlockMatrix | Convert this matrix to a BlockMatrix.
:param rowsPerBlock: Number of rows that make up each block.
The blocks forming the final rows are not
required to have the given number of rows.
:param colsPerBlock: Number of columns that make up each bloc... | python/pyspark/mllib/linalg/distributed.py | def toBlockMatrix(self, rowsPerBlock=1024, colsPerBlock=1024):
"""
Convert this matrix to a BlockMatrix.
:param rowsPerBlock: Number of rows that make up each block.
The blocks forming the final rows are not
required to have the given nu... | def toBlockMatrix(self, rowsPerBlock=1024, colsPerBlock=1024):
"""
Convert this matrix to a BlockMatrix.
:param rowsPerBlock: Number of rows that make up each block.
The blocks forming the final rows are not
required to have the given nu... | [
"Convert",
"this",
"matrix",
"to",
"a",
"BlockMatrix",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L631-L658 | [
"def",
"toBlockMatrix",
"(",
"self",
",",
"rowsPerBlock",
"=",
"1024",
",",
"colsPerBlock",
"=",
"1024",
")",
":",
"java_block_matrix",
"=",
"self",
".",
"_java_matrix_wrapper",
".",
"call",
"(",
"\"toBlockMatrix\"",
",",
"rowsPerBlock",
",",
"colsPerBlock",
")"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | IndexedRowMatrix.multiply | Multiply this matrix by a local dense matrix on the right.
:param matrix: a local dense matrix whose number of rows must match the number of columns
of this matrix
:returns: :py:class:`IndexedRowMatrix`
>>> mat = IndexedRowMatrix(sc.parallelize([(0, (0, 1)), (1, (2, 3))]... | python/pyspark/mllib/linalg/distributed.py | def multiply(self, matrix):
"""
Multiply this matrix by a local dense matrix on the right.
:param matrix: a local dense matrix whose number of rows must match the number of columns
of this matrix
:returns: :py:class:`IndexedRowMatrix`
>>> mat = IndexedRow... | def multiply(self, matrix):
"""
Multiply this matrix by a local dense matrix on the right.
:param matrix: a local dense matrix whose number of rows must match the number of columns
of this matrix
:returns: :py:class:`IndexedRowMatrix`
>>> mat = IndexedRow... | [
"Multiply",
"this",
"matrix",
"by",
"a",
"local",
"dense",
"matrix",
"on",
"the",
"right",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L705-L720 | [
"def",
"multiply",
"(",
"self",
",",
"matrix",
")",
":",
"if",
"not",
"isinstance",
"(",
"matrix",
",",
"DenseMatrix",
")",
":",
"raise",
"ValueError",
"(",
"\"Only multiplication with DenseMatrix \"",
"\"is supported.\"",
")",
"return",
"IndexedRowMatrix",
"(",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | CoordinateMatrix.entries | Entries of the CoordinateMatrix stored as an RDD of
MatrixEntries.
>>> mat = CoordinateMatrix(sc.parallelize([MatrixEntry(0, 0, 1.2),
... MatrixEntry(6, 4, 2.1)]))
>>> entries = mat.entries
>>> entries.first()
MatrixEntry(0, 0, 1.2) | python/pyspark/mllib/linalg/distributed.py | def entries(self):
"""
Entries of the CoordinateMatrix stored as an RDD of
MatrixEntries.
>>> mat = CoordinateMatrix(sc.parallelize([MatrixEntry(0, 0, 1.2),
... MatrixEntry(6, 4, 2.1)]))
>>> entries = mat.entries
>>> entries... | def entries(self):
"""
Entries of the CoordinateMatrix stored as an RDD of
MatrixEntries.
>>> mat = CoordinateMatrix(sc.parallelize([MatrixEntry(0, 0, 1.2),
... MatrixEntry(6, 4, 2.1)]))
>>> entries = mat.entries
>>> entries... | [
"Entries",
"of",
"the",
"CoordinateMatrix",
"stored",
"as",
"an",
"RDD",
"of",
"MatrixEntries",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L811-L828 | [
"def",
"entries",
"(",
"self",
")",
":",
"# We use DataFrames for serialization of MatrixEntry entries",
"# from Java, so we first convert the RDD of entries to a",
"# DataFrame on the Scala/Java side. Then we map each Row in",
"# the DataFrame back to a MatrixEntry on this side.",
"entries_df",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | BlockMatrix.blocks | The RDD of sub-matrix blocks
((blockRowIndex, blockColIndex), sub-matrix) that form this
distributed matrix.
>>> mat = BlockMatrix(
... sc.parallelize([((0, 0), Matrices.dense(3, 2, [1, 2, 3, 4, 5, 6])),
... ((1, 0), Matrices.dense(3, 2, [7, 8, 9, 10, 11,... | python/pyspark/mllib/linalg/distributed.py | def blocks(self):
"""
The RDD of sub-matrix blocks
((blockRowIndex, blockColIndex), sub-matrix) that form this
distributed matrix.
>>> mat = BlockMatrix(
... sc.parallelize([((0, 0), Matrices.dense(3, 2, [1, 2, 3, 4, 5, 6])),
... ((1, 0), ... | def blocks(self):
"""
The RDD of sub-matrix blocks
((blockRowIndex, blockColIndex), sub-matrix) that form this
distributed matrix.
>>> mat = BlockMatrix(
... sc.parallelize([((0, 0), Matrices.dense(3, 2, [1, 2, 3, 4, 5, 6])),
... ((1, 0), ... | [
"The",
"RDD",
"of",
"sub",
"-",
"matrix",
"blocks",
"((",
"blockRowIndex",
"blockColIndex",
")",
"sub",
"-",
"matrix",
")",
"that",
"form",
"this",
"distributed",
"matrix",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L1051-L1071 | [
"def",
"blocks",
"(",
"self",
")",
":",
"# We use DataFrames for serialization of sub-matrix blocks",
"# from Java, so we first convert the RDD of blocks to a",
"# DataFrame on the Scala/Java side. Then we map each Row in",
"# the DataFrame back to a sub-matrix block on this side.",
"blocks_df",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | BlockMatrix.persist | Persists the underlying RDD with the specified storage level. | python/pyspark/mllib/linalg/distributed.py | def persist(self, storageLevel):
"""
Persists the underlying RDD with the specified storage level.
"""
if not isinstance(storageLevel, StorageLevel):
raise TypeError("`storageLevel` should be a StorageLevel, got %s" % type(storageLevel))
javaStorageLevel = self._java_... | def persist(self, storageLevel):
"""
Persists the underlying RDD with the specified storage level.
"""
if not isinstance(storageLevel, StorageLevel):
raise TypeError("`storageLevel` should be a StorageLevel, got %s" % type(storageLevel))
javaStorageLevel = self._java_... | [
"Persists",
"the",
"underlying",
"RDD",
"with",
"the",
"specified",
"storage",
"level",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L1168-L1176 | [
"def",
"persist",
"(",
"self",
",",
"storageLevel",
")",
":",
"if",
"not",
"isinstance",
"(",
"storageLevel",
",",
"StorageLevel",
")",
":",
"raise",
"TypeError",
"(",
"\"`storageLevel` should be a StorageLevel, got %s\"",
"%",
"type",
"(",
"storageLevel",
")",
")... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | BlockMatrix.add | Adds two block matrices together. The matrices must have the
same size and matching `rowsPerBlock` and `colsPerBlock` values.
If one of the sub matrix blocks that are being added is a
SparseMatrix, the resulting sub matrix block will also be a
SparseMatrix, even if it is being added to a... | python/pyspark/mllib/linalg/distributed.py | def add(self, other):
"""
Adds two block matrices together. The matrices must have the
same size and matching `rowsPerBlock` and `colsPerBlock` values.
If one of the sub matrix blocks that are being added is a
SparseMatrix, the resulting sub matrix block will also be a
Sp... | def add(self, other):
"""
Adds two block matrices together. The matrices must have the
same size and matching `rowsPerBlock` and `colsPerBlock` values.
If one of the sub matrix blocks that are being added is a
SparseMatrix, the resulting sub matrix block will also be a
Sp... | [
"Adds",
"two",
"block",
"matrices",
"together",
".",
"The",
"matrices",
"must",
"have",
"the",
"same",
"size",
"and",
"matching",
"rowsPerBlock",
"and",
"colsPerBlock",
"values",
".",
"If",
"one",
"of",
"the",
"sub",
"matrix",
"blocks",
"that",
"are",
"being... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L1186-L1217 | [
"def",
"add",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"BlockMatrix",
")",
":",
"raise",
"TypeError",
"(",
"\"Other should be a BlockMatrix, got %s\"",
"%",
"type",
"(",
"other",
")",
")",
"other_java_block_matrix",
"=... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | BlockMatrix.transpose | Transpose this BlockMatrix. Returns a new BlockMatrix
instance sharing the same underlying data. Is a lazy operation.
>>> blocks = sc.parallelize([((0, 0), Matrices.dense(3, 2, [1, 2, 3, 4, 5, 6])),
... ((1, 0), Matrices.dense(3, 2, [7, 8, 9, 10, 11, 12]))])
>>>... | python/pyspark/mllib/linalg/distributed.py | def transpose(self):
"""
Transpose this BlockMatrix. Returns a new BlockMatrix
instance sharing the same underlying data. Is a lazy operation.
>>> blocks = sc.parallelize([((0, 0), Matrices.dense(3, 2, [1, 2, 3, 4, 5, 6])),
... ((1, 0), Matrices.dense(3,... | def transpose(self):
"""
Transpose this BlockMatrix. Returns a new BlockMatrix
instance sharing the same underlying data. Is a lazy operation.
>>> blocks = sc.parallelize([((0, 0), Matrices.dense(3, 2, [1, 2, 3, 4, 5, 6])),
... ((1, 0), Matrices.dense(3,... | [
"Transpose",
"this",
"BlockMatrix",
".",
"Returns",
"a",
"new",
"BlockMatrix",
"instance",
"sharing",
"the",
"same",
"underlying",
"data",
".",
"Is",
"a",
"lazy",
"operation",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L1290-L1304 | [
"def",
"transpose",
"(",
"self",
")",
":",
"java_transposed_matrix",
"=",
"self",
".",
"_java_matrix_wrapper",
".",
"call",
"(",
"\"transpose\"",
")",
"return",
"BlockMatrix",
"(",
"java_transposed_matrix",
",",
"self",
".",
"colsPerBlock",
",",
"self",
".",
"ro... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _vector_size | Returns the size of the vector.
>>> _vector_size([1., 2., 3.])
3
>>> _vector_size((1., 2., 3.))
3
>>> _vector_size(array.array('d', [1., 2., 3.]))
3
>>> _vector_size(np.zeros(3))
3
>>> _vector_size(np.zeros((3, 1)))
3
>>> _vector_size(np.zeros((1, 3)))
Traceback (most re... | python/pyspark/mllib/linalg/__init__.py | def _vector_size(v):
"""
Returns the size of the vector.
>>> _vector_size([1., 2., 3.])
3
>>> _vector_size((1., 2., 3.))
3
>>> _vector_size(array.array('d', [1., 2., 3.]))
3
>>> _vector_size(np.zeros(3))
3
>>> _vector_size(np.zeros((3, 1)))
3
>>> _vector_size(np.zero... | def _vector_size(v):
"""
Returns the size of the vector.
>>> _vector_size([1., 2., 3.])
3
>>> _vector_size((1., 2., 3.))
3
>>> _vector_size(array.array('d', [1., 2., 3.]))
3
>>> _vector_size(np.zeros(3))
3
>>> _vector_size(np.zeros((3, 1)))
3
>>> _vector_size(np.zero... | [
"Returns",
"the",
"size",
"of",
"the",
"vector",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L86-L118 | [
"def",
"_vector_size",
"(",
"v",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"Vector",
")",
":",
"return",
"len",
"(",
"v",
")",
"elif",
"type",
"(",
"v",
")",
"in",
"(",
"array",
".",
"array",
",",
"list",
",",
"tuple",
",",
"xrange",
")",
":... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DenseVector.parse | Parse string representation back into the DenseVector.
>>> DenseVector.parse(' [ 0.0,1.0,2.0, 3.0]')
DenseVector([0.0, 1.0, 2.0, 3.0]) | python/pyspark/mllib/linalg/__init__.py | def parse(s):
"""
Parse string representation back into the DenseVector.
>>> DenseVector.parse(' [ 0.0,1.0,2.0, 3.0]')
DenseVector([0.0, 1.0, 2.0, 3.0])
"""
start = s.find('[')
if start == -1:
raise ValueError("Array should start with '['.")
... | def parse(s):
"""
Parse string representation back into the DenseVector.
>>> DenseVector.parse(' [ 0.0,1.0,2.0, 3.0]')
DenseVector([0.0, 1.0, 2.0, 3.0])
"""
start = s.find('[')
if start == -1:
raise ValueError("Array should start with '['.")
... | [
"Parse",
"string",
"representation",
"back",
"into",
"the",
"DenseVector",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L297-L316 | [
"def",
"parse",
"(",
"s",
")",
":",
"start",
"=",
"s",
".",
"find",
"(",
"'['",
")",
"if",
"start",
"==",
"-",
"1",
":",
"raise",
"ValueError",
"(",
"\"Array should start with '['.\"",
")",
"end",
"=",
"s",
".",
"find",
"(",
"']'",
")",
"if",
"end"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DenseVector.dot | Compute the dot product of two Vectors. We support
(Numpy array, list, SparseVector, or SciPy sparse)
and a target NumPy array that is either 1- or 2-dimensional.
Equivalent to calling numpy.dot of the two vectors.
>>> dense = DenseVector(array.array('d', [1., 2.]))
>>> dense.do... | python/pyspark/mllib/linalg/__init__.py | def dot(self, other):
"""
Compute the dot product of two Vectors. We support
(Numpy array, list, SparseVector, or SciPy sparse)
and a target NumPy array that is either 1- or 2-dimensional.
Equivalent to calling numpy.dot of the two vectors.
>>> dense = DenseVector(array.... | def dot(self, other):
"""
Compute the dot product of two Vectors. We support
(Numpy array, list, SparseVector, or SciPy sparse)
and a target NumPy array that is either 1- or 2-dimensional.
Equivalent to calling numpy.dot of the two vectors.
>>> dense = DenseVector(array.... | [
"Compute",
"the",
"dot",
"product",
"of",
"two",
"Vectors",
".",
"We",
"support",
"(",
"Numpy",
"array",
"list",
"SparseVector",
"or",
"SciPy",
"sparse",
")",
"and",
"a",
"target",
"NumPy",
"array",
"that",
"is",
"either",
"1",
"-",
"or",
"2",
"-",
"di... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L339-L380 | [
"def",
"dot",
"(",
"self",
",",
"other",
")",
":",
"if",
"type",
"(",
"other",
")",
"==",
"np",
".",
"ndarray",
":",
"if",
"other",
".",
"ndim",
">",
"1",
":",
"assert",
"len",
"(",
"self",
")",
"==",
"other",
".",
"shape",
"[",
"0",
"]",
","... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DenseVector.squared_distance | Squared distance of two Vectors.
>>> dense1 = DenseVector(array.array('d', [1., 2.]))
>>> dense1.squared_distance(dense1)
0.0
>>> dense2 = np.array([2., 1.])
>>> dense1.squared_distance(dense2)
2.0
>>> dense3 = [2., 1.]
>>> dense1.squared_distance(dense3)... | python/pyspark/mllib/linalg/__init__.py | def squared_distance(self, other):
"""
Squared distance of two Vectors.
>>> dense1 = DenseVector(array.array('d', [1., 2.]))
>>> dense1.squared_distance(dense1)
0.0
>>> dense2 = np.array([2., 1.])
>>> dense1.squared_distance(dense2)
2.0
>>> dense3... | def squared_distance(self, other):
"""
Squared distance of two Vectors.
>>> dense1 = DenseVector(array.array('d', [1., 2.]))
>>> dense1.squared_distance(dense1)
0.0
>>> dense2 = np.array([2., 1.])
>>> dense1.squared_distance(dense2)
2.0
>>> dense3... | [
"Squared",
"distance",
"of",
"two",
"Vectors",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L382-L418 | [
"def",
"squared_distance",
"(",
"self",
",",
"other",
")",
":",
"assert",
"len",
"(",
"self",
")",
"==",
"_vector_size",
"(",
"other",
")",
",",
"\"dimension mismatch\"",
"if",
"isinstance",
"(",
"other",
",",
"SparseVector",
")",
":",
"return",
"other",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparseVector.parse | Parse string representation back into the SparseVector.
>>> SparseVector.parse(' (4, [0,1 ],[ 4.0,5.0] )')
SparseVector(4, {0: 4.0, 1: 5.0}) | python/pyspark/mllib/linalg/__init__.py | def parse(s):
"""
Parse string representation back into the SparseVector.
>>> SparseVector.parse(' (4, [0,1 ],[ 4.0,5.0] )')
SparseVector(4, {0: 4.0, 1: 5.0})
"""
start = s.find('(')
if start == -1:
raise ValueError("Tuple should start with '('")
... | def parse(s):
"""
Parse string representation back into the SparseVector.
>>> SparseVector.parse(' (4, [0,1 ],[ 4.0,5.0] )')
SparseVector(4, {0: 4.0, 1: 5.0})
"""
start = s.find('(')
if start == -1:
raise ValueError("Tuple should start with '('")
... | [
"Parse",
"string",
"representation",
"back",
"into",
"the",
"SparseVector",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L589-L635 | [
"def",
"parse",
"(",
"s",
")",
":",
"start",
"=",
"s",
".",
"find",
"(",
"'('",
")",
"if",
"start",
"==",
"-",
"1",
":",
"raise",
"ValueError",
"(",
"\"Tuple should start with '('\"",
")",
"end",
"=",
"s",
".",
"find",
"(",
"')'",
")",
"if",
"end",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparseVector.dot | Dot product with a SparseVector or 1- or 2-dimensional Numpy array.
>>> a = SparseVector(4, [1, 3], [3.0, 4.0])
>>> a.dot(a)
25.0
>>> a.dot(array.array('d', [1., 2., 3., 4.]))
22.0
>>> b = SparseVector(4, [2], [1.0])
>>> a.dot(b)
0.0
>>> a.dot(np.... | python/pyspark/mllib/linalg/__init__.py | def dot(self, other):
"""
Dot product with a SparseVector or 1- or 2-dimensional Numpy array.
>>> a = SparseVector(4, [1, 3], [3.0, 4.0])
>>> a.dot(a)
25.0
>>> a.dot(array.array('d', [1., 2., 3., 4.]))
22.0
>>> b = SparseVector(4, [2], [1.0])
>>> ... | def dot(self, other):
"""
Dot product with a SparseVector or 1- or 2-dimensional Numpy array.
>>> a = SparseVector(4, [1, 3], [3.0, 4.0])
>>> a.dot(a)
25.0
>>> a.dot(array.array('d', [1., 2., 3., 4.]))
22.0
>>> b = SparseVector(4, [2], [1.0])
>>> ... | [
"Dot",
"product",
"with",
"a",
"SparseVector",
"or",
"1",
"-",
"or",
"2",
"-",
"dimensional",
"Numpy",
"array",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L637-L691 | [
"def",
"dot",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"np",
".",
"ndarray",
")",
":",
"if",
"other",
".",
"ndim",
"not",
"in",
"[",
"2",
",",
"1",
"]",
":",
"raise",
"ValueError",
"(",
"\"Cannot call dot with %d-di... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparseVector.squared_distance | Squared distance from a SparseVector or 1-dimensional NumPy array.
>>> a = SparseVector(4, [1, 3], [3.0, 4.0])
>>> a.squared_distance(a)
0.0
>>> a.squared_distance(array.array('d', [1., 2., 3., 4.]))
11.0
>>> a.squared_distance(np.array([1., 2., 3., 4.]))
11.0
... | python/pyspark/mllib/linalg/__init__.py | def squared_distance(self, other):
"""
Squared distance from a SparseVector or 1-dimensional NumPy array.
>>> a = SparseVector(4, [1, 3], [3.0, 4.0])
>>> a.squared_distance(a)
0.0
>>> a.squared_distance(array.array('d', [1., 2., 3., 4.]))
11.0
>>> a.squar... | def squared_distance(self, other):
"""
Squared distance from a SparseVector or 1-dimensional NumPy array.
>>> a = SparseVector(4, [1, 3], [3.0, 4.0])
>>> a.squared_distance(a)
0.0
>>> a.squared_distance(array.array('d', [1., 2., 3., 4.]))
11.0
>>> a.squar... | [
"Squared",
"distance",
"from",
"a",
"SparseVector",
"or",
"1",
"-",
"dimensional",
"NumPy",
"array",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L693-L758 | [
"def",
"squared_distance",
"(",
"self",
",",
"other",
")",
":",
"assert",
"len",
"(",
"self",
")",
"==",
"_vector_size",
"(",
"other",
")",
",",
"\"dimension mismatch\"",
"if",
"isinstance",
"(",
"other",
",",
"np",
".",
"ndarray",
")",
"or",
"isinstance",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparseVector.toArray | Returns a copy of this SparseVector as a 1-dimensional NumPy array. | python/pyspark/mllib/linalg/__init__.py | def toArray(self):
"""
Returns a copy of this SparseVector as a 1-dimensional NumPy array.
"""
arr = np.zeros((self.size,), dtype=np.float64)
arr[self.indices] = self.values
return arr | def toArray(self):
"""
Returns a copy of this SparseVector as a 1-dimensional NumPy array.
"""
arr = np.zeros((self.size,), dtype=np.float64)
arr[self.indices] = self.values
return arr | [
"Returns",
"a",
"copy",
"of",
"this",
"SparseVector",
"as",
"a",
"1",
"-",
"dimensional",
"NumPy",
"array",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L760-L766 | [
"def",
"toArray",
"(",
"self",
")",
":",
"arr",
"=",
"np",
".",
"zeros",
"(",
"(",
"self",
".",
"size",
",",
")",
",",
"dtype",
"=",
"np",
".",
"float64",
")",
"arr",
"[",
"self",
".",
"indices",
"]",
"=",
"self",
".",
"values",
"return",
"arr"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparseVector.asML | Convert this vector to the new mllib-local representation.
This does NOT copy the data; it copies references.
:return: :py:class:`pyspark.ml.linalg.SparseVector`
.. versionadded:: 2.0.0 | python/pyspark/mllib/linalg/__init__.py | def asML(self):
"""
Convert this vector to the new mllib-local representation.
This does NOT copy the data; it copies references.
:return: :py:class:`pyspark.ml.linalg.SparseVector`
.. versionadded:: 2.0.0
"""
return newlinalg.SparseVector(self.size, self.indice... | def asML(self):
"""
Convert this vector to the new mllib-local representation.
This does NOT copy the data; it copies references.
:return: :py:class:`pyspark.ml.linalg.SparseVector`
.. versionadded:: 2.0.0
"""
return newlinalg.SparseVector(self.size, self.indice... | [
"Convert",
"this",
"vector",
"to",
"the",
"new",
"mllib",
"-",
"local",
"representation",
".",
"This",
"does",
"NOT",
"copy",
"the",
"data",
";",
"it",
"copies",
"references",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L768-L777 | [
"def",
"asML",
"(",
"self",
")",
":",
"return",
"newlinalg",
".",
"SparseVector",
"(",
"self",
".",
"size",
",",
"self",
".",
"indices",
",",
"self",
".",
"values",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Vectors.dense | Create a dense vector of 64-bit floats from a Python list or numbers.
>>> Vectors.dense([1, 2, 3])
DenseVector([1.0, 2.0, 3.0])
>>> Vectors.dense(1.0, 2.0)
DenseVector([1.0, 2.0]) | python/pyspark/mllib/linalg/__init__.py | def dense(*elements):
"""
Create a dense vector of 64-bit floats from a Python list or numbers.
>>> Vectors.dense([1, 2, 3])
DenseVector([1.0, 2.0, 3.0])
>>> Vectors.dense(1.0, 2.0)
DenseVector([1.0, 2.0])
"""
if len(elements) == 1 and not isinstance(elem... | def dense(*elements):
"""
Create a dense vector of 64-bit floats from a Python list or numbers.
>>> Vectors.dense([1, 2, 3])
DenseVector([1.0, 2.0, 3.0])
>>> Vectors.dense(1.0, 2.0)
DenseVector([1.0, 2.0])
"""
if len(elements) == 1 and not isinstance(elem... | [
"Create",
"a",
"dense",
"vector",
"of",
"64",
"-",
"bit",
"floats",
"from",
"a",
"Python",
"list",
"or",
"numbers",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L874-L886 | [
"def",
"dense",
"(",
"*",
"elements",
")",
":",
"if",
"len",
"(",
"elements",
")",
"==",
"1",
"and",
"not",
"isinstance",
"(",
"elements",
"[",
"0",
"]",
",",
"(",
"float",
",",
"int",
",",
"long",
")",
")",
":",
"# it's list, numpy.array or other iter... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Vectors.fromML | Convert a vector from the new mllib-local representation.
This does NOT copy the data; it copies references.
:param vec: a :py:class:`pyspark.ml.linalg.Vector`
:return: a :py:class:`pyspark.mllib.linalg.Vector`
.. versionadded:: 2.0.0 | python/pyspark/mllib/linalg/__init__.py | def fromML(vec):
"""
Convert a vector from the new mllib-local representation.
This does NOT copy the data; it copies references.
:param vec: a :py:class:`pyspark.ml.linalg.Vector`
:return: a :py:class:`pyspark.mllib.linalg.Vector`
.. versionadded:: 2.0.0
"""
... | def fromML(vec):
"""
Convert a vector from the new mllib-local representation.
This does NOT copy the data; it copies references.
:param vec: a :py:class:`pyspark.ml.linalg.Vector`
:return: a :py:class:`pyspark.mllib.linalg.Vector`
.. versionadded:: 2.0.0
"""
... | [
"Convert",
"a",
"vector",
"from",
"the",
"new",
"mllib",
"-",
"local",
"representation",
".",
"This",
"does",
"NOT",
"copy",
"the",
"data",
";",
"it",
"copies",
"references",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L889-L904 | [
"def",
"fromML",
"(",
"vec",
")",
":",
"if",
"isinstance",
"(",
"vec",
",",
"newlinalg",
".",
"DenseVector",
")",
":",
"return",
"DenseVector",
"(",
"vec",
".",
"array",
")",
"elif",
"isinstance",
"(",
"vec",
",",
"newlinalg",
".",
"SparseVector",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Vectors.squared_distance | Squared distance between two vectors.
a and b can be of type SparseVector, DenseVector, np.ndarray
or array.array.
>>> a = Vectors.sparse(4, [(0, 1), (3, 4)])
>>> b = Vectors.dense([2, 5, 4, 1])
>>> a.squared_distance(b)
51.0 | python/pyspark/mllib/linalg/__init__.py | def squared_distance(v1, v2):
"""
Squared distance between two vectors.
a and b can be of type SparseVector, DenseVector, np.ndarray
or array.array.
>>> a = Vectors.sparse(4, [(0, 1), (3, 4)])
>>> b = Vectors.dense([2, 5, 4, 1])
>>> a.squared_distance(b)
... | def squared_distance(v1, v2):
"""
Squared distance between two vectors.
a and b can be of type SparseVector, DenseVector, np.ndarray
or array.array.
>>> a = Vectors.sparse(4, [(0, 1), (3, 4)])
>>> b = Vectors.dense([2, 5, 4, 1])
>>> a.squared_distance(b)
... | [
"Squared",
"distance",
"between",
"two",
"vectors",
".",
"a",
"and",
"b",
"can",
"be",
"of",
"type",
"SparseVector",
"DenseVector",
"np",
".",
"ndarray",
"or",
"array",
".",
"array",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L920-L932 | [
"def",
"squared_distance",
"(",
"v1",
",",
"v2",
")",
":",
"v1",
",",
"v2",
"=",
"_convert_to_vector",
"(",
"v1",
")",
",",
"_convert_to_vector",
"(",
"v2",
")",
"return",
"v1",
".",
"squared_distance",
"(",
"v2",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Vectors.parse | Parse a string representation back into the Vector.
>>> Vectors.parse('[2,1,2 ]')
DenseVector([2.0, 1.0, 2.0])
>>> Vectors.parse(' ( 100, [0], [2])')
SparseVector(100, {0: 2.0}) | python/pyspark/mllib/linalg/__init__.py | def parse(s):
"""Parse a string representation back into the Vector.
>>> Vectors.parse('[2,1,2 ]')
DenseVector([2.0, 1.0, 2.0])
>>> Vectors.parse(' ( 100, [0], [2])')
SparseVector(100, {0: 2.0})
"""
if s.find('(') == -1 and s.find('[') != -1:
return... | def parse(s):
"""Parse a string representation back into the Vector.
>>> Vectors.parse('[2,1,2 ]')
DenseVector([2.0, 1.0, 2.0])
>>> Vectors.parse(' ( 100, [0], [2])')
SparseVector(100, {0: 2.0})
"""
if s.find('(') == -1 and s.find('[') != -1:
return... | [
"Parse",
"a",
"string",
"representation",
"back",
"into",
"the",
"Vector",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L942-L956 | [
"def",
"parse",
"(",
"s",
")",
":",
"if",
"s",
".",
"find",
"(",
"'('",
")",
"==",
"-",
"1",
"and",
"s",
".",
"find",
"(",
"'['",
")",
"!=",
"-",
"1",
":",
"return",
"DenseVector",
".",
"parse",
"(",
"s",
")",
"elif",
"s",
".",
"find",
"(",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Vectors._equals | Check equality between sparse/dense vectors,
v1_indices and v2_indices assume to be strictly increasing. | python/pyspark/mllib/linalg/__init__.py | def _equals(v1_indices, v1_values, v2_indices, v2_values):
"""
Check equality between sparse/dense vectors,
v1_indices and v2_indices assume to be strictly increasing.
"""
v1_size = len(v1_values)
v2_size = len(v2_values)
k1 = 0
k2 = 0
all_equal = ... | def _equals(v1_indices, v1_values, v2_indices, v2_values):
"""
Check equality between sparse/dense vectors,
v1_indices and v2_indices assume to be strictly increasing.
"""
v1_size = len(v1_values)
v2_size = len(v2_values)
k1 = 0
k2 = 0
all_equal = ... | [
"Check",
"equality",
"between",
"sparse",
"/",
"dense",
"vectors",
"v1_indices",
"and",
"v2_indices",
"assume",
"to",
"be",
"strictly",
"increasing",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L963-L985 | [
"def",
"_equals",
"(",
"v1_indices",
",",
"v1_values",
",",
"v2_indices",
",",
"v2_values",
")",
":",
"v1_size",
"=",
"len",
"(",
"v1_values",
")",
"v2_size",
"=",
"len",
"(",
"v2_values",
")",
"k1",
"=",
"0",
"k2",
"=",
"0",
"all_equal",
"=",
"True",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Matrix._convert_to_array | Convert Matrix attributes which are array-like or buffer to array. | python/pyspark/mllib/linalg/__init__.py | def _convert_to_array(array_like, dtype):
"""
Convert Matrix attributes which are array-like or buffer to array.
"""
if isinstance(array_like, bytes):
return np.frombuffer(array_like, dtype=dtype)
return np.asarray(array_like, dtype=dtype) | def _convert_to_array(array_like, dtype):
"""
Convert Matrix attributes which are array-like or buffer to array.
"""
if isinstance(array_like, bytes):
return np.frombuffer(array_like, dtype=dtype)
return np.asarray(array_like, dtype=dtype) | [
"Convert",
"Matrix",
"attributes",
"which",
"are",
"array",
"-",
"like",
"or",
"buffer",
"to",
"array",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1014-L1020 | [
"def",
"_convert_to_array",
"(",
"array_like",
",",
"dtype",
")",
":",
"if",
"isinstance",
"(",
"array_like",
",",
"bytes",
")",
":",
"return",
"np",
".",
"frombuffer",
"(",
"array_like",
",",
"dtype",
"=",
"dtype",
")",
"return",
"np",
".",
"asarray",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DenseMatrix.toArray | Return an numpy.ndarray
>>> m = DenseMatrix(2, 2, range(4))
>>> m.toArray()
array([[ 0., 2.],
[ 1., 3.]]) | python/pyspark/mllib/linalg/__init__.py | def toArray(self):
"""
Return an numpy.ndarray
>>> m = DenseMatrix(2, 2, range(4))
>>> m.toArray()
array([[ 0., 2.],
[ 1., 3.]])
"""
if self.isTransposed:
return np.asfortranarray(
self.values.reshape((self.numRows, se... | def toArray(self):
"""
Return an numpy.ndarray
>>> m = DenseMatrix(2, 2, range(4))
>>> m.toArray()
array([[ 0., 2.],
[ 1., 3.]])
"""
if self.isTransposed:
return np.asfortranarray(
self.values.reshape((self.numRows, se... | [
"Return",
"an",
"numpy",
".",
"ndarray"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1082-L1095 | [
"def",
"toArray",
"(",
"self",
")",
":",
"if",
"self",
".",
"isTransposed",
":",
"return",
"np",
".",
"asfortranarray",
"(",
"self",
".",
"values",
".",
"reshape",
"(",
"(",
"self",
".",
"numRows",
",",
"self",
".",
"numCols",
")",
")",
")",
"else",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DenseMatrix.toSparse | Convert to SparseMatrix | python/pyspark/mllib/linalg/__init__.py | def toSparse(self):
"""Convert to SparseMatrix"""
if self.isTransposed:
values = np.ravel(self.toArray(), order='F')
else:
values = self.values
indices = np.nonzero(values)[0]
colCounts = np.bincount(indices // self.numRows)
colPtrs = np.cumsum(np.... | def toSparse(self):
"""Convert to SparseMatrix"""
if self.isTransposed:
values = np.ravel(self.toArray(), order='F')
else:
values = self.values
indices = np.nonzero(values)[0]
colCounts = np.bincount(indices // self.numRows)
colPtrs = np.cumsum(np.... | [
"Convert",
"to",
"SparseMatrix"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1097-L1110 | [
"def",
"toSparse",
"(",
"self",
")",
":",
"if",
"self",
".",
"isTransposed",
":",
"values",
"=",
"np",
".",
"ravel",
"(",
"self",
".",
"toArray",
"(",
")",
",",
"order",
"=",
"'F'",
")",
"else",
":",
"values",
"=",
"self",
".",
"values",
"indices",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DenseMatrix.asML | Convert this matrix to the new mllib-local representation.
This does NOT copy the data; it copies references.
:return: :py:class:`pyspark.ml.linalg.DenseMatrix`
.. versionadded:: 2.0.0 | python/pyspark/mllib/linalg/__init__.py | def asML(self):
"""
Convert this matrix to the new mllib-local representation.
This does NOT copy the data; it copies references.
:return: :py:class:`pyspark.ml.linalg.DenseMatrix`
.. versionadded:: 2.0.0
"""
return newlinalg.DenseMatrix(self.numRows, self.numCo... | def asML(self):
"""
Convert this matrix to the new mllib-local representation.
This does NOT copy the data; it copies references.
:return: :py:class:`pyspark.ml.linalg.DenseMatrix`
.. versionadded:: 2.0.0
"""
return newlinalg.DenseMatrix(self.numRows, self.numCo... | [
"Convert",
"this",
"matrix",
"to",
"the",
"new",
"mllib",
"-",
"local",
"representation",
".",
"This",
"does",
"NOT",
"copy",
"the",
"data",
";",
"it",
"copies",
"references",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1112-L1121 | [
"def",
"asML",
"(",
"self",
")",
":",
"return",
"newlinalg",
".",
"DenseMatrix",
"(",
"self",
".",
"numRows",
",",
"self",
".",
"numCols",
",",
"self",
".",
"values",
",",
"self",
".",
"isTransposed",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparseMatrix.toArray | Return an numpy.ndarray | python/pyspark/mllib/linalg/__init__.py | def toArray(self):
"""
Return an numpy.ndarray
"""
A = np.zeros((self.numRows, self.numCols), dtype=np.float64, order='F')
for k in xrange(self.colPtrs.size - 1):
startptr = self.colPtrs[k]
endptr = self.colPtrs[k + 1]
if self.isTransposed:
... | def toArray(self):
"""
Return an numpy.ndarray
"""
A = np.zeros((self.numRows, self.numCols), dtype=np.float64, order='F')
for k in xrange(self.colPtrs.size - 1):
startptr = self.colPtrs[k]
endptr = self.colPtrs[k + 1]
if self.isTransposed:
... | [
"Return",
"an",
"numpy",
".",
"ndarray"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1277-L1289 | [
"def",
"toArray",
"(",
"self",
")",
":",
"A",
"=",
"np",
".",
"zeros",
"(",
"(",
"self",
".",
"numRows",
",",
"self",
".",
"numCols",
")",
",",
"dtype",
"=",
"np",
".",
"float64",
",",
"order",
"=",
"'F'",
")",
"for",
"k",
"in",
"xrange",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparseMatrix.asML | Convert this matrix to the new mllib-local representation.
This does NOT copy the data; it copies references.
:return: :py:class:`pyspark.ml.linalg.SparseMatrix`
.. versionadded:: 2.0.0 | python/pyspark/mllib/linalg/__init__.py | def asML(self):
"""
Convert this matrix to the new mllib-local representation.
This does NOT copy the data; it copies references.
:return: :py:class:`pyspark.ml.linalg.SparseMatrix`
.. versionadded:: 2.0.0
"""
return newlinalg.SparseMatrix(self.numRows, self.num... | def asML(self):
"""
Convert this matrix to the new mllib-local representation.
This does NOT copy the data; it copies references.
:return: :py:class:`pyspark.ml.linalg.SparseMatrix`
.. versionadded:: 2.0.0
"""
return newlinalg.SparseMatrix(self.numRows, self.num... | [
"Convert",
"this",
"matrix",
"to",
"the",
"new",
"mllib",
"-",
"local",
"representation",
".",
"This",
"does",
"NOT",
"copy",
"the",
"data",
";",
"it",
"copies",
"references",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1295-L1305 | [
"def",
"asML",
"(",
"self",
")",
":",
"return",
"newlinalg",
".",
"SparseMatrix",
"(",
"self",
".",
"numRows",
",",
"self",
".",
"numCols",
",",
"self",
".",
"colPtrs",
",",
"self",
".",
"rowIndices",
",",
"self",
".",
"values",
",",
"self",
".",
"is... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Matrices.sparse | Create a SparseMatrix | python/pyspark/mllib/linalg/__init__.py | def sparse(numRows, numCols, colPtrs, rowIndices, values):
"""
Create a SparseMatrix
"""
return SparseMatrix(numRows, numCols, colPtrs, rowIndices, values) | def sparse(numRows, numCols, colPtrs, rowIndices, values):
"""
Create a SparseMatrix
"""
return SparseMatrix(numRows, numCols, colPtrs, rowIndices, values) | [
"Create",
"a",
"SparseMatrix"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1321-L1325 | [
"def",
"sparse",
"(",
"numRows",
",",
"numCols",
",",
"colPtrs",
",",
"rowIndices",
",",
"values",
")",
":",
"return",
"SparseMatrix",
"(",
"numRows",
",",
"numCols",
",",
"colPtrs",
",",
"rowIndices",
",",
"values",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Matrices.fromML | Convert a matrix from the new mllib-local representation.
This does NOT copy the data; it copies references.
:param mat: a :py:class:`pyspark.ml.linalg.Matrix`
:return: a :py:class:`pyspark.mllib.linalg.Matrix`
.. versionadded:: 2.0.0 | python/pyspark/mllib/linalg/__init__.py | def fromML(mat):
"""
Convert a matrix from the new mllib-local representation.
This does NOT copy the data; it copies references.
:param mat: a :py:class:`pyspark.ml.linalg.Matrix`
:return: a :py:class:`pyspark.mllib.linalg.Matrix`
.. versionadded:: 2.0.0
"""
... | def fromML(mat):
"""
Convert a matrix from the new mllib-local representation.
This does NOT copy the data; it copies references.
:param mat: a :py:class:`pyspark.ml.linalg.Matrix`
:return: a :py:class:`pyspark.mllib.linalg.Matrix`
.. versionadded:: 2.0.0
"""
... | [
"Convert",
"a",
"matrix",
"from",
"the",
"new",
"mllib",
"-",
"local",
"representation",
".",
"This",
"does",
"NOT",
"copy",
"the",
"data",
";",
"it",
"copies",
"references",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1328-L1344 | [
"def",
"fromML",
"(",
"mat",
")",
":",
"if",
"isinstance",
"(",
"mat",
",",
"newlinalg",
".",
"DenseMatrix",
")",
":",
"return",
"DenseMatrix",
"(",
"mat",
".",
"numRows",
",",
"mat",
".",
"numCols",
",",
"mat",
".",
"values",
",",
"mat",
".",
"isTra... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | LSHModel.approxNearestNeighbors | Given a large dataset and an item, approximately find at most k items which have the
closest distance to the item. If the :py:attr:`outputCol` is missing, the method will
transform the data; if the :py:attr:`outputCol` exists, it will use that. This allows
caching of the transformed data when ne... | python/pyspark/ml/feature.py | def approxNearestNeighbors(self, dataset, key, numNearestNeighbors, distCol="distCol"):
"""
Given a large dataset and an item, approximately find at most k items which have the
closest distance to the item. If the :py:attr:`outputCol` is missing, the method will
transform the data; if th... | def approxNearestNeighbors(self, dataset, key, numNearestNeighbors, distCol="distCol"):
"""
Given a large dataset and an item, approximately find at most k items which have the
closest distance to the item. If the :py:attr:`outputCol` is missing, the method will
transform the data; if th... | [
"Given",
"a",
"large",
"dataset",
"and",
"an",
"item",
"approximately",
"find",
"at",
"most",
"k",
"items",
"which",
"have",
"the",
"closest",
"distance",
"to",
"the",
"item",
".",
"If",
"the",
":",
"py",
":",
"attr",
":",
"outputCol",
"is",
"missing",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/feature.py#L162-L180 | [
"def",
"approxNearestNeighbors",
"(",
"self",
",",
"dataset",
",",
"key",
",",
"numNearestNeighbors",
",",
"distCol",
"=",
"\"distCol\"",
")",
":",
"return",
"self",
".",
"_call_java",
"(",
"\"approxNearestNeighbors\"",
",",
"dataset",
",",
"key",
",",
"numNeare... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | LSHModel.approxSimilarityJoin | Join two datasets to approximately find all pairs of rows whose distance are smaller than
the threshold. If the :py:attr:`outputCol` is missing, the method will transform the data;
if the :py:attr:`outputCol` exists, it will use that. This allows caching of the
transformed data when necessary.
... | python/pyspark/ml/feature.py | def approxSimilarityJoin(self, datasetA, datasetB, threshold, distCol="distCol"):
"""
Join two datasets to approximately find all pairs of rows whose distance are smaller than
the threshold. If the :py:attr:`outputCol` is missing, the method will transform the data;
if the :py:attr:`outp... | def approxSimilarityJoin(self, datasetA, datasetB, threshold, distCol="distCol"):
"""
Join two datasets to approximately find all pairs of rows whose distance are smaller than
the threshold. If the :py:attr:`outputCol` is missing, the method will transform the data;
if the :py:attr:`outp... | [
"Join",
"two",
"datasets",
"to",
"approximately",
"find",
"all",
"pairs",
"of",
"rows",
"whose",
"distance",
"are",
"smaller",
"than",
"the",
"threshold",
".",
"If",
"the",
":",
"py",
":",
"attr",
":",
"outputCol",
"is",
"missing",
"the",
"method",
"will",... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/feature.py#L182-L199 | [
"def",
"approxSimilarityJoin",
"(",
"self",
",",
"datasetA",
",",
"datasetB",
",",
"threshold",
",",
"distCol",
"=",
"\"distCol\"",
")",
":",
"threshold",
"=",
"TypeConverters",
".",
"toFloat",
"(",
"threshold",
")",
"return",
"self",
".",
"_call_java",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StringIndexerModel.from_labels | Construct the model directly from an array of label strings,
requires an active SparkContext. | python/pyspark/ml/feature.py | def from_labels(cls, labels, inputCol, outputCol=None, handleInvalid=None):
"""
Construct the model directly from an array of label strings,
requires an active SparkContext.
"""
sc = SparkContext._active_spark_context
java_class = sc._gateway.jvm.java.lang.String
... | def from_labels(cls, labels, inputCol, outputCol=None, handleInvalid=None):
"""
Construct the model directly from an array of label strings,
requires an active SparkContext.
"""
sc = SparkContext._active_spark_context
java_class = sc._gateway.jvm.java.lang.String
... | [
"Construct",
"the",
"model",
"directly",
"from",
"an",
"array",
"of",
"label",
"strings",
"requires",
"an",
"active",
"SparkContext",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/feature.py#L2503-L2518 | [
"def",
"from_labels",
"(",
"cls",
",",
"labels",
",",
"inputCol",
",",
"outputCol",
"=",
"None",
",",
"handleInvalid",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"java_class",
"=",
"sc",
".",
"_gateway",
".",
"jvm",
"."... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StringIndexerModel.from_arrays_of_labels | Construct the model directly from an array of array of label strings,
requires an active SparkContext. | python/pyspark/ml/feature.py | def from_arrays_of_labels(cls, arrayOfLabels, inputCols, outputCols=None,
handleInvalid=None):
"""
Construct the model directly from an array of array of label strings,
requires an active SparkContext.
"""
sc = SparkContext._active_spark_context
... | def from_arrays_of_labels(cls, arrayOfLabels, inputCols, outputCols=None,
handleInvalid=None):
"""
Construct the model directly from an array of array of label strings,
requires an active SparkContext.
"""
sc = SparkContext._active_spark_context
... | [
"Construct",
"the",
"model",
"directly",
"from",
"an",
"array",
"of",
"array",
"of",
"label",
"strings",
"requires",
"an",
"active",
"SparkContext",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/feature.py#L2522-L2538 | [
"def",
"from_arrays_of_labels",
"(",
"cls",
",",
"arrayOfLabels",
",",
"inputCols",
",",
"outputCols",
"=",
"None",
",",
"handleInvalid",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"java_class",
"=",
"sc",
".",
"_gateway",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StopWordsRemover.setParams | setParams(self, inputCol=None, outputCol=None, stopWords=None, caseSensitive=false, \
locale=None)
Sets params for this StopWordRemover. | python/pyspark/ml/feature.py | def setParams(self, inputCol=None, outputCol=None, stopWords=None, caseSensitive=False,
locale=None):
"""
setParams(self, inputCol=None, outputCol=None, stopWords=None, caseSensitive=false, \
locale=None)
Sets params for this StopWordRemover.
"""
kwargs ... | def setParams(self, inputCol=None, outputCol=None, stopWords=None, caseSensitive=False,
locale=None):
"""
setParams(self, inputCol=None, outputCol=None, stopWords=None, caseSensitive=false, \
locale=None)
Sets params for this StopWordRemover.
"""
kwargs ... | [
"setParams",
"(",
"self",
"inputCol",
"=",
"None",
"outputCol",
"=",
"None",
"stopWords",
"=",
"None",
"caseSensitive",
"=",
"false",
"\\",
"locale",
"=",
"None",
")",
"Sets",
"params",
"for",
"this",
"StopWordRemover",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/feature.py#L2654-L2662 | [
"def",
"setParams",
"(",
"self",
",",
"inputCol",
"=",
"None",
",",
"outputCol",
"=",
"None",
",",
"stopWords",
"=",
"None",
",",
"caseSensitive",
"=",
"False",
",",
"locale",
"=",
"None",
")",
":",
"kwargs",
"=",
"self",
".",
"_input_kwargs",
"return",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StopWordsRemover.loadDefaultStopWords | Loads the default stop words for the given language.
Supported languages: danish, dutch, english, finnish, french, german, hungarian,
italian, norwegian, portuguese, russian, spanish, swedish, turkish | python/pyspark/ml/feature.py | def loadDefaultStopWords(language):
"""
Loads the default stop words for the given language.
Supported languages: danish, dutch, english, finnish, french, german, hungarian,
italian, norwegian, portuguese, russian, spanish, swedish, turkish
"""
stopWordsObj = _jvm().org.a... | def loadDefaultStopWords(language):
"""
Loads the default stop words for the given language.
Supported languages: danish, dutch, english, finnish, french, german, hungarian,
italian, norwegian, portuguese, russian, spanish, swedish, turkish
"""
stopWordsObj = _jvm().org.a... | [
"Loads",
"the",
"default",
"stop",
"words",
"for",
"the",
"given",
"language",
".",
"Supported",
"languages",
":",
"danish",
"dutch",
"english",
"finnish",
"french",
"german",
"hungarian",
"italian",
"norwegian",
"portuguese",
"russian",
"spanish",
"swedish",
"tur... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/feature.py#L2708-L2715 | [
"def",
"loadDefaultStopWords",
"(",
"language",
")",
":",
"stopWordsObj",
"=",
"_jvm",
"(",
")",
".",
"org",
".",
"apache",
".",
"spark",
".",
"ml",
".",
"feature",
".",
"StopWordsRemover",
"return",
"list",
"(",
"stopWordsObj",
".",
"loadDefaultStopWords",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Word2VecModel.findSynonyms | Find "num" number of words closest in similarity to "word".
word can be a string or vector representation.
Returns a dataframe with two fields word and similarity (which
gives the cosine similarity). | python/pyspark/ml/feature.py | def findSynonyms(self, word, num):
"""
Find "num" number of words closest in similarity to "word".
word can be a string or vector representation.
Returns a dataframe with two fields word and similarity (which
gives the cosine similarity).
"""
if not isinstance(wor... | def findSynonyms(self, word, num):
"""
Find "num" number of words closest in similarity to "word".
word can be a string or vector representation.
Returns a dataframe with two fields word and similarity (which
gives the cosine similarity).
"""
if not isinstance(wor... | [
"Find",
"num",
"number",
"of",
"words",
"closest",
"in",
"similarity",
"to",
"word",
".",
"word",
"can",
"be",
"a",
"string",
"or",
"vector",
"representation",
".",
"Returns",
"a",
"dataframe",
"with",
"two",
"fields",
"word",
"and",
"similarity",
"(",
"wh... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/feature.py#L3293-L3302 | [
"def",
"findSynonyms",
"(",
"self",
",",
"word",
",",
"num",
")",
":",
"if",
"not",
"isinstance",
"(",
"word",
",",
"basestring",
")",
":",
"word",
"=",
"_convert_to_vector",
"(",
"word",
")",
"return",
"self",
".",
"_call_java",
"(",
"\"findSynonyms\"",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Word2VecModel.findSynonymsArray | Find "num" number of words closest in similarity to "word".
word can be a string or vector representation.
Returns an array with two fields word and similarity (which
gives the cosine similarity). | python/pyspark/ml/feature.py | def findSynonymsArray(self, word, num):
"""
Find "num" number of words closest in similarity to "word".
word can be a string or vector representation.
Returns an array with two fields word and similarity (which
gives the cosine similarity).
"""
if not isinstance(w... | def findSynonymsArray(self, word, num):
"""
Find "num" number of words closest in similarity to "word".
word can be a string or vector representation.
Returns an array with two fields word and similarity (which
gives the cosine similarity).
"""
if not isinstance(w... | [
"Find",
"num",
"number",
"of",
"words",
"closest",
"in",
"similarity",
"to",
"word",
".",
"word",
"can",
"be",
"a",
"string",
"or",
"vector",
"representation",
".",
"Returns",
"an",
"array",
"with",
"two",
"fields",
"word",
"and",
"similarity",
"(",
"which... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/feature.py#L3305-L3315 | [
"def",
"findSynonymsArray",
"(",
"self",
",",
"word",
",",
"num",
")",
":",
"if",
"not",
"isinstance",
"(",
"word",
",",
"basestring",
")",
":",
"word",
"=",
"_convert_to_vector",
"(",
"word",
")",
"tuples",
"=",
"self",
".",
"_java_obj",
".",
"findSynon... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | install_exception_handler | Hook an exception handler into Py4j, which could capture some SQL exceptions in Java.
When calling Java API, it will call `get_return_value` to parse the returned object.
If any exception happened in JVM, the result will be Java exception object, it raise
py4j.protocol.Py4JJavaError. We replace the origina... | python/pyspark/sql/utils.py | def install_exception_handler():
"""
Hook an exception handler into Py4j, which could capture some SQL exceptions in Java.
When calling Java API, it will call `get_return_value` to parse the returned object.
If any exception happened in JVM, the result will be Java exception object, it raise
py4j.p... | def install_exception_handler():
"""
Hook an exception handler into Py4j, which could capture some SQL exceptions in Java.
When calling Java API, it will call `get_return_value` to parse the returned object.
If any exception happened in JVM, the result will be Java exception object, it raise
py4j.p... | [
"Hook",
"an",
"exception",
"handler",
"into",
"Py4j",
"which",
"could",
"capture",
"some",
"SQL",
"exceptions",
"in",
"Java",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/utils.py#L99-L114 | [
"def",
"install_exception_handler",
"(",
")",
":",
"original",
"=",
"py4j",
".",
"protocol",
".",
"get_return_value",
"# The original `get_return_value` is not patched, it's idempotent.",
"patched",
"=",
"capture_sql_exception",
"(",
"original",
")",
"# only patch the one used ... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | toJArray | Convert python list to java type array
:param gateway: Py4j Gateway
:param jtype: java type of element in array
:param arr: python type list | python/pyspark/sql/utils.py | def toJArray(gateway, jtype, arr):
"""
Convert python list to java type array
:param gateway: Py4j Gateway
:param jtype: java type of element in array
:param arr: python type list
"""
jarr = gateway.new_array(jtype, len(arr))
for i in range(0, len(arr)):
jarr[i] = arr[i]
retu... | def toJArray(gateway, jtype, arr):
"""
Convert python list to java type array
:param gateway: Py4j Gateway
:param jtype: java type of element in array
:param arr: python type list
"""
jarr = gateway.new_array(jtype, len(arr))
for i in range(0, len(arr)):
jarr[i] = arr[i]
retu... | [
"Convert",
"python",
"list",
"to",
"java",
"type",
"array",
":",
"param",
"gateway",
":",
"Py4j",
"Gateway",
":",
"param",
"jtype",
":",
"java",
"type",
"of",
"element",
"in",
"array",
":",
"param",
"arr",
":",
"python",
"type",
"list"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/utils.py#L117-L127 | [
"def",
"toJArray",
"(",
"gateway",
",",
"jtype",
",",
"arr",
")",
":",
"jarr",
"=",
"gateway",
".",
"new_array",
"(",
"jtype",
",",
"len",
"(",
"arr",
")",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"arr",
")",
")",
":",
"jarr",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | require_minimum_pandas_version | Raise ImportError if minimum version of Pandas is not installed | python/pyspark/sql/utils.py | def require_minimum_pandas_version():
""" Raise ImportError if minimum version of Pandas is not installed
"""
# TODO(HyukjinKwon): Relocate and deduplicate the version specification.
minimum_pandas_version = "0.19.2"
from distutils.version import LooseVersion
try:
import pandas
... | def require_minimum_pandas_version():
""" Raise ImportError if minimum version of Pandas is not installed
"""
# TODO(HyukjinKwon): Relocate and deduplicate the version specification.
minimum_pandas_version = "0.19.2"
from distutils.version import LooseVersion
try:
import pandas
... | [
"Raise",
"ImportError",
"if",
"minimum",
"version",
"of",
"Pandas",
"is",
"not",
"installed"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/utils.py#L130-L147 | [
"def",
"require_minimum_pandas_version",
"(",
")",
":",
"# TODO(HyukjinKwon): Relocate and deduplicate the version specification.",
"minimum_pandas_version",
"=",
"\"0.19.2\"",
"from",
"distutils",
".",
"version",
"import",
"LooseVersion",
"try",
":",
"import",
"pandas",
"have_... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | require_minimum_pyarrow_version | Raise ImportError if minimum version of pyarrow is not installed | python/pyspark/sql/utils.py | def require_minimum_pyarrow_version():
""" Raise ImportError if minimum version of pyarrow is not installed
"""
# TODO(HyukjinKwon): Relocate and deduplicate the version specification.
minimum_pyarrow_version = "0.12.1"
from distutils.version import LooseVersion
try:
import pyarrow
... | def require_minimum_pyarrow_version():
""" Raise ImportError if minimum version of pyarrow is not installed
"""
# TODO(HyukjinKwon): Relocate and deduplicate the version specification.
minimum_pyarrow_version = "0.12.1"
from distutils.version import LooseVersion
try:
import pyarrow
... | [
"Raise",
"ImportError",
"if",
"minimum",
"version",
"of",
"pyarrow",
"is",
"not",
"installed"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/utils.py#L150-L167 | [
"def",
"require_minimum_pyarrow_version",
"(",
")",
":",
"# TODO(HyukjinKwon): Relocate and deduplicate the version specification.",
"minimum_pyarrow_version",
"=",
"\"0.12.1\"",
"from",
"distutils",
".",
"version",
"import",
"LooseVersion",
"try",
":",
"import",
"pyarrow",
"ha... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | launch_gateway | launch jvm gateway
:param conf: spark configuration passed to spark-submit
:param popen_kwargs: Dictionary of kwargs to pass to Popen when spawning
the py4j JVM. This is a developer feature intended for use in
customizing how pyspark interacts with the py4j JVM (e.g., capturing
stdout/st... | python/pyspark/java_gateway.py | def launch_gateway(conf=None, popen_kwargs=None):
"""
launch jvm gateway
:param conf: spark configuration passed to spark-submit
:param popen_kwargs: Dictionary of kwargs to pass to Popen when spawning
the py4j JVM. This is a developer feature intended for use in
customizing how pyspark ... | def launch_gateway(conf=None, popen_kwargs=None):
"""
launch jvm gateway
:param conf: spark configuration passed to spark-submit
:param popen_kwargs: Dictionary of kwargs to pass to Popen when spawning
the py4j JVM. This is a developer feature intended for use in
customizing how pyspark ... | [
"launch",
"jvm",
"gateway",
":",
"param",
"conf",
":",
"spark",
"configuration",
"passed",
"to",
"spark",
"-",
"submit",
":",
"param",
"popen_kwargs",
":",
"Dictionary",
"of",
"kwargs",
"to",
"pass",
"to",
"Popen",
"when",
"spawning",
"the",
"py4j",
"JVM",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/java_gateway.py#L39-L147 | [
"def",
"launch_gateway",
"(",
"conf",
"=",
"None",
",",
"popen_kwargs",
"=",
"None",
")",
":",
"if",
"\"PYSPARK_GATEWAY_PORT\"",
"in",
"os",
".",
"environ",
":",
"gateway_port",
"=",
"int",
"(",
"os",
".",
"environ",
"[",
"\"PYSPARK_GATEWAY_PORT\"",
"]",
")"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _do_server_auth | Performs the authentication protocol defined by the SocketAuthHelper class on the given
file-like object 'conn'. | python/pyspark/java_gateway.py | def _do_server_auth(conn, auth_secret):
"""
Performs the authentication protocol defined by the SocketAuthHelper class on the given
file-like object 'conn'.
"""
write_with_length(auth_secret.encode("utf-8"), conn)
conn.flush()
reply = UTF8Deserializer().loads(conn)
if reply != "ok":
... | def _do_server_auth(conn, auth_secret):
"""
Performs the authentication protocol defined by the SocketAuthHelper class on the given
file-like object 'conn'.
"""
write_with_length(auth_secret.encode("utf-8"), conn)
conn.flush()
reply = UTF8Deserializer().loads(conn)
if reply != "ok":
... | [
"Performs",
"the",
"authentication",
"protocol",
"defined",
"by",
"the",
"SocketAuthHelper",
"class",
"on",
"the",
"given",
"file",
"-",
"like",
"object",
"conn",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/java_gateway.py#L150-L160 | [
"def",
"_do_server_auth",
"(",
"conn",
",",
"auth_secret",
")",
":",
"write_with_length",
"(",
"auth_secret",
".",
"encode",
"(",
"\"utf-8\"",
")",
",",
"conn",
")",
"conn",
".",
"flush",
"(",
")",
"reply",
"=",
"UTF8Deserializer",
"(",
")",
".",
"loads",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | local_connect_and_auth | Connect to local host, authenticate with it, and return a (sockfile,sock) for that connection.
Handles IPV4 & IPV6, does some error handling.
:param port
:param auth_secret
:return: a tuple with (sockfile, sock) | python/pyspark/java_gateway.py | def local_connect_and_auth(port, auth_secret):
"""
Connect to local host, authenticate with it, and return a (sockfile,sock) for that connection.
Handles IPV4 & IPV6, does some error handling.
:param port
:param auth_secret
:return: a tuple with (sockfile, sock)
"""
sock = None
error... | def local_connect_and_auth(port, auth_secret):
"""
Connect to local host, authenticate with it, and return a (sockfile,sock) for that connection.
Handles IPV4 & IPV6, does some error handling.
:param port
:param auth_secret
:return: a tuple with (sockfile, sock)
"""
sock = None
error... | [
"Connect",
"to",
"local",
"host",
"authenticate",
"with",
"it",
"and",
"return",
"a",
"(",
"sockfile",
"sock",
")",
"for",
"that",
"connection",
".",
"Handles",
"IPV4",
"&",
"IPV6",
"does",
"some",
"error",
"handling",
".",
":",
"param",
"port",
":",
"pa... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/java_gateway.py#L163-L189 | [
"def",
"local_connect_and_auth",
"(",
"port",
",",
"auth_secret",
")",
":",
"sock",
"=",
"None",
"errors",
"=",
"[",
"]",
"# Support for both IPv4 and IPv6.",
"# On most of IPv6-ready systems, IPv6 will take precedence.",
"for",
"res",
"in",
"socket",
".",
"getaddrinfo",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | ensure_callback_server_started | Start callback server if not already started. The callback server is needed if the Java
driver process needs to callback into the Python driver process to execute Python code. | python/pyspark/java_gateway.py | def ensure_callback_server_started(gw):
"""
Start callback server if not already started. The callback server is needed if the Java
driver process needs to callback into the Python driver process to execute Python code.
"""
# getattr will fallback to JVM, so we cannot test by hasattr()
if "_cal... | def ensure_callback_server_started(gw):
"""
Start callback server if not already started. The callback server is needed if the Java
driver process needs to callback into the Python driver process to execute Python code.
"""
# getattr will fallback to JVM, so we cannot test by hasattr()
if "_cal... | [
"Start",
"callback",
"server",
"if",
"not",
"already",
"started",
".",
"The",
"callback",
"server",
"is",
"needed",
"if",
"the",
"Java",
"driver",
"process",
"needs",
"to",
"callback",
"into",
"the",
"Python",
"driver",
"process",
"to",
"execute",
"Python",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/java_gateway.py#L192-L212 | [
"def",
"ensure_callback_server_started",
"(",
"gw",
")",
":",
"# getattr will fallback to JVM, so we cannot test by hasattr()",
"if",
"\"_callback_server\"",
"not",
"in",
"gw",
".",
"__dict__",
"or",
"gw",
".",
"_callback_server",
"is",
"None",
":",
"gw",
".",
"callback... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _find_spark_home | Find the SPARK_HOME. | python/pyspark/find_spark_home.py | def _find_spark_home():
"""Find the SPARK_HOME."""
# If the environment has SPARK_HOME set trust it.
if "SPARK_HOME" in os.environ:
return os.environ["SPARK_HOME"]
def is_spark_home(path):
"""Takes a path and returns true if the provided path could be a reasonable SPARK_HOME"""
... | def _find_spark_home():
"""Find the SPARK_HOME."""
# If the environment has SPARK_HOME set trust it.
if "SPARK_HOME" in os.environ:
return os.environ["SPARK_HOME"]
def is_spark_home(path):
"""Takes a path and returns true if the provided path could be a reasonable SPARK_HOME"""
... | [
"Find",
"the",
"SPARK_HOME",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/find_spark_home.py#L28-L71 | [
"def",
"_find_spark_home",
"(",
")",
":",
"# If the environment has SPARK_HOME set trust it.",
"if",
"\"SPARK_HOME\"",
"in",
"os",
".",
"environ",
":",
"return",
"os",
".",
"environ",
"[",
"\"SPARK_HOME\"",
"]",
"def",
"is_spark_home",
"(",
"path",
")",
":",
"\"\"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | computeContribs | Calculates URL contributions to the rank of other URLs. | examples/src/main/python/pagerank.py | def computeContribs(urls, rank):
"""Calculates URL contributions to the rank of other URLs."""
num_urls = len(urls)
for url in urls:
yield (url, rank / num_urls) | def computeContribs(urls, rank):
"""Calculates URL contributions to the rank of other URLs."""
num_urls = len(urls)
for url in urls:
yield (url, rank / num_urls) | [
"Calculates",
"URL",
"contributions",
"to",
"the",
"rank",
"of",
"other",
"URLs",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/examples/src/main/python/pagerank.py#L34-L38 | [
"def",
"computeContribs",
"(",
"urls",
",",
"rank",
")",
":",
"num_urls",
"=",
"len",
"(",
"urls",
")",
"for",
"url",
"in",
"urls",
":",
"yield",
"(",
"url",
",",
"rank",
"/",
"num_urls",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | GaussianMixtureModel.summary | Gets summary (e.g. cluster assignments, cluster sizes) of the model trained on the
training set. An exception is thrown if no summary exists. | python/pyspark/ml/clustering.py | def summary(self):
"""
Gets summary (e.g. cluster assignments, cluster sizes) of the model trained on the
training set. An exception is thrown if no summary exists.
"""
if self.hasSummary:
return GaussianMixtureSummary(super(GaussianMixtureModel, self).summary)
... | def summary(self):
"""
Gets summary (e.g. cluster assignments, cluster sizes) of the model trained on the
training set. An exception is thrown if no summary exists.
"""
if self.hasSummary:
return GaussianMixtureSummary(super(GaussianMixtureModel, self).summary)
... | [
"Gets",
"summary",
"(",
"e",
".",
"g",
".",
"cluster",
"assignments",
"cluster",
"sizes",
")",
"of",
"the",
"model",
"trained",
"on",
"the",
"training",
"set",
".",
"An",
"exception",
"is",
"thrown",
"if",
"no",
"summary",
"exists",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/clustering.py#L129-L138 | [
"def",
"summary",
"(",
"self",
")",
":",
"if",
"self",
".",
"hasSummary",
":",
"return",
"GaussianMixtureSummary",
"(",
"super",
"(",
"GaussianMixtureModel",
",",
"self",
")",
".",
"summary",
")",
"else",
":",
"raise",
"RuntimeError",
"(",
"\"No training summa... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | KMeansModel.summary | Gets summary (e.g. cluster assignments, cluster sizes) of the model trained on the
training set. An exception is thrown if no summary exists. | python/pyspark/ml/clustering.py | def summary(self):
"""
Gets summary (e.g. cluster assignments, cluster sizes) of the model trained on the
training set. An exception is thrown if no summary exists.
"""
if self.hasSummary:
return KMeansSummary(super(KMeansModel, self).summary)
else:
... | def summary(self):
"""
Gets summary (e.g. cluster assignments, cluster sizes) of the model trained on the
training set. An exception is thrown if no summary exists.
"""
if self.hasSummary:
return KMeansSummary(super(KMeansModel, self).summary)
else:
... | [
"Gets",
"summary",
"(",
"e",
".",
"g",
".",
"cluster",
"assignments",
"cluster",
"sizes",
")",
"of",
"the",
"model",
"trained",
"on",
"the",
"training",
"set",
".",
"An",
"exception",
"is",
"thrown",
"if",
"no",
"summary",
"exists",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/clustering.py#L331-L340 | [
"def",
"summary",
"(",
"self",
")",
":",
"if",
"self",
".",
"hasSummary",
":",
"return",
"KMeansSummary",
"(",
"super",
"(",
"KMeansModel",
",",
"self",
")",
".",
"summary",
")",
"else",
":",
"raise",
"RuntimeError",
"(",
"\"No training summary available for t... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | BisectingKMeansModel.summary | Gets summary (e.g. cluster assignments, cluster sizes) of the model trained on the
training set. An exception is thrown if no summary exists. | python/pyspark/ml/clustering.py | def summary(self):
"""
Gets summary (e.g. cluster assignments, cluster sizes) of the model trained on the
training set. An exception is thrown if no summary exists.
"""
if self.hasSummary:
return BisectingKMeansSummary(super(BisectingKMeansModel, self).summary)
... | def summary(self):
"""
Gets summary (e.g. cluster assignments, cluster sizes) of the model trained on the
training set. An exception is thrown if no summary exists.
"""
if self.hasSummary:
return BisectingKMeansSummary(super(BisectingKMeansModel, self).summary)
... | [
"Gets",
"summary",
"(",
"e",
".",
"g",
".",
"cluster",
"assignments",
"cluster",
"sizes",
")",
"of",
"the",
"model",
"trained",
"on",
"the",
"training",
"set",
".",
"An",
"exception",
"is",
"thrown",
"if",
"no",
"summary",
"exists",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/clustering.py#L522-L531 | [
"def",
"summary",
"(",
"self",
")",
":",
"if",
"self",
".",
"hasSummary",
":",
"return",
"BisectingKMeansSummary",
"(",
"super",
"(",
"BisectingKMeansModel",
",",
"self",
")",
".",
"summary",
")",
"else",
":",
"raise",
"RuntimeError",
"(",
"\"No training summa... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _ImageSchema.imageSchema | Returns the image schema.
:return: a :class:`StructType` with a single column of images
named "image" (nullable) and having the same type returned by :meth:`columnSchema`.
.. versionadded:: 2.3.0 | python/pyspark/ml/image.py | def imageSchema(self):
"""
Returns the image schema.
:return: a :class:`StructType` with a single column of images
named "image" (nullable) and having the same type returned by :meth:`columnSchema`.
.. versionadded:: 2.3.0
"""
if self._imageSchema is Non... | def imageSchema(self):
"""
Returns the image schema.
:return: a :class:`StructType` with a single column of images
named "image" (nullable) and having the same type returned by :meth:`columnSchema`.
.. versionadded:: 2.3.0
"""
if self._imageSchema is Non... | [
"Returns",
"the",
"image",
"schema",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L55-L69 | [
"def",
"imageSchema",
"(",
"self",
")",
":",
"if",
"self",
".",
"_imageSchema",
"is",
"None",
":",
"ctx",
"=",
"SparkContext",
".",
"_active_spark_context",
"jschema",
"=",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"ml",
".",
"i... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _ImageSchema.ocvTypes | Returns the OpenCV type mapping supported.
:return: a dictionary containing the OpenCV type mapping supported.
.. versionadded:: 2.3.0 | python/pyspark/ml/image.py | def ocvTypes(self):
"""
Returns the OpenCV type mapping supported.
:return: a dictionary containing the OpenCV type mapping supported.
.. versionadded:: 2.3.0
"""
if self._ocvTypes is None:
ctx = SparkContext._active_spark_context
self._ocvTypes... | def ocvTypes(self):
"""
Returns the OpenCV type mapping supported.
:return: a dictionary containing the OpenCV type mapping supported.
.. versionadded:: 2.3.0
"""
if self._ocvTypes is None:
ctx = SparkContext._active_spark_context
self._ocvTypes... | [
"Returns",
"the",
"OpenCV",
"type",
"mapping",
"supported",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L72-L84 | [
"def",
"ocvTypes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_ocvTypes",
"is",
"None",
":",
"ctx",
"=",
"SparkContext",
".",
"_active_spark_context",
"self",
".",
"_ocvTypes",
"=",
"dict",
"(",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spar... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _ImageSchema.columnSchema | Returns the schema for the image column.
:return: a :class:`StructType` for image column,
``struct<origin:string, height:int, width:int, nChannels:int, mode:int, data:binary>``.
.. versionadded:: 2.4.0 | python/pyspark/ml/image.py | def columnSchema(self):
"""
Returns the schema for the image column.
:return: a :class:`StructType` for image column,
``struct<origin:string, height:int, width:int, nChannels:int, mode:int, data:binary>``.
.. versionadded:: 2.4.0
"""
if self._columnSchema i... | def columnSchema(self):
"""
Returns the schema for the image column.
:return: a :class:`StructType` for image column,
``struct<origin:string, height:int, width:int, nChannels:int, mode:int, data:binary>``.
.. versionadded:: 2.4.0
"""
if self._columnSchema i... | [
"Returns",
"the",
"schema",
"for",
"the",
"image",
"column",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L87-L101 | [
"def",
"columnSchema",
"(",
"self",
")",
":",
"if",
"self",
".",
"_columnSchema",
"is",
"None",
":",
"ctx",
"=",
"SparkContext",
".",
"_active_spark_context",
"jschema",
"=",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"ml",
".",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _ImageSchema.imageFields | Returns field names of image columns.
:return: a list of field names.
.. versionadded:: 2.3.0 | python/pyspark/ml/image.py | def imageFields(self):
"""
Returns field names of image columns.
:return: a list of field names.
.. versionadded:: 2.3.0
"""
if self._imageFields is None:
ctx = SparkContext._active_spark_context
self._imageFields = list(ctx._jvm.org.apache.spar... | def imageFields(self):
"""
Returns field names of image columns.
:return: a list of field names.
.. versionadded:: 2.3.0
"""
if self._imageFields is None:
ctx = SparkContext._active_spark_context
self._imageFields = list(ctx._jvm.org.apache.spar... | [
"Returns",
"field",
"names",
"of",
"image",
"columns",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L104-L116 | [
"def",
"imageFields",
"(",
"self",
")",
":",
"if",
"self",
".",
"_imageFields",
"is",
"None",
":",
"ctx",
"=",
"SparkContext",
".",
"_active_spark_context",
"self",
".",
"_imageFields",
"=",
"list",
"(",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
"."... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _ImageSchema.undefinedImageType | Returns the name of undefined image type for the invalid image.
.. versionadded:: 2.3.0 | python/pyspark/ml/image.py | def undefinedImageType(self):
"""
Returns the name of undefined image type for the invalid image.
.. versionadded:: 2.3.0
"""
if self._undefinedImageType is None:
ctx = SparkContext._active_spark_context
self._undefinedImageType = \
ctx._... | def undefinedImageType(self):
"""
Returns the name of undefined image type for the invalid image.
.. versionadded:: 2.3.0
"""
if self._undefinedImageType is None:
ctx = SparkContext._active_spark_context
self._undefinedImageType = \
ctx._... | [
"Returns",
"the",
"name",
"of",
"undefined",
"image",
"type",
"for",
"the",
"invalid",
"image",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L119-L130 | [
"def",
"undefinedImageType",
"(",
"self",
")",
":",
"if",
"self",
".",
"_undefinedImageType",
"is",
"None",
":",
"ctx",
"=",
"SparkContext",
".",
"_active_spark_context",
"self",
".",
"_undefinedImageType",
"=",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _ImageSchema.toNDArray | Converts an image to an array with metadata.
:param `Row` image: A row that contains the image to be converted. It should
have the attributes specified in `ImageSchema.imageSchema`.
:return: a `numpy.ndarray` that is an image.
.. versionadded:: 2.3.0 | python/pyspark/ml/image.py | def toNDArray(self, image):
"""
Converts an image to an array with metadata.
:param `Row` image: A row that contains the image to be converted. It should
have the attributes specified in `ImageSchema.imageSchema`.
:return: a `numpy.ndarray` that is an image.
.. vers... | def toNDArray(self, image):
"""
Converts an image to an array with metadata.
:param `Row` image: A row that contains the image to be converted. It should
have the attributes specified in `ImageSchema.imageSchema`.
:return: a `numpy.ndarray` that is an image.
.. vers... | [
"Converts",
"an",
"image",
"to",
"an",
"array",
"with",
"metadata",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L132-L160 | [
"def",
"toNDArray",
"(",
"self",
",",
"image",
")",
":",
"if",
"not",
"isinstance",
"(",
"image",
",",
"Row",
")",
":",
"raise",
"TypeError",
"(",
"\"image argument should be pyspark.sql.types.Row; however, \"",
"\"it got [%s].\"",
"%",
"type",
"(",
"image",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _ImageSchema.toImage | Converts an array with metadata to a two-dimensional image.
:param `numpy.ndarray` array: The array to convert to image.
:param str origin: Path to the image, optional.
:return: a :class:`Row` that is a two dimensional image.
.. versionadded:: 2.3.0 | python/pyspark/ml/image.py | def toImage(self, array, origin=""):
"""
Converts an array with metadata to a two-dimensional image.
:param `numpy.ndarray` array: The array to convert to image.
:param str origin: Path to the image, optional.
:return: a :class:`Row` that is a two dimensional image.
.. ... | def toImage(self, array, origin=""):
"""
Converts an array with metadata to a two-dimensional image.
:param `numpy.ndarray` array: The array to convert to image.
:param str origin: Path to the image, optional.
:return: a :class:`Row` that is a two dimensional image.
.. ... | [
"Converts",
"an",
"array",
"with",
"metadata",
"to",
"a",
"two",
"-",
"dimensional",
"image",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L162-L204 | [
"def",
"toImage",
"(",
"self",
",",
"array",
",",
"origin",
"=",
"\"\"",
")",
":",
"if",
"not",
"isinstance",
"(",
"array",
",",
"np",
".",
"ndarray",
")",
":",
"raise",
"TypeError",
"(",
"\"array argument should be numpy.ndarray; however, it got [%s].\"",
"%",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _ImageSchema.readImages | Reads the directory of images from the local or remote source.
.. note:: If multiple jobs are run in parallel with different sampleRatio or recursive flag,
there may be a race condition where one job overwrites the hadoop configs of another.
.. note:: If sample ratio is less than 1, sampli... | python/pyspark/ml/image.py | def readImages(self, path, recursive=False, numPartitions=-1,
dropImageFailures=False, sampleRatio=1.0, seed=0):
"""
Reads the directory of images from the local or remote source.
.. note:: If multiple jobs are run in parallel with different sampleRatio or recursive flag,
... | def readImages(self, path, recursive=False, numPartitions=-1,
dropImageFailures=False, sampleRatio=1.0, seed=0):
"""
Reads the directory of images from the local or remote source.
.. note:: If multiple jobs are run in parallel with different sampleRatio or recursive flag,
... | [
"Reads",
"the",
"directory",
"of",
"images",
"from",
"the",
"local",
"or",
"remote",
"source",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L206-L242 | [
"def",
"readImages",
"(",
"self",
",",
"path",
",",
"recursive",
"=",
"False",
",",
"numPartitions",
"=",
"-",
"1",
",",
"dropImageFailures",
"=",
"False",
",",
"sampleRatio",
"=",
"1.0",
",",
"seed",
"=",
"0",
")",
":",
"warnings",
".",
"warn",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | JavaWrapper._create_from_java_class | Construct this object from given Java classname and arguments | python/pyspark/ml/wrapper.py | def _create_from_java_class(cls, java_class, *args):
"""
Construct this object from given Java classname and arguments
"""
java_obj = JavaWrapper._new_java_obj(java_class, *args)
return cls(java_obj) | def _create_from_java_class(cls, java_class, *args):
"""
Construct this object from given Java classname and arguments
"""
java_obj = JavaWrapper._new_java_obj(java_class, *args)
return cls(java_obj) | [
"Construct",
"this",
"object",
"from",
"given",
"Java",
"classname",
"and",
"arguments"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/wrapper.py#L44-L49 | [
"def",
"_create_from_java_class",
"(",
"cls",
",",
"java_class",
",",
"*",
"args",
")",
":",
"java_obj",
"=",
"JavaWrapper",
".",
"_new_java_obj",
"(",
"java_class",
",",
"*",
"args",
")",
"return",
"cls",
"(",
"java_obj",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | JavaWrapper._new_java_array | Create a Java array of given java_class type. Useful for
calling a method with a Scala Array from Python with Py4J.
If the param pylist is a 2D array, then a 2D java array will be returned.
The returned 2D java array is a square, non-jagged 2D array that is big
enough for all elements. T... | python/pyspark/ml/wrapper.py | def _new_java_array(pylist, java_class):
"""
Create a Java array of given java_class type. Useful for
calling a method with a Scala Array from Python with Py4J.
If the param pylist is a 2D array, then a 2D java array will be returned.
The returned 2D java array is a square, non-j... | def _new_java_array(pylist, java_class):
"""
Create a Java array of given java_class type. Useful for
calling a method with a Scala Array from Python with Py4J.
If the param pylist is a 2D array, then a 2D java array will be returned.
The returned 2D java array is a square, non-j... | [
"Create",
"a",
"Java",
"array",
"of",
"given",
"java_class",
"type",
".",
"Useful",
"for",
"calling",
"a",
"method",
"with",
"a",
"Scala",
"Array",
"from",
"Python",
"with",
"Py4J",
".",
"If",
"the",
"param",
"pylist",
"is",
"a",
"2D",
"array",
"then",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/wrapper.py#L70-L109 | [
"def",
"_new_java_array",
"(",
"pylist",
",",
"java_class",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"java_array",
"=",
"None",
"if",
"len",
"(",
"pylist",
")",
">",
"0",
"and",
"isinstance",
"(",
"pylist",
"[",
"0",
"]",
",",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _convert_epytext | >>> _convert_epytext("L{A}")
:class:`A` | python/docs/epytext.py | def _convert_epytext(line):
"""
>>> _convert_epytext("L{A}")
:class:`A`
"""
line = line.replace('@', ':')
for p, sub in RULES:
line = re.sub(p, sub, line)
return line | def _convert_epytext(line):
"""
>>> _convert_epytext("L{A}")
:class:`A`
"""
line = line.replace('@', ':')
for p, sub in RULES:
line = re.sub(p, sub, line)
return line | [
">>>",
"_convert_epytext",
"(",
"L",
"{",
"A",
"}",
")",
":",
"class",
":",
"A"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/docs/epytext.py#L13-L21 | [
"def",
"_convert_epytext",
"(",
"line",
")",
":",
"line",
"=",
"line",
".",
"replace",
"(",
"'@'",
",",
"':'",
")",
"for",
"p",
",",
"sub",
"in",
"RULES",
":",
"line",
"=",
"re",
".",
"sub",
"(",
"p",
",",
"sub",
",",
"line",
")",
"return",
"li... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | rddToFileName | Return string prefix-time(.suffix)
>>> rddToFileName("spark", None, 12345678910)
'spark-12345678910'
>>> rddToFileName("spark", "tmp", 12345678910)
'spark-12345678910.tmp' | python/pyspark/streaming/util.py | def rddToFileName(prefix, suffix, timestamp):
"""
Return string prefix-time(.suffix)
>>> rddToFileName("spark", None, 12345678910)
'spark-12345678910'
>>> rddToFileName("spark", "tmp", 12345678910)
'spark-12345678910.tmp'
"""
if isinstance(timestamp, datetime):
seconds = time.mk... | def rddToFileName(prefix, suffix, timestamp):
"""
Return string prefix-time(.suffix)
>>> rddToFileName("spark", None, 12345678910)
'spark-12345678910'
>>> rddToFileName("spark", "tmp", 12345678910)
'spark-12345678910.tmp'
"""
if isinstance(timestamp, datetime):
seconds = time.mk... | [
"Return",
"string",
"prefix",
"-",
"time",
"(",
".",
"suffix",
")"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/util.py#L138-L153 | [
"def",
"rddToFileName",
"(",
"prefix",
",",
"suffix",
",",
"timestamp",
")",
":",
"if",
"isinstance",
"(",
"timestamp",
",",
"datetime",
")",
":",
"seconds",
"=",
"time",
".",
"mktime",
"(",
"timestamp",
".",
"timetuple",
"(",
")",
")",
"timestamp",
"=",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | ProfilerCollector.add_profiler | Add a profiler for RDD `id` | python/pyspark/profiler.py | def add_profiler(self, id, profiler):
""" Add a profiler for RDD `id` """
if not self.profilers:
if self.profile_dump_path:
atexit.register(self.dump_profiles, self.profile_dump_path)
else:
atexit.register(self.show_profiles)
self.profiler... | def add_profiler(self, id, profiler):
""" Add a profiler for RDD `id` """
if not self.profilers:
if self.profile_dump_path:
atexit.register(self.dump_profiles, self.profile_dump_path)
else:
atexit.register(self.show_profiles)
self.profiler... | [
"Add",
"a",
"profiler",
"for",
"RDD",
"id"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/profiler.py#L43-L51 | [
"def",
"add_profiler",
"(",
"self",
",",
"id",
",",
"profiler",
")",
":",
"if",
"not",
"self",
".",
"profilers",
":",
"if",
"self",
".",
"profile_dump_path",
":",
"atexit",
".",
"register",
"(",
"self",
".",
"dump_profiles",
",",
"self",
".",
"profile_du... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | ProfilerCollector.dump_profiles | Dump the profile stats into directory `path` | python/pyspark/profiler.py | def dump_profiles(self, path):
""" Dump the profile stats into directory `path` """
for id, profiler, _ in self.profilers:
profiler.dump(id, path)
self.profilers = [] | def dump_profiles(self, path):
""" Dump the profile stats into directory `path` """
for id, profiler, _ in self.profilers:
profiler.dump(id, path)
self.profilers = [] | [
"Dump",
"the",
"profile",
"stats",
"into",
"directory",
"path"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/profiler.py#L53-L57 | [
"def",
"dump_profiles",
"(",
"self",
",",
"path",
")",
":",
"for",
"id",
",",
"profiler",
",",
"_",
"in",
"self",
".",
"profilers",
":",
"profiler",
".",
"dump",
"(",
"id",
",",
"path",
")",
"self",
".",
"profilers",
"=",
"[",
"]"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | ProfilerCollector.show_profiles | Print the profile stats to stdout | python/pyspark/profiler.py | def show_profiles(self):
""" Print the profile stats to stdout """
for i, (id, profiler, showed) in enumerate(self.profilers):
if not showed and profiler:
profiler.show(id)
# mark it as showed
self.profilers[i][2] = True | def show_profiles(self):
""" Print the profile stats to stdout """
for i, (id, profiler, showed) in enumerate(self.profilers):
if not showed and profiler:
profiler.show(id)
# mark it as showed
self.profilers[i][2] = True | [
"Print",
"the",
"profile",
"stats",
"to",
"stdout"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/profiler.py#L59-L65 | [
"def",
"show_profiles",
"(",
"self",
")",
":",
"for",
"i",
",",
"(",
"id",
",",
"profiler",
",",
"showed",
")",
"in",
"enumerate",
"(",
"self",
".",
"profilers",
")",
":",
"if",
"not",
"showed",
"and",
"profiler",
":",
"profiler",
".",
"show",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.