id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
19,200 | apache/spark | python/pyspark/sql/functions.py | sequence | def sequence(start, stop, step=None):
"""
Generate a sequence of integers from `start` to `stop`, incrementing by `step`.
If `step` is not set, incrementing by 1 if `start` is less than or equal to `stop`,
otherwise -1.
>>> df1 = spark.createDataFrame([(-2, 2)], ('C1', 'C2'))
>>> df1.select(seq... | python | def sequence(start, stop, step=None):
"""
Generate a sequence of integers from `start` to `stop`, incrementing by `step`.
If `step` is not set, incrementing by 1 if `start` is less than or equal to `stop`,
otherwise -1.
>>> df1 = spark.createDataFrame([(-2, 2)], ('C1', 'C2'))
>>> df1.select(seq... | [
"def",
"sequence",
"(",
"start",
",",
"stop",
",",
"step",
"=",
"None",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"step",
"is",
"None",
":",
"return",
"Column",
"(",
"sc",
".",
"_jvm",
".",
"functions",
".",
"sequence",
"... | Generate a sequence of integers from `start` to `stop`, incrementing by `step`.
If `step` is not set, incrementing by 1 if `start` is less than or equal to `stop`,
otherwise -1.
>>> df1 = spark.createDataFrame([(-2, 2)], ('C1', 'C2'))
>>> df1.select(sequence('C1', 'C2').alias('r')).collect()
[Row(r... | [
"Generate",
"a",
"sequence",
"of",
"integers",
"from",
"start",
"to",
"stop",
"incrementing",
"by",
"step",
".",
"If",
"step",
"is",
"not",
"set",
"incrementing",
"by",
"1",
"if",
"start",
"is",
"less",
"than",
"or",
"equal",
"to",
"stop",
"otherwise",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2739-L2757 |
19,201 | apache/spark | python/pyspark/sql/functions.py | from_csv | def from_csv(col, schema, options={}):
"""
Parses a column containing a CSV string to a row with the specified schema.
Returns `null`, in the case of an unparseable string.
:param col: string column in CSV format
:param schema: a string with schema in DDL format to use when parsing the CSV column.
... | python | def from_csv(col, schema, options={}):
"""
Parses a column containing a CSV string to a row with the specified schema.
Returns `null`, in the case of an unparseable string.
:param col: string column in CSV format
:param schema: a string with schema in DDL format to use when parsing the CSV column.
... | [
"def",
"from_csv",
"(",
"col",
",",
"schema",
",",
"options",
"=",
"{",
"}",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"if",
"isinstance",
"(",
"schema",
",",
"basestring",
")",
":",
"schema",
"=",
"_create_column_from_literal",
"(",... | Parses a column containing a CSV string to a row with the specified schema.
Returns `null`, in the case of an unparseable string.
:param col: string column in CSV format
:param schema: a string with schema in DDL format to use when parsing the CSV column.
:param options: options to control parsing. acc... | [
"Parses",
"a",
"column",
"containing",
"a",
"CSV",
"string",
"to",
"a",
"row",
"with",
"the",
"specified",
"schema",
".",
"Returns",
"null",
"in",
"the",
"case",
"of",
"an",
"unparseable",
"string",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L2762-L2789 |
19,202 | apache/spark | python/pyspark/sql/readwriter.py | DataFrameReader.format | def format(self, source):
"""Specifies the input data source format.
:param source: string, name of the data source, e.g. 'json', 'parquet'.
>>> df = spark.read.format('json').load('python/test_support/sql/people.json')
>>> df.dtypes
[('age', 'bigint'), ('name', 'string')]
... | python | def format(self, source):
"""Specifies the input data source format.
:param source: string, name of the data source, e.g. 'json', 'parquet'.
>>> df = spark.read.format('json').load('python/test_support/sql/people.json')
>>> df.dtypes
[('age', 'bigint'), ('name', 'string')]
... | [
"def",
"format",
"(",
"self",
",",
"source",
")",
":",
"self",
".",
"_jreader",
"=",
"self",
".",
"_jreader",
".",
"format",
"(",
"source",
")",
"return",
"self"
] | Specifies the input data source format.
:param source: string, name of the data source, e.g. 'json', 'parquet'.
>>> df = spark.read.format('json').load('python/test_support/sql/people.json')
>>> df.dtypes
[('age', 'bigint'), ('name', 'string')] | [
"Specifies",
"the",
"input",
"data",
"source",
"format",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L78-L89 |
19,203 | apache/spark | python/pyspark/sql/readwriter.py | DataFrameReader.schema | def schema(self, schema):
"""Specifies the input schema.
Some data sources (e.g. JSON) can infer the input schema automatically from data.
By specifying the schema here, the underlying data source can skip the schema
inference step, and thus speed up data loading.
:param schema... | python | def schema(self, schema):
"""Specifies the input schema.
Some data sources (e.g. JSON) can infer the input schema automatically from data.
By specifying the schema here, the underlying data source can skip the schema
inference step, and thus speed up data loading.
:param schema... | [
"def",
"schema",
"(",
"self",
",",
"schema",
")",
":",
"from",
"pyspark",
".",
"sql",
"import",
"SparkSession",
"spark",
"=",
"SparkSession",
".",
"builder",
".",
"getOrCreate",
"(",
")",
"if",
"isinstance",
"(",
"schema",
",",
"StructType",
")",
":",
"j... | Specifies the input schema.
Some data sources (e.g. JSON) can infer the input schema automatically from data.
By specifying the schema here, the underlying data source can skip the schema
inference step, and thus speed up data loading.
:param schema: a :class:`pyspark.sql.types.StructT... | [
"Specifies",
"the",
"input",
"schema",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L92-L113 |
19,204 | apache/spark | python/pyspark/sql/readwriter.py | DataFrameReader.option | def option(self, key, value):
"""Adds an input option for the underlying data source.
You can set the following option(s) for reading files:
* ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps
in the JSON/CSV datasources or partition valu... | python | def option(self, key, value):
"""Adds an input option for the underlying data source.
You can set the following option(s) for reading files:
* ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps
in the JSON/CSV datasources or partition valu... | [
"def",
"option",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"_jreader",
"=",
"self",
".",
"_jreader",
".",
"option",
"(",
"key",
",",
"to_str",
"(",
"value",
")",
")",
"return",
"self"
] | Adds an input option for the underlying data source.
You can set the following option(s) for reading files:
* ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps
in the JSON/CSV datasources or partition values.
If it isn't set, it u... | [
"Adds",
"an",
"input",
"option",
"for",
"the",
"underlying",
"data",
"source",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L116-L125 |
19,205 | apache/spark | python/pyspark/sql/readwriter.py | DataFrameReader.options | def options(self, **options):
"""Adds input options for the underlying data source.
You can set the following option(s) for reading files:
* ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps
in the JSON/CSV datasources or partition values... | python | def options(self, **options):
"""Adds input options for the underlying data source.
You can set the following option(s) for reading files:
* ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps
in the JSON/CSV datasources or partition values... | [
"def",
"options",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"for",
"k",
"in",
"options",
":",
"self",
".",
"_jreader",
"=",
"self",
".",
"_jreader",
".",
"option",
"(",
"k",
",",
"to_str",
"(",
"options",
"[",
"k",
"]",
")",
")",
"return",... | Adds input options for the underlying data source.
You can set the following option(s) for reading files:
* ``timeZone``: sets the string that indicates a timezone to be used to parse timestamps
in the JSON/CSV datasources or partition values.
If it isn't set, it use... | [
"Adds",
"input",
"options",
"for",
"the",
"underlying",
"data",
"source",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L128-L138 |
19,206 | apache/spark | python/pyspark/sql/readwriter.py | DataFrameWriter.mode | def mode(self, saveMode):
"""Specifies the behavior when data or table already exists.
Options include:
* `append`: Append contents of this :class:`DataFrame` to existing data.
* `overwrite`: Overwrite existing data.
* `error` or `errorifexists`: Throw an exception if data alre... | python | def mode(self, saveMode):
"""Specifies the behavior when data or table already exists.
Options include:
* `append`: Append contents of this :class:`DataFrame` to existing data.
* `overwrite`: Overwrite existing data.
* `error` or `errorifexists`: Throw an exception if data alre... | [
"def",
"mode",
"(",
"self",
",",
"saveMode",
")",
":",
"# At the JVM side, the default value of mode is already set to \"error\".",
"# So, if the given saveMode is None, we will not call JVM-side's mode method.",
"if",
"saveMode",
"is",
"not",
"None",
":",
"self",
".",
"_jwrite",... | Specifies the behavior when data or table already exists.
Options include:
* `append`: Append contents of this :class:`DataFrame` to existing data.
* `overwrite`: Overwrite existing data.
* `error` or `errorifexists`: Throw an exception if data already exists.
* `ignore`: Silen... | [
"Specifies",
"the",
"behavior",
"when",
"data",
"or",
"table",
"already",
"exists",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L590-L606 |
19,207 | apache/spark | python/pyspark/sql/readwriter.py | DataFrameWriter.format | def format(self, source):
"""Specifies the underlying output data source.
:param source: string, name of the data source, e.g. 'json', 'parquet'.
>>> df.write.format('json').save(os.path.join(tempfile.mkdtemp(), 'data'))
"""
self._jwrite = self._jwrite.format(source)
re... | python | def format(self, source):
"""Specifies the underlying output data source.
:param source: string, name of the data source, e.g. 'json', 'parquet'.
>>> df.write.format('json').save(os.path.join(tempfile.mkdtemp(), 'data'))
"""
self._jwrite = self._jwrite.format(source)
re... | [
"def",
"format",
"(",
"self",
",",
"source",
")",
":",
"self",
".",
"_jwrite",
"=",
"self",
".",
"_jwrite",
".",
"format",
"(",
"source",
")",
"return",
"self"
] | Specifies the underlying output data source.
:param source: string, name of the data source, e.g. 'json', 'parquet'.
>>> df.write.format('json').save(os.path.join(tempfile.mkdtemp(), 'data')) | [
"Specifies",
"the",
"underlying",
"output",
"data",
"source",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L609-L617 |
19,208 | apache/spark | python/pyspark/sql/readwriter.py | DataFrameWriter.option | def option(self, key, value):
"""Adds an output option 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 va... | python | def option(self, key, value):
"""Adds an output option 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 va... | [
"def",
"option",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"_jwrite",
"=",
"self",
".",
"_jwrite",
".",
"option",
"(",
"key",
",",
"to_str",
"(",
"value",
")",
")",
"return",
"self"
] | Adds an output option 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... | [
"Adds",
"an",
"output",
"option",
"for",
"the",
"underlying",
"data",
"source",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L620-L629 |
19,209 | apache/spark | python/pyspark/sql/readwriter.py | DataFrameWriter.options | 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... | python | 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",
")",
":",
"for",
"k",
"in",
"options",
":",
"self",
".",
"_jwrite",
"=",
"self",
".",
"_jwrite",
".",
"option",
"(",
"k",
",",
"to_str",
"(",
"options",
"[",
"k",
"]",
")",
")",
"return",
... | 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... | [
"Adds",
"output",
"options",
"for",
"the",
"underlying",
"data",
"source",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L632-L642 |
19,210 | apache/spark | python/pyspark/sql/readwriter.py | DataFrameWriter.partitionBy | 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... | python | 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",
")",
":",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
"and",
"isinstance",
"(",
"cols",
"[",
"0",
"]",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"cols",
"=",
"cols",
"[",
"0",
"]",
"self... | 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')) | [
"Partitions",
"the",
"output",
"by",
"the",
"given",
"columns",
"on",
"the",
"file",
"system",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L645-L658 |
19,211 | apache/spark | python/pyspark/sql/readwriter.py | DataFrameWriter.sortBy | 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... | python | 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",
")",
":",
"if",
"isinstance",
"(",
"col",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"if",
"cols",
":",
"raise",
"ValueError",
"(",
"\"col is a {0} but cols are not empty\"",
".",
"format",
... | 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',... | [
"Sorts",
"the",
"output",
"in",
"each",
"bucket",
"by",
"the",
"given",
"columns",
"on",
"the",
"file",
"system",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L693-L715 |
19,212 | apache/spark | python/pyspark/sql/readwriter.py | DataFrameWriter.text | 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... | python | 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",
")",
":",
"self",
".",
"_set_opts",
"(",
"compression",
"=",
"compression",
",",
"lineSep",
"=",
"lineSep",
")",
"self",
".",
"_jwrite",
".",
"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 ... | [
"Saves",
"the",
"content",
"of",
"the",
"DataFrame",
"in",
"a",
"text",
"file",
"at",
"the",
"specified",
"path",
".",
"The",
"text",
"files",
"will",
"be",
"encoded",
"as",
"UTF",
"-",
"8",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/readwriter.py#L856-L871 |
19,213 | apache/spark | dev/merge_spark_pr.py | choose_jira_assignee | 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:... | python | 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",
")",
":",
"while",
"True",
":",
"try",
":",
"reporter",
"=",
"issue",
".",
"fields",
".",
"reporter",
"commentors",
"=",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"author",
",",
"issue",
"."... | 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 | [
"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"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/dev/merge_spark_pr.py#L325-L362 |
19,214 | apache/spark | python/pyspark/mllib/util.py | MLUtils._convert_labeled_point_to_libsvm | 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... | python | 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",
")",
":",
"from",
"pyspark",
".",
"mllib",
".",
"regression",
"import",
"LabeledPoint",
"assert",
"isinstance",
"(",
"p",
",",
"LabeledPoint",
")",
"items",
"=",
"[",
"str",
"(",
"p",
".",
"label",
")",
... | Converts a LabeledPoint to a string in LIBSVM format. | [
"Converts",
"a",
"LabeledPoint",
"to",
"a",
"string",
"in",
"LIBSVM",
"format",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L56-L69 |
19,215 | apache/spark | python/pyspark/mllib/util.py | MLUtils.saveAsLibSVMFile | 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... | python | 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",
")",
":",
"lines",
"=",
"data",
".",
"map",
"(",
"lambda",
"p",
":",
"MLUtils",
".",
"_convert_labeled_point_to_libsvm",
"(",
"p",
")",
")",
"lines",
".",
"saveAsTextFile",
"(",
"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.regression import LabeledPoint
>>> from glob imp... | [
"Save",
"labeled",
"data",
"in",
"LIBSVM",
"format",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L126-L147 |
19,216 | apache/spark | python/pyspark/mllib/util.py | MLUtils.loadLabeledPoints | 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
... | python | 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",
")",
":",
"minPartitions",
"=",
"minPartitions",
"or",
"min",
"(",
"sc",
".",
"defaultParallelism",
",",
"2",
")",
"return",
"callMLlibFunc",
"(",
"\"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
>>... | [
"Load",
"labeled",
"points",
"saved",
"using",
"RDD",
".",
"saveAsTextFile",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L151-L173 |
19,217 | apache/spark | python/pyspark/mllib/util.py | LinearDataGenerator.generateLinearRDD | 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(... | python | 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",
")",
":",
"return",
"callMLlibFunc",
"(",
"\"generateLinearRDDWrapper\"",
",",
"sc",
",",
"int",
"(",
"nexamples",
... | Generate an RDD of LabeledPoints. | [
"Generate",
"an",
"RDD",
"of",
"LabeledPoints",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/util.py#L494-L501 |
19,218 | apache/spark | python/pyspark/mllib/regression.py | IsotonicRegressionModel.save | 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... | python | 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",
")",
":",
"java_boundaries",
"=",
"_py2java",
"(",
"sc",
",",
"self",
".",
"boundaries",
".",
"tolist",
"(",
")",
")",
"java_predictions",
"=",
"_py2java",
"(",
"sc",
",",
"self",
".",
"predictions",
... | Save an IsotonicRegressionModel. | [
"Save",
"an",
"IsotonicRegressionModel",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/regression.py#L654-L660 |
19,219 | apache/spark | python/pyspark/mllib/regression.py | IsotonicRegressionModel.load | 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... | python | 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",
")",
":",
"java_model",
"=",
"sc",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"mllib",
".",
"regression",
".",
"IsotonicRegressionModel",
".",
"load",
"(",
"sc",
".",
"_jsc",
".",
"... | Load an IsotonicRegressionModel. | [
"Load",
"an",
"IsotonicRegressionModel",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/regression.py#L664-L670 |
19,220 | apache/spark | python/pyspark/mllib/regression.py | IsotonicRegression.train | 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)
"""
... | python | 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",
")",
":",
"boundaries",
",",
"predictions",
"=",
"callMLlibFunc",
"(",
"\"trainIsotonicRegressionModel\"",
",",
"data",
".",
"map",
"(",
"_convert_to_vector",
")",
",",
"bool",
"(",
"isot... | 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",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/regression.py#L699-L711 |
19,221 | apache/spark | python/pyspark/mllib/linalg/distributed.py | RowMatrix.columnSimilarities | 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... | python | 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",
")",
":",
"java_sims_mat",
"=",
"self",
".",
"_java_matrix_wrapper",
".",
"call",
"(",
"\"columnSimilarities\"",
",",
"float",
"(",
"threshold",
")",
")",
"return",
"CoordinateMatrix",
"(",
... | 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... | [
"Compute",
"similarities",
"between",
"columns",
"of",
"this",
"matrix",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L201-L260 |
19,222 | apache/spark | python/pyspark/mllib/linalg/distributed.py | RowMatrix.tallSkinnyQR | 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... | python | 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",
")",
":",
"decomp",
"=",
"JavaModelWrapper",
"(",
"self",
".",
"_java_matrix_wrapper",
".",
"call",
"(",
"\"tallSkinnyQR\"",
",",
"computeQ",
")",
")",
"if",
"computeQ",
":",
"java_Q",
"=",
... | 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... | [
"Compute",
"the",
"QR",
"decomposition",
"of",
"this",
"RowMatrix",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L263-L301 |
19,223 | apache/spark | python/pyspark/mllib/linalg/distributed.py | RowMatrix.computeSVD | 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... | python | 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",
")",
":",
"j_model",
"=",
"self",
".",
"_java_matrix_wrapper",
".",
"call",
"(",
"\"computeSVD\"",
",",
"int",
"(",
"k",
")",
",",
"bool",
"(",
"com... | 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... | [
"Computes",
"the",
"singular",
"value",
"decomposition",
"of",
"the",
"RowMatrix",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L304-L345 |
19,224 | apache/spark | python/pyspark/mllib/linalg/distributed.py | SingularValueDecomposition.U | 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... | python | 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",
")",
":",
"u",
"=",
"self",
".",
"call",
"(",
"\"U\"",
")",
"if",
"u",
"is",
"not",
"None",
":",
"mat_name",
"=",
"u",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"if",
"mat_name",
"==",
"\"RowMatrix\"",
":... | Returns a distributed matrix whose columns are the left
singular vectors of the SingularValueDecomposition if computeU was set to be True. | [
"Returns",
"a",
"distributed",
"matrix",
"whose",
"columns",
"are",
"the",
"left",
"singular",
"vectors",
"of",
"the",
"SingularValueDecomposition",
"if",
"computeU",
"was",
"set",
"to",
"be",
"True",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L401-L414 |
19,225 | apache/spark | python/pyspark/mllib/linalg/distributed.py | IndexedRowMatrix.rows | 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... | python | 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",
")",
":",
"# 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... | 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]) | [
"Rows",
"of",
"the",
"IndexedRowMatrix",
"stored",
"as",
"an",
"RDD",
"of",
"IndexedRows",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L519-L535 |
19,226 | apache/spark | python/pyspark/mllib/linalg/distributed.py | IndexedRowMatrix.toBlockMatrix | 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... | python | 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",
")",
":",
"java_block_matrix",
"=",
"self",
".",
"_java_matrix_wrapper",
".",
"call",
"(",
"\"toBlockMatrix\"",
",",
"rowsPerBlock",
",",
"colsPerBlock",
")"... | 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... | [
"Convert",
"this",
"matrix",
"to",
"a",
"BlockMatrix",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L631-L658 |
19,227 | apache/spark | python/pyspark/mllib/linalg/distributed.py | CoordinateMatrix.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... | python | 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",
")",
":",
"# 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",... | 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) | [
"Entries",
"of",
"the",
"CoordinateMatrix",
"stored",
"as",
"an",
"RDD",
"of",
"MatrixEntries",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L811-L828 |
19,228 | apache/spark | python/pyspark/mllib/linalg/distributed.py | BlockMatrix.persist | 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_... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"storageLevel",
",",
"StorageLevel",
")",
":",
"raise",
"TypeError",
"(",
"\"`storageLevel` should be a StorageLevel, got %s\"",
"%",
"type",
"(",
"storageLevel",
")",
")... | Persists the underlying RDD with the specified storage level. | [
"Persists",
"the",
"underlying",
"RDD",
"with",
"the",
"specified",
"storage",
"level",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L1168-L1176 |
19,229 | apache/spark | python/pyspark/mllib/linalg/distributed.py | BlockMatrix.add | 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... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"BlockMatrix",
")",
":",
"raise",
"TypeError",
"(",
"\"Other should be a BlockMatrix, got %s\"",
"%",
"type",
"(",
"other",
")",
")",
"other_java_block_matrix",
"=... | 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... | [
"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... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L1186-L1217 |
19,230 | apache/spark | python/pyspark/mllib/linalg/distributed.py | BlockMatrix.transpose | 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,... | python | 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",
")",
":",
"java_transposed_matrix",
"=",
"self",
".",
"_java_matrix_wrapper",
".",
"call",
"(",
"\"transpose\"",
")",
"return",
"BlockMatrix",
"(",
"java_transposed_matrix",
",",
"self",
".",
"colsPerBlock",
",",
"self",
".",
"ro... | 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]))])
>>>... | [
"Transpose",
"this",
"BlockMatrix",
".",
"Returns",
"a",
"new",
"BlockMatrix",
"instance",
"sharing",
"the",
"same",
"underlying",
"data",
".",
"Is",
"a",
"lazy",
"operation",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L1290-L1304 |
19,231 | apache/spark | python/pyspark/mllib/linalg/__init__.py | _vector_size | 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... | python | 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",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"Vector",
")",
":",
"return",
"len",
"(",
"v",
")",
"elif",
"type",
"(",
"v",
")",
"in",
"(",
"array",
".",
"array",
",",
"list",
",",
"tuple",
",",
"xrange",
")",
":... | 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... | [
"Returns",
"the",
"size",
"of",
"the",
"vector",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L86-L118 |
19,232 | apache/spark | python/pyspark/mllib/linalg/__init__.py | DenseVector.parse | 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 '['.")
... | python | 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",
")",
":",
"start",
"=",
"s",
".",
"find",
"(",
"'['",
")",
"if",
"start",
"==",
"-",
"1",
":",
"raise",
"ValueError",
"(",
"\"Array should start with '['.\"",
")",
"end",
"=",
"s",
".",
"find",
"(",
"']'",
")",
"if",
"end"... | 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]) | [
"Parse",
"string",
"representation",
"back",
"into",
"the",
"DenseVector",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L297-L316 |
19,233 | apache/spark | python/pyspark/mllib/linalg/__init__.py | DenseVector.squared_distance | 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... | python | 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",
")",
":",
"assert",
"len",
"(",
"self",
")",
"==",
"_vector_size",
"(",
"other",
")",
",",
"\"dimension mismatch\"",
"if",
"isinstance",
"(",
"other",
",",
"SparseVector",
")",
":",
"return",
"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 = [2., 1.]
>>> dense1.squared_distance(dense3)... | [
"Squared",
"distance",
"of",
"two",
"Vectors",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L382-L418 |
19,234 | apache/spark | python/pyspark/mllib/linalg/__init__.py | SparseVector.parse | 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 '('")
... | python | 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",
")",
":",
"start",
"=",
"s",
".",
"find",
"(",
"'('",
")",
"if",
"start",
"==",
"-",
"1",
":",
"raise",
"ValueError",
"(",
"\"Tuple should start with '('\"",
")",
"end",
"=",
"s",
".",
"find",
"(",
"')'",
")",
"if",
"end",... | Parse string representation back into the SparseVector.
>>> SparseVector.parse(' (4, [0,1 ],[ 4.0,5.0] )')
SparseVector(4, {0: 4.0, 1: 5.0}) | [
"Parse",
"string",
"representation",
"back",
"into",
"the",
"SparseVector",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L589-L635 |
19,235 | apache/spark | python/pyspark/mllib/linalg/__init__.py | SparseVector.dot | 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])
>>> ... | python | 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",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"np",
".",
"ndarray",
")",
":",
"if",
"other",
".",
"ndim",
"not",
"in",
"[",
"2",
",",
"1",
"]",
":",
"raise",
"ValueError",
"(",
"\"Cannot call dot with %d-di... | 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.... | [
"Dot",
"product",
"with",
"a",
"SparseVector",
"or",
"1",
"-",
"or",
"2",
"-",
"dimensional",
"Numpy",
"array",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L637-L691 |
19,236 | apache/spark | python/pyspark/mllib/linalg/__init__.py | SparseVector.squared_distance | 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... | python | 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",
")",
":",
"assert",
"len",
"(",
"self",
")",
"==",
"_vector_size",
"(",
"other",
")",
",",
"\"dimension mismatch\"",
"if",
"isinstance",
"(",
"other",
",",
"np",
".",
"ndarray",
")",
"or",
"isinstance",... | 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
... | [
"Squared",
"distance",
"from",
"a",
"SparseVector",
"or",
"1",
"-",
"dimensional",
"NumPy",
"array",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L693-L758 |
19,237 | apache/spark | python/pyspark/mllib/linalg/__init__.py | SparseVector.toArray | 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 | python | 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",
")",
":",
"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. | [
"Returns",
"a",
"copy",
"of",
"this",
"SparseVector",
"as",
"a",
"1",
"-",
"dimensional",
"NumPy",
"array",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L760-L766 |
19,238 | apache/spark | python/pyspark/mllib/linalg/__init__.py | SparseVector.asML | 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... | python | 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",
")",
":",
"return",
"newlinalg",
".",
"SparseVector",
"(",
"self",
".",
"size",
",",
"self",
".",
"indices",
",",
"self",
".",
"values",
")"
] | 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 | [
"Convert",
"this",
"vector",
"to",
"the",
"new",
"mllib",
"-",
"local",
"representation",
".",
"This",
"does",
"NOT",
"copy",
"the",
"data",
";",
"it",
"copies",
"references",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L768-L777 |
19,239 | apache/spark | python/pyspark/mllib/linalg/__init__.py | Vectors.dense | 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... | python | 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",
")",
":",
"if",
"len",
"(",
"elements",
")",
"==",
"1",
"and",
"not",
"isinstance",
"(",
"elements",
"[",
"0",
"]",
",",
"(",
"float",
",",
"int",
",",
"long",
")",
")",
":",
"# it's list, numpy.array or other iter... | 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]) | [
"Create",
"a",
"dense",
"vector",
"of",
"64",
"-",
"bit",
"floats",
"from",
"a",
"Python",
"list",
"or",
"numbers",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L874-L886 |
19,240 | apache/spark | python/pyspark/mllib/linalg/__init__.py | Vectors.fromML | 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
"""
... | python | 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",
")",
":",
"if",
"isinstance",
"(",
"vec",
",",
"newlinalg",
".",
"DenseVector",
")",
":",
"return",
"DenseVector",
"(",
"vec",
".",
"array",
")",
"elif",
"isinstance",
"(",
"vec",
",",
"newlinalg",
".",
"SparseVector",
")",
... | 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",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L889-L904 |
19,241 | apache/spark | python/pyspark/mllib/linalg/__init__.py | Vectors.squared_distance | 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)
... | python | 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",
")",
":",
"v1",
",",
"v2",
"=",
"_convert_to_vector",
"(",
"v1",
")",
",",
"_convert_to_vector",
"(",
"v2",
")",
"return",
"v1",
".",
"squared_distance",
"(",
"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)
51.0 | [
"Squared",
"distance",
"between",
"two",
"vectors",
".",
"a",
"and",
"b",
"can",
"be",
"of",
"type",
"SparseVector",
"DenseVector",
"np",
".",
"ndarray",
"or",
"array",
".",
"array",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L920-L932 |
19,242 | apache/spark | python/pyspark/mllib/linalg/__init__.py | Vectors.parse | 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... | python | 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",
")",
":",
"if",
"s",
".",
"find",
"(",
"'('",
")",
"==",
"-",
"1",
"and",
"s",
".",
"find",
"(",
"'['",
")",
"!=",
"-",
"1",
":",
"return",
"DenseVector",
".",
"parse",
"(",
"s",
")",
"elif",
"s",
".",
"find",
"(",... | 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}) | [
"Parse",
"a",
"string",
"representation",
"back",
"into",
"the",
"Vector",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L942-L956 |
19,243 | apache/spark | python/pyspark/mllib/linalg/__init__.py | Matrix._convert_to_array | 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) | python | 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",
")",
":",
"if",
"isinstance",
"(",
"array_like",
",",
"bytes",
")",
":",
"return",
"np",
".",
"frombuffer",
"(",
"array_like",
",",
"dtype",
"=",
"dtype",
")",
"return",
"np",
".",
"asarray",
"... | Convert Matrix attributes which are array-like or buffer to array. | [
"Convert",
"Matrix",
"attributes",
"which",
"are",
"array",
"-",
"like",
"or",
"buffer",
"to",
"array",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1014-L1020 |
19,244 | apache/spark | python/pyspark/mllib/linalg/__init__.py | DenseMatrix.toSparse | 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.... | python | 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",
")",
":",
"if",
"self",
".",
"isTransposed",
":",
"values",
"=",
"np",
".",
"ravel",
"(",
"self",
".",
"toArray",
"(",
")",
",",
"order",
"=",
"'F'",
")",
"else",
":",
"values",
"=",
"self",
".",
"values",
"indices",... | Convert to SparseMatrix | [
"Convert",
"to",
"SparseMatrix"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1097-L1110 |
19,245 | apache/spark | python/pyspark/mllib/linalg/__init__.py | Matrices.sparse | def sparse(numRows, numCols, colPtrs, rowIndices, values):
"""
Create a SparseMatrix
"""
return SparseMatrix(numRows, numCols, colPtrs, rowIndices, values) | python | def sparse(numRows, numCols, colPtrs, rowIndices, values):
"""
Create a SparseMatrix
"""
return SparseMatrix(numRows, numCols, colPtrs, rowIndices, values) | [
"def",
"sparse",
"(",
"numRows",
",",
"numCols",
",",
"colPtrs",
",",
"rowIndices",
",",
"values",
")",
":",
"return",
"SparseMatrix",
"(",
"numRows",
",",
"numCols",
",",
"colPtrs",
",",
"rowIndices",
",",
"values",
")"
] | Create a SparseMatrix | [
"Create",
"a",
"SparseMatrix"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1321-L1325 |
19,246 | apache/spark | python/pyspark/mllib/linalg/__init__.py | Matrices.fromML | 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
"""
... | python | 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",
")",
":",
"if",
"isinstance",
"(",
"mat",
",",
"newlinalg",
".",
"DenseMatrix",
")",
":",
"return",
"DenseMatrix",
"(",
"mat",
".",
"numRows",
",",
"mat",
".",
"numCols",
",",
"mat",
".",
"values",
",",
"mat",
".",
"isTra... | 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",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/__init__.py#L1328-L1344 |
19,247 | apache/spark | python/pyspark/ml/feature.py | StringIndexerModel.from_labels | 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
... | python | 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",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"java_class",
"=",
"sc",
".",
"_gateway",
".",
"jvm",
"."... | Construct the model directly from an array of label strings,
requires an active SparkContext. | [
"Construct",
"the",
"model",
"directly",
"from",
"an",
"array",
"of",
"label",
"strings",
"requires",
"an",
"active",
"SparkContext",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/feature.py#L2503-L2518 |
19,248 | apache/spark | python/pyspark/ml/feature.py | StringIndexerModel.from_arrays_of_labels | 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
... | python | 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",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"java_class",
"=",
"sc",
".",
"_gateway",
... | Construct the model directly from an array of array of label strings,
requires an active SparkContext. | [
"Construct",
"the",
"model",
"directly",
"from",
"an",
"array",
"of",
"array",
"of",
"label",
"strings",
"requires",
"an",
"active",
"SparkContext",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/feature.py#L2522-L2538 |
19,249 | apache/spark | python/pyspark/sql/utils.py | install_exception_handler | 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... | python | 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",
"(",
")",
":",
"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 ... | 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... | [
"Hook",
"an",
"exception",
"handler",
"into",
"Py4j",
"which",
"could",
"capture",
"some",
"SQL",
"exceptions",
"in",
"Java",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/utils.py#L99-L114 |
19,250 | apache/spark | python/pyspark/sql/utils.py | require_minimum_pandas_version | 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
... | python | 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",
"(",
")",
":",
"# TODO(HyukjinKwon): Relocate and deduplicate the version specification.",
"minimum_pandas_version",
"=",
"\"0.19.2\"",
"from",
"distutils",
".",
"version",
"import",
"LooseVersion",
"try",
":",
"import",
"pandas",
"have_... | Raise ImportError if minimum version of Pandas is not installed | [
"Raise",
"ImportError",
"if",
"minimum",
"version",
"of",
"Pandas",
"is",
"not",
"installed"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/utils.py#L130-L147 |
19,251 | apache/spark | python/pyspark/sql/utils.py | require_minimum_pyarrow_version | 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
... | python | 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",
"(",
")",
":",
"# TODO(HyukjinKwon): Relocate and deduplicate the version specification.",
"minimum_pyarrow_version",
"=",
"\"0.12.1\"",
"from",
"distutils",
".",
"version",
"import",
"LooseVersion",
"try",
":",
"import",
"pyarrow",
"ha... | Raise ImportError if minimum version of pyarrow is not installed | [
"Raise",
"ImportError",
"if",
"minimum",
"version",
"of",
"pyarrow",
"is",
"not",
"installed"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/utils.py#L150-L167 |
19,252 | apache/spark | python/pyspark/java_gateway.py | _do_server_auth | 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":
... | python | 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",
")",
":",
"write_with_length",
"(",
"auth_secret",
".",
"encode",
"(",
"\"utf-8\"",
")",
",",
"conn",
")",
"conn",
".",
"flush",
"(",
")",
"reply",
"=",
"UTF8Deserializer",
"(",
")",
".",
"loads",
... | Performs the authentication protocol defined by the SocketAuthHelper class on the given
file-like object 'conn'. | [
"Performs",
"the",
"authentication",
"protocol",
"defined",
"by",
"the",
"SocketAuthHelper",
"class",
"on",
"the",
"given",
"file",
"-",
"like",
"object",
"conn",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/java_gateway.py#L150-L160 |
19,253 | apache/spark | python/pyspark/java_gateway.py | ensure_callback_server_started | 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... | python | 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",
")",
":",
"# 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... | 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. | [
"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",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/java_gateway.py#L192-L212 |
19,254 | apache/spark | python/pyspark/find_spark_home.py | _find_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"""
... | python | 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",
"(",
")",
":",
"# 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",
")",
":",
"\"\"... | Find the SPARK_HOME. | [
"Find",
"the",
"SPARK_HOME",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/find_spark_home.py#L28-L71 |
19,255 | apache/spark | examples/src/main/python/pagerank.py | computeContribs | 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) | python | 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",
")",
":",
"num_urls",
"=",
"len",
"(",
"urls",
")",
"for",
"url",
"in",
"urls",
":",
"yield",
"(",
"url",
",",
"rank",
"/",
"num_urls",
")"
] | Calculates URL contributions to the rank of other URLs. | [
"Calculates",
"URL",
"contributions",
"to",
"the",
"rank",
"of",
"other",
"URLs",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/examples/src/main/python/pagerank.py#L34-L38 |
19,256 | apache/spark | python/pyspark/ml/image.py | _ImageSchema.imageSchema | 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... | python | 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",
")",
":",
"if",
"self",
".",
"_imageSchema",
"is",
"None",
":",
"ctx",
"=",
"SparkContext",
".",
"_active_spark_context",
"jschema",
"=",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"ml",
".",
"i... | 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 | [
"Returns",
"the",
"image",
"schema",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L55-L69 |
19,257 | apache/spark | python/pyspark/ml/image.py | _ImageSchema.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... | python | 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",
")",
":",
"if",
"self",
".",
"_ocvTypes",
"is",
"None",
":",
"ctx",
"=",
"SparkContext",
".",
"_active_spark_context",
"self",
".",
"_ocvTypes",
"=",
"dict",
"(",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spar... | Returns the OpenCV type mapping supported.
:return: a dictionary containing the OpenCV type mapping supported.
.. versionadded:: 2.3.0 | [
"Returns",
"the",
"OpenCV",
"type",
"mapping",
"supported",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L72-L84 |
19,258 | apache/spark | python/pyspark/ml/image.py | _ImageSchema.columnSchema | 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... | python | 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",
")",
":",
"if",
"self",
".",
"_columnSchema",
"is",
"None",
":",
"ctx",
"=",
"SparkContext",
".",
"_active_spark_context",
"jschema",
"=",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"ml",
".",
... | 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 | [
"Returns",
"the",
"schema",
"for",
"the",
"image",
"column",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L87-L101 |
19,259 | apache/spark | python/pyspark/ml/image.py | _ImageSchema.imageFields | 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... | python | 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",
")",
":",
"if",
"self",
".",
"_imageFields",
"is",
"None",
":",
"ctx",
"=",
"SparkContext",
".",
"_active_spark_context",
"self",
".",
"_imageFields",
"=",
"list",
"(",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
"."... | Returns field names of image columns.
:return: a list of field names.
.. versionadded:: 2.3.0 | [
"Returns",
"field",
"names",
"of",
"image",
"columns",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L104-L116 |
19,260 | apache/spark | python/pyspark/ml/image.py | _ImageSchema.undefinedImageType | 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._... | python | 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",
")",
":",
"if",
"self",
".",
"_undefinedImageType",
"is",
"None",
":",
"ctx",
"=",
"SparkContext",
".",
"_active_spark_context",
"self",
".",
"_undefinedImageType",
"=",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
... | Returns the name of undefined image type for the invalid image.
.. versionadded:: 2.3.0 | [
"Returns",
"the",
"name",
"of",
"undefined",
"image",
"type",
"for",
"the",
"invalid",
"image",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L119-L130 |
19,261 | apache/spark | python/pyspark/ml/image.py | _ImageSchema.toNDArray | 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... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"image",
",",
"Row",
")",
":",
"raise",
"TypeError",
"(",
"\"image argument should be pyspark.sql.types.Row; however, \"",
"\"it got [%s].\"",
"%",
"type",
"(",
"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.
.. versionadded:: 2.3.0 | [
"Converts",
"an",
"image",
"to",
"an",
"array",
"with",
"metadata",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L132-L160 |
19,262 | apache/spark | python/pyspark/ml/image.py | _ImageSchema.toImage | 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.
.. ... | python | 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",
"=",
"\"\"",
")",
":",
"if",
"not",
"isinstance",
"(",
"array",
",",
"np",
".",
"ndarray",
")",
":",
"raise",
"TypeError",
"(",
"\"array argument should be numpy.ndarray; however, it got [%s].\"",
"%",
... | 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 | [
"Converts",
"an",
"array",
"with",
"metadata",
"to",
"a",
"two",
"-",
"dimensional",
"image",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L162-L204 |
19,263 | apache/spark | python/pyspark/ml/image.py | _ImageSchema.readImages | 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,
... | python | 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",
")",
":",
"warnings",
".",
"warn",
"(",
... | 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... | [
"Reads",
"the",
"directory",
"of",
"images",
"from",
"the",
"local",
"or",
"remote",
"source",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/image.py#L206-L242 |
19,264 | apache/spark | python/pyspark/ml/wrapper.py | JavaWrapper._create_from_java_class | 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) | python | 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",
")",
":",
"java_obj",
"=",
"JavaWrapper",
".",
"_new_java_obj",
"(",
"java_class",
",",
"*",
"args",
")",
"return",
"cls",
"(",
"java_obj",
")"
] | Construct this object from given Java classname and arguments | [
"Construct",
"this",
"object",
"from",
"given",
"Java",
"classname",
"and",
"arguments"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/wrapper.py#L44-L49 |
19,265 | apache/spark | python/pyspark/ml/wrapper.py | JavaWrapper._new_java_array | 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... | python | 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",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"java_array",
"=",
"None",
"if",
"len",
"(",
"pylist",
")",
">",
"0",
"and",
"isinstance",
"(",
"pylist",
"[",
"0",
"]",
",",
"... | 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... | [
"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",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/wrapper.py#L70-L109 |
19,266 | apache/spark | python/pyspark/profiler.py | ProfilerCollector.add_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... | python | 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",
")",
":",
"if",
"not",
"self",
".",
"profilers",
":",
"if",
"self",
".",
"profile_dump_path",
":",
"atexit",
".",
"register",
"(",
"self",
".",
"dump_profiles",
",",
"self",
".",
"profile_du... | Add a profiler for RDD `id` | [
"Add",
"a",
"profiler",
"for",
"RDD",
"id"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/profiler.py#L43-L51 |
19,267 | apache/spark | python/pyspark/profiler.py | ProfilerCollector.show_profiles | 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 | python | 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",
")",
":",
"for",
"i",
",",
"(",
"id",
",",
"profiler",
",",
"showed",
")",
"in",
"enumerate",
"(",
"self",
".",
"profilers",
")",
":",
"if",
"not",
"showed",
"and",
"profiler",
":",
"profiler",
".",
"show",
"(",
... | Print the profile stats to stdout | [
"Print",
"the",
"profile",
"stats",
"to",
"stdout"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/profiler.py#L59-L65 |
19,268 | apache/spark | python/pyspark/profiler.py | Profiler.show | def show(self, id):
""" Print the profile stats to stdout, id is the RDD id """
stats = self.stats()
if stats:
print("=" * 60)
print("Profile of RDD<id=%d>" % id)
print("=" * 60)
stats.sort_stats("time", "cumulative").print_stats() | python | def show(self, id):
""" Print the profile stats to stdout, id is the RDD id """
stats = self.stats()
if stats:
print("=" * 60)
print("Profile of RDD<id=%d>" % id)
print("=" * 60)
stats.sort_stats("time", "cumulative").print_stats() | [
"def",
"show",
"(",
"self",
",",
"id",
")",
":",
"stats",
"=",
"self",
".",
"stats",
"(",
")",
"if",
"stats",
":",
"print",
"(",
"\"=\"",
"*",
"60",
")",
"print",
"(",
"\"Profile of RDD<id=%d>\"",
"%",
"id",
")",
"print",
"(",
"\"=\"",
"*",
"60",
... | Print the profile stats to stdout, id is the RDD id | [
"Print",
"the",
"profile",
"stats",
"to",
"stdout",
"id",
"is",
"the",
"RDD",
"id"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/profiler.py#L113-L120 |
19,269 | apache/spark | python/pyspark/profiler.py | Profiler.dump | def dump(self, id, path):
""" Dump the profile into path, id is the RDD id """
if not os.path.exists(path):
os.makedirs(path)
stats = self.stats()
if stats:
p = os.path.join(path, "rdd_%d.pstats" % id)
stats.dump_stats(p) | python | def dump(self, id, path):
""" Dump the profile into path, id is the RDD id """
if not os.path.exists(path):
os.makedirs(path)
stats = self.stats()
if stats:
p = os.path.join(path, "rdd_%d.pstats" % id)
stats.dump_stats(p) | [
"def",
"dump",
"(",
"self",
",",
"id",
",",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"os",
".",
"makedirs",
"(",
"path",
")",
"stats",
"=",
"self",
".",
"stats",
"(",
")",
"if",
"stats",
":",
"p"... | Dump the profile into path, id is the RDD id | [
"Dump",
"the",
"profile",
"into",
"path",
"id",
"is",
"the",
"RDD",
"id"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/profiler.py#L122-L129 |
19,270 | apache/spark | python/pyspark/profiler.py | BasicProfiler.profile | def profile(self, func):
""" Runs and profiles the method to_profile passed in. A profile object is returned. """
pr = cProfile.Profile()
pr.runcall(func)
st = pstats.Stats(pr)
st.stream = None # make it picklable
st.strip_dirs()
# Adds a new profile to the exis... | python | def profile(self, func):
""" Runs and profiles the method to_profile passed in. A profile object is returned. """
pr = cProfile.Profile()
pr.runcall(func)
st = pstats.Stats(pr)
st.stream = None # make it picklable
st.strip_dirs()
# Adds a new profile to the exis... | [
"def",
"profile",
"(",
"self",
",",
"func",
")",
":",
"pr",
"=",
"cProfile",
".",
"Profile",
"(",
")",
"pr",
".",
"runcall",
"(",
"func",
")",
"st",
"=",
"pstats",
".",
"Stats",
"(",
"pr",
")",
"st",
".",
"stream",
"=",
"None",
"# make it picklable... | Runs and profiles the method to_profile passed in. A profile object is returned. | [
"Runs",
"and",
"profiles",
"the",
"method",
"to_profile",
"passed",
"in",
".",
"A",
"profile",
"object",
"is",
"returned",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/profiler.py#L158-L167 |
19,271 | apache/spark | python/pyspark/sql/context.py | SQLContext.getOrCreate | def getOrCreate(cls, sc):
"""
Get the existing SQLContext or create a new one with given SparkContext.
:param sc: SparkContext
"""
if cls._instantiatedContext is None:
jsqlContext = sc._jvm.SQLContext.getOrCreate(sc._jsc.sc())
sparkSession = SparkSession(... | python | def getOrCreate(cls, sc):
"""
Get the existing SQLContext or create a new one with given SparkContext.
:param sc: SparkContext
"""
if cls._instantiatedContext is None:
jsqlContext = sc._jvm.SQLContext.getOrCreate(sc._jsc.sc())
sparkSession = SparkSession(... | [
"def",
"getOrCreate",
"(",
"cls",
",",
"sc",
")",
":",
"if",
"cls",
".",
"_instantiatedContext",
"is",
"None",
":",
"jsqlContext",
"=",
"sc",
".",
"_jvm",
".",
"SQLContext",
".",
"getOrCreate",
"(",
"sc",
".",
"_jsc",
".",
"sc",
"(",
")",
")",
"spark... | Get the existing SQLContext or create a new one with given SparkContext.
:param sc: SparkContext | [
"Get",
"the",
"existing",
"SQLContext",
"or",
"create",
"a",
"new",
"one",
"with",
"given",
"SparkContext",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/context.py#L103-L113 |
19,272 | apache/spark | python/pyspark/sql/context.py | SQLContext.setConf | def setConf(self, key, value):
"""Sets the given Spark SQL configuration property.
"""
self.sparkSession.conf.set(key, value) | python | def setConf(self, key, value):
"""Sets the given Spark SQL configuration property.
"""
self.sparkSession.conf.set(key, value) | [
"def",
"setConf",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"sparkSession",
".",
"conf",
".",
"set",
"(",
"key",
",",
"value",
")"
] | Sets the given Spark SQL configuration property. | [
"Sets",
"the",
"given",
"Spark",
"SQL",
"configuration",
"property",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/context.py#L125-L128 |
19,273 | apache/spark | python/pyspark/sql/context.py | SQLContext.getConf | def getConf(self, key, defaultValue=_NoValue):
"""Returns the value of Spark SQL configuration property for the given key.
If the key is not set and defaultValue is set, return
defaultValue. If the key is not set and defaultValue is not set, return
the system default value.
>>>... | python | def getConf(self, key, defaultValue=_NoValue):
"""Returns the value of Spark SQL configuration property for the given key.
If the key is not set and defaultValue is set, return
defaultValue. If the key is not set and defaultValue is not set, return
the system default value.
>>>... | [
"def",
"getConf",
"(",
"self",
",",
"key",
",",
"defaultValue",
"=",
"_NoValue",
")",
":",
"return",
"self",
".",
"sparkSession",
".",
"conf",
".",
"get",
"(",
"key",
",",
"defaultValue",
")"
] | Returns the value of Spark SQL configuration property for the given key.
If the key is not set and defaultValue is set, return
defaultValue. If the key is not set and defaultValue is not set, return
the system default value.
>>> sqlContext.getConf("spark.sql.shuffle.partitions")
... | [
"Returns",
"the",
"value",
"of",
"Spark",
"SQL",
"configuration",
"property",
"for",
"the",
"given",
"key",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/context.py#L132-L147 |
19,274 | apache/spark | python/pyspark/sql/context.py | SQLContext.createExternalTable | def createExternalTable(self, tableName, path=None, source=None, schema=None, **options):
"""Creates an external table based on the dataset in a data source.
It returns the DataFrame associated with the external table.
The data source is specified by the ``source`` and a set of ``options``.
... | python | def createExternalTable(self, tableName, path=None, source=None, schema=None, **options):
"""Creates an external table based on the dataset in a data source.
It returns the DataFrame associated with the external table.
The data source is specified by the ``source`` and a set of ``options``.
... | [
"def",
"createExternalTable",
"(",
"self",
",",
"tableName",
",",
"path",
"=",
"None",
",",
"source",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"return",
"self",
".",
"sparkSession",
".",
"catalog",
".",
"createExternal... | Creates an external table based on the dataset in a data source.
It returns the DataFrame associated with the external table.
The data source is specified by the ``source`` and a set of ``options``.
If ``source`` is not specified, the default data source configured by
``spark.sql.sourc... | [
"Creates",
"an",
"external",
"table",
"based",
"on",
"the",
"dataset",
"in",
"a",
"data",
"source",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/context.py#L329-L344 |
19,275 | apache/spark | python/pyspark/sql/context.py | SQLContext.tableNames | def tableNames(self, dbName=None):
"""Returns a list of names of tables in the database ``dbName``.
:param dbName: string, name of the database to use. Default to the current database.
:return: list of table names, in string
>>> sqlContext.registerDataFrameAsTable(df, "table1")
... | python | def tableNames(self, dbName=None):
"""Returns a list of names of tables in the database ``dbName``.
:param dbName: string, name of the database to use. Default to the current database.
:return: list of table names, in string
>>> sqlContext.registerDataFrameAsTable(df, "table1")
... | [
"def",
"tableNames",
"(",
"self",
",",
"dbName",
"=",
"None",
")",
":",
"if",
"dbName",
"is",
"None",
":",
"return",
"[",
"name",
"for",
"name",
"in",
"self",
".",
"_ssql_ctx",
".",
"tableNames",
"(",
")",
"]",
"else",
":",
"return",
"[",
"name",
"... | Returns a list of names of tables in the database ``dbName``.
:param dbName: string, name of the database to use. Default to the current database.
:return: list of table names, in string
>>> sqlContext.registerDataFrameAsTable(df, "table1")
>>> "table1" in sqlContext.tableNames()
... | [
"Returns",
"a",
"list",
"of",
"names",
"of",
"tables",
"in",
"the",
"database",
"dbName",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/context.py#L397-L412 |
19,276 | apache/spark | python/pyspark/ml/classification.py | OneVsRestModel.copy | def copy(self, extra=None):
"""
Creates a copy of this instance with a randomly generated uid
and some extra params. This creates a deep copy of the embedded paramMap,
and copies the embedded and extra parameters over.
:param extra: Extra parameters to copy to the new instance
... | python | def copy(self, extra=None):
"""
Creates a copy of this instance with a randomly generated uid
and some extra params. This creates a deep copy of the embedded paramMap,
and copies the embedded and extra parameters over.
:param extra: Extra parameters to copy to the new instance
... | [
"def",
"copy",
"(",
"self",
",",
"extra",
"=",
"None",
")",
":",
"if",
"extra",
"is",
"None",
":",
"extra",
"=",
"dict",
"(",
")",
"newModel",
"=",
"Params",
".",
"copy",
"(",
"self",
",",
"extra",
")",
"newModel",
".",
"models",
"=",
"[",
"model... | Creates a copy of this instance with a randomly generated uid
and some extra params. This creates a deep copy of the embedded paramMap,
and copies the embedded and extra parameters over.
:param extra: Extra parameters to copy to the new instance
:return: Copy of this instance | [
"Creates",
"a",
"copy",
"of",
"this",
"instance",
"with",
"a",
"randomly",
"generated",
"uid",
"and",
"some",
"extra",
"params",
".",
"This",
"creates",
"a",
"deep",
"copy",
"of",
"the",
"embedded",
"paramMap",
"and",
"copies",
"the",
"embedded",
"and",
"e... | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/classification.py#L2046-L2059 |
19,277 | apache/spark | python/pyspark/ml/classification.py | OneVsRestModel._from_java | def _from_java(cls, java_stage):
"""
Given a Java OneVsRestModel, create and return a Python wrapper of it.
Used for ML persistence.
"""
featuresCol = java_stage.getFeaturesCol()
labelCol = java_stage.getLabelCol()
predictionCol = java_stage.getPredictionCol()
... | python | def _from_java(cls, java_stage):
"""
Given a Java OneVsRestModel, create and return a Python wrapper of it.
Used for ML persistence.
"""
featuresCol = java_stage.getFeaturesCol()
labelCol = java_stage.getLabelCol()
predictionCol = java_stage.getPredictionCol()
... | [
"def",
"_from_java",
"(",
"cls",
",",
"java_stage",
")",
":",
"featuresCol",
"=",
"java_stage",
".",
"getFeaturesCol",
"(",
")",
"labelCol",
"=",
"java_stage",
".",
"getLabelCol",
"(",
")",
"predictionCol",
"=",
"java_stage",
".",
"getPredictionCol",
"(",
")",... | Given a Java OneVsRestModel, create and return a Python wrapper of it.
Used for ML persistence. | [
"Given",
"a",
"Java",
"OneVsRestModel",
"create",
"and",
"return",
"a",
"Python",
"wrapper",
"of",
"it",
".",
"Used",
"for",
"ML",
"persistence",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/classification.py#L2062-L2075 |
19,278 | apache/spark | python/pyspark/ml/classification.py | OneVsRestModel._to_java | def _to_java(self):
"""
Transfer this instance to a Java OneVsRestModel. Used for ML persistence.
:return: Java object equivalent to this instance.
"""
sc = SparkContext._active_spark_context
java_models = [model._to_java() for model in self.models]
java_models_a... | python | def _to_java(self):
"""
Transfer this instance to a Java OneVsRestModel. Used for ML persistence.
:return: Java object equivalent to this instance.
"""
sc = SparkContext._active_spark_context
java_models = [model._to_java() for model in self.models]
java_models_a... | [
"def",
"_to_java",
"(",
"self",
")",
":",
"sc",
"=",
"SparkContext",
".",
"_active_spark_context",
"java_models",
"=",
"[",
"model",
".",
"_to_java",
"(",
")",
"for",
"model",
"in",
"self",
".",
"models",
"]",
"java_models_array",
"=",
"JavaWrapper",
".",
... | Transfer this instance to a Java OneVsRestModel. Used for ML persistence.
:return: Java object equivalent to this instance. | [
"Transfer",
"this",
"instance",
"to",
"a",
"Java",
"OneVsRestModel",
".",
"Used",
"for",
"ML",
"persistence",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/classification.py#L2077-L2094 |
19,279 | apache/spark | python/pyspark/util.py | _exception_message | def _exception_message(excp):
"""Return the message from an exception as either a str or unicode object. Supports both
Python 2 and Python 3.
>>> msg = "Exception message"
>>> excp = Exception(msg)
>>> msg == _exception_message(excp)
True
>>> msg = u"unicöde"
>>> excp = Exception(msg)... | python | def _exception_message(excp):
"""Return the message from an exception as either a str or unicode object. Supports both
Python 2 and Python 3.
>>> msg = "Exception message"
>>> excp = Exception(msg)
>>> msg == _exception_message(excp)
True
>>> msg = u"unicöde"
>>> excp = Exception(msg)... | [
"def",
"_exception_message",
"(",
"excp",
")",
":",
"if",
"isinstance",
"(",
"excp",
",",
"Py4JJavaError",
")",
":",
"# 'Py4JJavaError' doesn't contain the stack trace available on the Java side in 'message'",
"# attribute in Python 2. We should call 'str' function on this exception in... | Return the message from an exception as either a str or unicode object. Supports both
Python 2 and Python 3.
>>> msg = "Exception message"
>>> excp = Exception(msg)
>>> msg == _exception_message(excp)
True
>>> msg = u"unicöde"
>>> excp = Exception(msg)
>>> msg == _exception_message(ex... | [
"Return",
"the",
"message",
"from",
"an",
"exception",
"as",
"either",
"a",
"str",
"or",
"unicode",
"object",
".",
"Supports",
"both",
"Python",
"2",
"and",
"Python",
"3",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/util.py#L27-L49 |
19,280 | apache/spark | python/pyspark/util.py | _get_argspec | def _get_argspec(f):
"""
Get argspec of a function. Supports both Python 2 and Python 3.
"""
if sys.version_info[0] < 3:
argspec = inspect.getargspec(f)
else:
# `getargspec` is deprecated since python3.0 (incompatible with function annotations).
# See SPARK-23569.
arg... | python | def _get_argspec(f):
"""
Get argspec of a function. Supports both Python 2 and Python 3.
"""
if sys.version_info[0] < 3:
argspec = inspect.getargspec(f)
else:
# `getargspec` is deprecated since python3.0 (incompatible with function annotations).
# See SPARK-23569.
arg... | [
"def",
"_get_argspec",
"(",
"f",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"<",
"3",
":",
"argspec",
"=",
"inspect",
".",
"getargspec",
"(",
"f",
")",
"else",
":",
"# `getargspec` is deprecated since python3.0 (incompatible with function annotatio... | Get argspec of a function. Supports both Python 2 and Python 3. | [
"Get",
"argspec",
"of",
"a",
"function",
".",
"Supports",
"both",
"Python",
"2",
"and",
"Python",
"3",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/util.py#L52-L62 |
19,281 | apache/spark | python/pyspark/util.py | fail_on_stopiteration | def fail_on_stopiteration(f):
"""
Wraps the input function to fail on 'StopIteration' by raising a 'RuntimeError'
prevents silent loss of data when 'f' is used in a for loop in Spark code
"""
def wrapper(*args, **kwargs):
try:
return f(*args, **kwargs)
except StopIteratio... | python | def fail_on_stopiteration(f):
"""
Wraps the input function to fail on 'StopIteration' by raising a 'RuntimeError'
prevents silent loss of data when 'f' is used in a for loop in Spark code
"""
def wrapper(*args, **kwargs):
try:
return f(*args, **kwargs)
except StopIteratio... | [
"def",
"fail_on_stopiteration",
"(",
"f",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"f",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"StopIteration",
"as",
"exc",
":",
"rais... | Wraps the input function to fail on 'StopIteration' by raising a 'RuntimeError'
prevents silent loss of data when 'f' is used in a for loop in Spark code | [
"Wraps",
"the",
"input",
"function",
"to",
"fail",
"on",
"StopIteration",
"by",
"raising",
"a",
"RuntimeError",
"prevents",
"silent",
"loss",
"of",
"data",
"when",
"f",
"is",
"used",
"in",
"a",
"for",
"loop",
"in",
"Spark",
"code"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/util.py#L92-L106 |
19,282 | apache/spark | python/pyspark/context.py | SparkContext._ensure_initialized | def _ensure_initialized(cls, instance=None, gateway=None, conf=None):
"""
Checks whether a SparkContext is initialized or not.
Throws error if a SparkContext is already running.
"""
with SparkContext._lock:
if not SparkContext._gateway:
SparkContext._g... | python | def _ensure_initialized(cls, instance=None, gateway=None, conf=None):
"""
Checks whether a SparkContext is initialized or not.
Throws error if a SparkContext is already running.
"""
with SparkContext._lock:
if not SparkContext._gateway:
SparkContext._g... | [
"def",
"_ensure_initialized",
"(",
"cls",
",",
"instance",
"=",
"None",
",",
"gateway",
"=",
"None",
",",
"conf",
"=",
"None",
")",
":",
"with",
"SparkContext",
".",
"_lock",
":",
"if",
"not",
"SparkContext",
".",
"_gateway",
":",
"SparkContext",
".",
"_... | Checks whether a SparkContext is initialized or not.
Throws error if a SparkContext is already running. | [
"Checks",
"whether",
"a",
"SparkContext",
"is",
"initialized",
"or",
"not",
".",
"Throws",
"error",
"if",
"a",
"SparkContext",
"is",
"already",
"running",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/context.py#L303-L328 |
19,283 | apache/spark | python/pyspark/context.py | SparkContext.getOrCreate | def getOrCreate(cls, conf=None):
"""
Get or instantiate a SparkContext and register it as a singleton object.
:param conf: SparkConf (optional)
"""
with SparkContext._lock:
if SparkContext._active_spark_context is None:
SparkContext(conf=conf or Spark... | python | def getOrCreate(cls, conf=None):
"""
Get or instantiate a SparkContext and register it as a singleton object.
:param conf: SparkConf (optional)
"""
with SparkContext._lock:
if SparkContext._active_spark_context is None:
SparkContext(conf=conf or Spark... | [
"def",
"getOrCreate",
"(",
"cls",
",",
"conf",
"=",
"None",
")",
":",
"with",
"SparkContext",
".",
"_lock",
":",
"if",
"SparkContext",
".",
"_active_spark_context",
"is",
"None",
":",
"SparkContext",
"(",
"conf",
"=",
"conf",
"or",
"SparkConf",
"(",
")",
... | Get or instantiate a SparkContext and register it as a singleton object.
:param conf: SparkConf (optional) | [
"Get",
"or",
"instantiate",
"a",
"SparkContext",
"and",
"register",
"it",
"as",
"a",
"singleton",
"object",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/context.py#L353-L362 |
19,284 | apache/spark | python/pyspark/context.py | SparkContext.setSystemProperty | def setSystemProperty(cls, key, value):
"""
Set a Java system property, such as spark.executor.memory. This must
must be invoked before instantiating SparkContext.
"""
SparkContext._ensure_initialized()
SparkContext._jvm.java.lang.System.setProperty(key, value) | python | def setSystemProperty(cls, key, value):
"""
Set a Java system property, such as spark.executor.memory. This must
must be invoked before instantiating SparkContext.
"""
SparkContext._ensure_initialized()
SparkContext._jvm.java.lang.System.setProperty(key, value) | [
"def",
"setSystemProperty",
"(",
"cls",
",",
"key",
",",
"value",
")",
":",
"SparkContext",
".",
"_ensure_initialized",
"(",
")",
"SparkContext",
".",
"_jvm",
".",
"java",
".",
"lang",
".",
"System",
".",
"setProperty",
"(",
"key",
",",
"value",
")"
] | Set a Java system property, such as spark.executor.memory. This must
must be invoked before instantiating SparkContext. | [
"Set",
"a",
"Java",
"system",
"property",
"such",
"as",
"spark",
".",
"executor",
".",
"memory",
".",
"This",
"must",
"must",
"be",
"invoked",
"before",
"instantiating",
"SparkContext",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/context.py#L372-L378 |
19,285 | apache/spark | python/pyspark/context.py | SparkContext.stop | def stop(self):
"""
Shut down the SparkContext.
"""
if getattr(self, "_jsc", None):
try:
self._jsc.stop()
except Py4JError:
# Case: SPARK-18523
warnings.warn(
'Unable to cleanly shutdown Spark JVM... | python | def stop(self):
"""
Shut down the SparkContext.
"""
if getattr(self, "_jsc", None):
try:
self._jsc.stop()
except Py4JError:
# Case: SPARK-18523
warnings.warn(
'Unable to cleanly shutdown Spark JVM... | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"\"_jsc\"",
",",
"None",
")",
":",
"try",
":",
"self",
".",
"_jsc",
".",
"stop",
"(",
")",
"except",
"Py4JError",
":",
"# Case: SPARK-18523",
"warnings",
".",
"warn",
"(",
"'Una... | Shut down the SparkContext. | [
"Shut",
"down",
"the",
"SparkContext",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/context.py#L427-L448 |
19,286 | apache/spark | python/pyspark/context.py | SparkContext.parallelize | def parallelize(self, c, numSlices=None):
"""
Distribute a local Python collection to form an RDD. Using xrange
is recommended if the input represents a range for performance.
>>> sc.parallelize([0, 2, 3, 4, 6], 5).glom().collect()
[[0], [2], [3], [4], [6]]
>>> sc.parall... | python | def parallelize(self, c, numSlices=None):
"""
Distribute a local Python collection to form an RDD. Using xrange
is recommended if the input represents a range for performance.
>>> sc.parallelize([0, 2, 3, 4, 6], 5).glom().collect()
[[0], [2], [3], [4], [6]]
>>> sc.parall... | [
"def",
"parallelize",
"(",
"self",
",",
"c",
",",
"numSlices",
"=",
"None",
")",
":",
"numSlices",
"=",
"int",
"(",
"numSlices",
")",
"if",
"numSlices",
"is",
"not",
"None",
"else",
"self",
".",
"defaultParallelism",
"if",
"isinstance",
"(",
"c",
",",
... | Distribute a local Python collection to form an RDD. Using xrange
is recommended if the input represents a range for performance.
>>> sc.parallelize([0, 2, 3, 4, 6], 5).glom().collect()
[[0], [2], [3], [4], [6]]
>>> sc.parallelize(xrange(0, 6, 2), 5).glom().collect()
[[], [0], [... | [
"Distribute",
"a",
"local",
"Python",
"collection",
"to",
"form",
"an",
"RDD",
".",
"Using",
"xrange",
"is",
"recommended",
"if",
"the",
"input",
"represents",
"a",
"range",
"for",
"performance",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/context.py#L482-L529 |
19,287 | apache/spark | python/pyspark/context.py | SparkContext.union | def union(self, rdds):
"""
Build the union of a list of RDDs.
This supports unions() of RDDs with different serialized formats,
although this forces them to be reserialized using the default
serializer:
>>> path = os.path.join(tempdir, "union-text.txt")
>>> with... | python | def union(self, rdds):
"""
Build the union of a list of RDDs.
This supports unions() of RDDs with different serialized formats,
although this forces them to be reserialized using the default
serializer:
>>> path = os.path.join(tempdir, "union-text.txt")
>>> with... | [
"def",
"union",
"(",
"self",
",",
"rdds",
")",
":",
"first_jrdd_deserializer",
"=",
"rdds",
"[",
"0",
"]",
".",
"_jrdd_deserializer",
"if",
"any",
"(",
"x",
".",
"_jrdd_deserializer",
"!=",
"first_jrdd_deserializer",
"for",
"x",
"in",
"rdds",
")",
":",
"rd... | Build the union of a list of RDDs.
This supports unions() of RDDs with different serialized formats,
although this forces them to be reserialized using the default
serializer:
>>> path = os.path.join(tempdir, "union-text.txt")
>>> with open(path, "w") as testFile:
... ... | [
"Build",
"the",
"union",
"of",
"a",
"list",
"of",
"RDDs",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/context.py#L837-L862 |
19,288 | apache/spark | python/pyspark/context.py | SparkContext._getJavaStorageLevel | def _getJavaStorageLevel(self, storageLevel):
"""
Returns a Java StorageLevel based on a pyspark.StorageLevel.
"""
if not isinstance(storageLevel, StorageLevel):
raise Exception("storageLevel must be of type pyspark.StorageLevel")
newStorageLevel = self._jvm.org.apac... | python | def _getJavaStorageLevel(self, storageLevel):
"""
Returns a Java StorageLevel based on a pyspark.StorageLevel.
"""
if not isinstance(storageLevel, StorageLevel):
raise Exception("storageLevel must be of type pyspark.StorageLevel")
newStorageLevel = self._jvm.org.apac... | [
"def",
"_getJavaStorageLevel",
"(",
"self",
",",
"storageLevel",
")",
":",
"if",
"not",
"isinstance",
"(",
"storageLevel",
",",
"StorageLevel",
")",
":",
"raise",
"Exception",
"(",
"\"storageLevel must be of type pyspark.StorageLevel\"",
")",
"newStorageLevel",
"=",
"... | Returns a Java StorageLevel based on a pyspark.StorageLevel. | [
"Returns",
"a",
"Java",
"StorageLevel",
"based",
"on",
"a",
"pyspark",
".",
"StorageLevel",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/context.py#L949-L961 |
19,289 | apache/spark | python/pyspark/context.py | SparkContext.setJobGroup | def setJobGroup(self, groupId, description, interruptOnCancel=False):
"""
Assigns a group ID to all the jobs started by this thread until the group ID is set to a
different value or cleared.
Often, a unit of execution in an application consists of multiple Spark actions or jobs.
... | python | def setJobGroup(self, groupId, description, interruptOnCancel=False):
"""
Assigns a group ID to all the jobs started by this thread until the group ID is set to a
different value or cleared.
Often, a unit of execution in an application consists of multiple Spark actions or jobs.
... | [
"def",
"setJobGroup",
"(",
"self",
",",
"groupId",
",",
"description",
",",
"interruptOnCancel",
"=",
"False",
")",
":",
"self",
".",
"_jsc",
".",
"setJobGroup",
"(",
"groupId",
",",
"description",
",",
"interruptOnCancel",
")"
] | Assigns a group ID to all the jobs started by this thread until the group ID is set to a
different value or cleared.
Often, a unit of execution in an application consists of multiple Spark actions or jobs.
Application programmers can use this method to group all those jobs together and give a
... | [
"Assigns",
"a",
"group",
"ID",
"to",
"all",
"the",
"jobs",
"started",
"by",
"this",
"thread",
"until",
"the",
"group",
"ID",
"is",
"set",
"to",
"a",
"different",
"value",
"or",
"cleared",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/context.py#L963-L1005 |
19,290 | apache/spark | python/pyspark/context.py | SparkContext.runJob | def runJob(self, rdd, partitionFunc, partitions=None, allowLocal=False):
"""
Executes the given partitionFunc on the specified set of partitions,
returning the result as an array of elements.
If 'partitions' is not specified, this will run over all partitions.
>>> myRDD = sc.pa... | python | def runJob(self, rdd, partitionFunc, partitions=None, allowLocal=False):
"""
Executes the given partitionFunc on the specified set of partitions,
returning the result as an array of elements.
If 'partitions' is not specified, this will run over all partitions.
>>> myRDD = sc.pa... | [
"def",
"runJob",
"(",
"self",
",",
"rdd",
",",
"partitionFunc",
",",
"partitions",
"=",
"None",
",",
"allowLocal",
"=",
"False",
")",
":",
"if",
"partitions",
"is",
"None",
":",
"partitions",
"=",
"range",
"(",
"rdd",
".",
"_jrdd",
".",
"partitions",
"... | Executes the given partitionFunc on the specified set of partitions,
returning the result as an array of elements.
If 'partitions' is not specified, this will run over all partitions.
>>> myRDD = sc.parallelize(range(6), 3)
>>> sc.runJob(myRDD, lambda part: [x * x for x in part])
... | [
"Executes",
"the",
"given",
"partitionFunc",
"on",
"the",
"specified",
"set",
"of",
"partitions",
"returning",
"the",
"result",
"as",
"an",
"array",
"of",
"elements",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/context.py#L1052-L1075 |
19,291 | apache/spark | python/pyspark/mllib/fpm.py | FPGrowth.train | def train(cls, data, minSupport=0.3, numPartitions=-1):
"""
Computes an FP-Growth model that contains frequent itemsets.
:param data:
The input data set, each element contains a transaction.
:param minSupport:
The minimal support level.
(default: 0.3)
... | python | def train(cls, data, minSupport=0.3, numPartitions=-1):
"""
Computes an FP-Growth model that contains frequent itemsets.
:param data:
The input data set, each element contains a transaction.
:param minSupport:
The minimal support level.
(default: 0.3)
... | [
"def",
"train",
"(",
"cls",
",",
"data",
",",
"minSupport",
"=",
"0.3",
",",
"numPartitions",
"=",
"-",
"1",
")",
":",
"model",
"=",
"callMLlibFunc",
"(",
"\"trainFPGrowthModel\"",
",",
"data",
",",
"float",
"(",
"minSupport",
")",
",",
"int",
"(",
"nu... | Computes an FP-Growth model that contains frequent itemsets.
:param data:
The input data set, each element contains a transaction.
:param minSupport:
The minimal support level.
(default: 0.3)
:param numPartitions:
The number of partitions used by parallel... | [
"Computes",
"an",
"FP",
"-",
"Growth",
"model",
"that",
"contains",
"frequent",
"itemsets",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/fpm.py#L78-L93 |
19,292 | apache/spark | python/pyspark/mllib/fpm.py | PrefixSpan.train | def train(cls, data, minSupport=0.1, maxPatternLength=10, maxLocalProjDBSize=32000000):
"""
Finds the complete set of frequent sequential patterns in the
input sequences of itemsets.
:param data:
The input data set, each element contains a sequence of
itemsets.
... | python | def train(cls, data, minSupport=0.1, maxPatternLength=10, maxLocalProjDBSize=32000000):
"""
Finds the complete set of frequent sequential patterns in the
input sequences of itemsets.
:param data:
The input data set, each element contains a sequence of
itemsets.
... | [
"def",
"train",
"(",
"cls",
",",
"data",
",",
"minSupport",
"=",
"0.1",
",",
"maxPatternLength",
"=",
"10",
",",
"maxLocalProjDBSize",
"=",
"32000000",
")",
":",
"model",
"=",
"callMLlibFunc",
"(",
"\"trainPrefixSpanModel\"",
",",
"data",
",",
"minSupport",
... | Finds the complete set of frequent sequential patterns in the
input sequences of itemsets.
:param data:
The input data set, each element contains a sequence of
itemsets.
:param minSupport:
The minimal support level of the sequential pattern, any
pattern t... | [
"Finds",
"the",
"complete",
"set",
"of",
"frequent",
"sequential",
"patterns",
"in",
"the",
"input",
"sequences",
"of",
"itemsets",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/fpm.py#L140-L166 |
19,293 | apache/spark | python/pyspark/mllib/stat/KernelDensity.py | KernelDensity.setSample | def setSample(self, sample):
"""Set sample points from the population. Should be a RDD"""
if not isinstance(sample, RDD):
raise TypeError("samples should be a RDD, received %s" % type(sample))
self._sample = sample | python | def setSample(self, sample):
"""Set sample points from the population. Should be a RDD"""
if not isinstance(sample, RDD):
raise TypeError("samples should be a RDD, received %s" % type(sample))
self._sample = sample | [
"def",
"setSample",
"(",
"self",
",",
"sample",
")",
":",
"if",
"not",
"isinstance",
"(",
"sample",
",",
"RDD",
")",
":",
"raise",
"TypeError",
"(",
"\"samples should be a RDD, received %s\"",
"%",
"type",
"(",
"sample",
")",
")",
"self",
".",
"_sample",
"... | Set sample points from the population. Should be a RDD | [
"Set",
"sample",
"points",
"from",
"the",
"population",
".",
"Should",
"be",
"a",
"RDD"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/stat/KernelDensity.py#L48-L52 |
19,294 | apache/spark | python/pyspark/mllib/stat/KernelDensity.py | KernelDensity.estimate | def estimate(self, points):
"""Estimate the probability density at points"""
points = list(points)
densities = callMLlibFunc(
"estimateKernelDensity", self._sample, self._bandwidth, points)
return np.asarray(densities) | python | def estimate(self, points):
"""Estimate the probability density at points"""
points = list(points)
densities = callMLlibFunc(
"estimateKernelDensity", self._sample, self._bandwidth, points)
return np.asarray(densities) | [
"def",
"estimate",
"(",
"self",
",",
"points",
")",
":",
"points",
"=",
"list",
"(",
"points",
")",
"densities",
"=",
"callMLlibFunc",
"(",
"\"estimateKernelDensity\"",
",",
"self",
".",
"_sample",
",",
"self",
".",
"_bandwidth",
",",
"points",
")",
"retur... | Estimate the probability density at points | [
"Estimate",
"the",
"probability",
"density",
"at",
"points"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/stat/KernelDensity.py#L54-L59 |
19,295 | apache/spark | python/pyspark/accumulators.py | _start_update_server | def _start_update_server(auth_token):
"""Start a TCP server to receive accumulator updates in a daemon thread, and returns it"""
server = AccumulatorServer(("localhost", 0), _UpdateRequestHandler, auth_token)
thread = threading.Thread(target=server.serve_forever)
thread.daemon = True
thread.start()
... | python | def _start_update_server(auth_token):
"""Start a TCP server to receive accumulator updates in a daemon thread, and returns it"""
server = AccumulatorServer(("localhost", 0), _UpdateRequestHandler, auth_token)
thread = threading.Thread(target=server.serve_forever)
thread.daemon = True
thread.start()
... | [
"def",
"_start_update_server",
"(",
"auth_token",
")",
":",
"server",
"=",
"AccumulatorServer",
"(",
"(",
"\"localhost\"",
",",
"0",
")",
",",
"_UpdateRequestHandler",
",",
"auth_token",
")",
"thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"serv... | Start a TCP server to receive accumulator updates in a daemon thread, and returns it | [
"Start",
"a",
"TCP",
"server",
"to",
"receive",
"accumulator",
"updates",
"in",
"a",
"daemon",
"thread",
"and",
"returns",
"it"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/accumulators.py#L289-L295 |
19,296 | apache/spark | python/pyspark/accumulators.py | Accumulator.add | def add(self, term):
"""Adds a term to this accumulator's value"""
self._value = self.accum_param.addInPlace(self._value, term) | python | def add(self, term):
"""Adds a term to this accumulator's value"""
self._value = self.accum_param.addInPlace(self._value, term) | [
"def",
"add",
"(",
"self",
",",
"term",
")",
":",
"self",
".",
"_value",
"=",
"self",
".",
"accum_param",
".",
"addInPlace",
"(",
"self",
".",
"_value",
",",
"term",
")"
] | Adds a term to this accumulator's value | [
"Adds",
"a",
"term",
"to",
"this",
"accumulator",
"s",
"value"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/accumulators.py#L163-L165 |
19,297 | apache/spark | python/pyspark/mllib/random.py | RandomRDDs.normalRDD | def normalRDD(sc, size, numPartitions=None, seed=None):
"""
Generates an RDD comprised of i.i.d. samples from the standard normal
distribution.
To transform the distribution in the generated RDD from standard normal
to some other normal N(mean, sigma^2), use
C{RandomRDDs... | python | def normalRDD(sc, size, numPartitions=None, seed=None):
"""
Generates an RDD comprised of i.i.d. samples from the standard normal
distribution.
To transform the distribution in the generated RDD from standard normal
to some other normal N(mean, sigma^2), use
C{RandomRDDs... | [
"def",
"normalRDD",
"(",
"sc",
",",
"size",
",",
"numPartitions",
"=",
"None",
",",
"seed",
"=",
"None",
")",
":",
"return",
"callMLlibFunc",
"(",
"\"normalRDD\"",
",",
"sc",
".",
"_jsc",
",",
"size",
",",
"numPartitions",
",",
"seed",
")"
] | Generates an RDD comprised of i.i.d. samples from the standard normal
distribution.
To transform the distribution in the generated RDD from standard normal
to some other normal N(mean, sigma^2), use
C{RandomRDDs.normal(sc, n, p, seed)\
.map(lambda v: mean + sigma * v)}
... | [
"Generates",
"an",
"RDD",
"comprised",
"of",
"i",
".",
"i",
".",
"d",
".",
"samples",
"from",
"the",
"standard",
"normal",
"distribution",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/random.py#L81-L106 |
19,298 | apache/spark | python/pyspark/mllib/random.py | RandomRDDs.logNormalRDD | def logNormalRDD(sc, mean, std, size, numPartitions=None, seed=None):
"""
Generates an RDD comprised of i.i.d. samples from the log normal
distribution with the input mean and standard distribution.
:param sc: SparkContext used to create the RDD.
:param mean: mean for the log No... | python | def logNormalRDD(sc, mean, std, size, numPartitions=None, seed=None):
"""
Generates an RDD comprised of i.i.d. samples from the log normal
distribution with the input mean and standard distribution.
:param sc: SparkContext used to create the RDD.
:param mean: mean for the log No... | [
"def",
"logNormalRDD",
"(",
"sc",
",",
"mean",
",",
"std",
",",
"size",
",",
"numPartitions",
"=",
"None",
",",
"seed",
"=",
"None",
")",
":",
"return",
"callMLlibFunc",
"(",
"\"logNormalRDD\"",
",",
"sc",
".",
"_jsc",
",",
"float",
"(",
"mean",
")",
... | Generates an RDD comprised of i.i.d. samples from the log normal
distribution with the input mean and standard distribution.
:param sc: SparkContext used to create the RDD.
:param mean: mean for the log Normal distribution
:param std: std for the log Normal distribution
:param s... | [
"Generates",
"an",
"RDD",
"comprised",
"of",
"i",
".",
"i",
".",
"d",
".",
"samples",
"from",
"the",
"log",
"normal",
"distribution",
"with",
"the",
"input",
"mean",
"and",
"standard",
"distribution",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/random.py#L110-L139 |
19,299 | apache/spark | python/pyspark/mllib/random.py | RandomRDDs.exponentialRDD | def exponentialRDD(sc, mean, size, numPartitions=None, seed=None):
"""
Generates an RDD comprised of i.i.d. samples from the Exponential
distribution with the input mean.
:param sc: SparkContext used to create the RDD.
:param mean: Mean, or 1 / lambda, for the Exponential distri... | python | def exponentialRDD(sc, mean, size, numPartitions=None, seed=None):
"""
Generates an RDD comprised of i.i.d. samples from the Exponential
distribution with the input mean.
:param sc: SparkContext used to create the RDD.
:param mean: Mean, or 1 / lambda, for the Exponential distri... | [
"def",
"exponentialRDD",
"(",
"sc",
",",
"mean",
",",
"size",
",",
"numPartitions",
"=",
"None",
",",
"seed",
"=",
"None",
")",
":",
"return",
"callMLlibFunc",
"(",
"\"exponentialRDD\"",
",",
"sc",
".",
"_jsc",
",",
"float",
"(",
"mean",
")",
",",
"siz... | Generates an RDD comprised of i.i.d. samples from the Exponential
distribution with the input mean.
:param sc: SparkContext used to create the RDD.
:param mean: Mean, or 1 / lambda, for the Exponential distribution.
:param size: Size of the RDD.
:param numPartitions: Number of p... | [
"Generates",
"an",
"RDD",
"comprised",
"of",
"i",
".",
"i",
".",
"d",
".",
"samples",
"from",
"the",
"Exponential",
"distribution",
"with",
"the",
"input",
"mean",
"."
] | 618d6bff71073c8c93501ab7392c3cc579730f0b | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/random.py#L170-L193 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.