partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | _reverse_op | Create a method for binary operator (this object is on right side) | python/pyspark/sql/column.py | def _reverse_op(name, doc="binary operator"):
""" Create a method for binary operator (this object is on right side)
"""
def _(self, other):
jother = _create_column_from_literal(other)
jc = getattr(jother, name)(self._jc)
return Column(jc)
_.__doc__ = doc
return _ | def _reverse_op(name, doc="binary operator"):
""" Create a method for binary operator (this object is on right side)
"""
def _(self, other):
jother = _create_column_from_literal(other)
jc = getattr(jother, name)(self._jc)
return Column(jc)
_.__doc__ = doc
return _ | [
"Create",
"a",
"method",
"for",
"binary",
"operator",
"(",
"this",
"object",
"is",
"on",
"right",
"side",
")"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L121-L129 | [
"def",
"_reverse_op",
"(",
"name",
",",
"doc",
"=",
"\"binary operator\"",
")",
":",
"def",
"_",
"(",
"self",
",",
"other",
")",
":",
"jother",
"=",
"_create_column_from_literal",
"(",
"other",
")",
"jc",
"=",
"getattr",
"(",
"jother",
",",
"name",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Column.substr | Return a :class:`Column` which is a substring of the column.
:param startPos: start position (int or Column)
:param length: length of the substring (int or Column)
>>> df.select(df.name.substr(1, 3).alias("col")).collect()
[Row(col=u'Ali'), Row(col=u'Bob')] | python/pyspark/sql/column.py | def substr(self, startPos, length):
"""
Return a :class:`Column` which is a substring of the column.
:param startPos: start position (int or Column)
:param length: length of the substring (int or Column)
>>> df.select(df.name.substr(1, 3).alias("col")).collect()
[Row(c... | def substr(self, startPos, length):
"""
Return a :class:`Column` which is a substring of the column.
:param startPos: start position (int or Column)
:param length: length of the substring (int or Column)
>>> df.select(df.name.substr(1, 3).alias("col")).collect()
[Row(c... | [
"Return",
"a",
":",
"class",
":",
"Column",
"which",
"is",
"a",
"substring",
"of",
"the",
"column",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L403-L427 | [
"def",
"substr",
"(",
"self",
",",
"startPos",
",",
"length",
")",
":",
"if",
"type",
"(",
"startPos",
")",
"!=",
"type",
"(",
"length",
")",
":",
"raise",
"TypeError",
"(",
"\"startPos and length must be the same type. \"",
"\"Got {startPos_t} and {length_t}, respe... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Column.isin | A boolean expression that is evaluated to true if the value of this
expression is contained by the evaluated values of the arguments.
>>> df[df.name.isin("Bob", "Mike")].collect()
[Row(age=5, name=u'Bob')]
>>> df[df.age.isin([1, 2, 3])].collect()
[Row(age=2, name=u'Alice')] | python/pyspark/sql/column.py | def isin(self, *cols):
"""
A boolean expression that is evaluated to true if the value of this
expression is contained by the evaluated values of the arguments.
>>> df[df.name.isin("Bob", "Mike")].collect()
[Row(age=5, name=u'Bob')]
>>> df[df.age.isin([1, 2, 3])].collect... | def isin(self, *cols):
"""
A boolean expression that is evaluated to true if the value of this
expression is contained by the evaluated values of the arguments.
>>> df[df.name.isin("Bob", "Mike")].collect()
[Row(age=5, name=u'Bob')]
>>> df[df.age.isin([1, 2, 3])].collect... | [
"A",
"boolean",
"expression",
"that",
"is",
"evaluated",
"to",
"true",
"if",
"the",
"value",
"of",
"this",
"expression",
"is",
"contained",
"by",
"the",
"evaluated",
"values",
"of",
"the",
"arguments",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L431-L446 | [
"def",
"isin",
"(",
"self",
",",
"*",
"cols",
")",
":",
"if",
"len",
"(",
"cols",
")",
"==",
"1",
"and",
"isinstance",
"(",
"cols",
"[",
"0",
"]",
",",
"(",
"list",
",",
"set",
")",
")",
":",
"cols",
"=",
"cols",
"[",
"0",
"]",
"cols",
"=",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Column.alias | Returns this column aliased with a new name or names (in the case of expressions that
return more than one column, such as explode).
:param alias: strings of desired column names (collects all positional arguments passed)
:param metadata: a dict of information to be stored in ``metadata`` attri... | python/pyspark/sql/column.py | def alias(self, *alias, **kwargs):
"""
Returns this column aliased with a new name or names (in the case of expressions that
return more than one column, such as explode).
:param alias: strings of desired column names (collects all positional arguments passed)
:param metadata: a... | def alias(self, *alias, **kwargs):
"""
Returns this column aliased with a new name or names (in the case of expressions that
return more than one column, such as explode).
:param alias: strings of desired column names (collects all positional arguments passed)
:param metadata: a... | [
"Returns",
"this",
"column",
"aliased",
"with",
"a",
"new",
"name",
"or",
"names",
"(",
"in",
"the",
"case",
"of",
"expressions",
"that",
"return",
"more",
"than",
"one",
"column",
"such",
"as",
"explode",
")",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L538-L570 | [
"def",
"alias",
"(",
"self",
",",
"*",
"alias",
",",
"*",
"*",
"kwargs",
")",
":",
"metadata",
"=",
"kwargs",
".",
"pop",
"(",
"'metadata'",
",",
"None",
")",
"assert",
"not",
"kwargs",
",",
"'Unexpected kwargs where passed: %s'",
"%",
"kwargs",
"sc",
"=... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Column.cast | Convert the column into type ``dataType``.
>>> df.select(df.age.cast("string").alias('ages')).collect()
[Row(ages=u'2'), Row(ages=u'5')]
>>> df.select(df.age.cast(StringType()).alias('ages')).collect()
[Row(ages=u'2'), Row(ages=u'5')] | python/pyspark/sql/column.py | def cast(self, dataType):
""" Convert the column into type ``dataType``.
>>> df.select(df.age.cast("string").alias('ages')).collect()
[Row(ages=u'2'), Row(ages=u'5')]
>>> df.select(df.age.cast(StringType()).alias('ages')).collect()
[Row(ages=u'2'), Row(ages=u'5')]
"""
... | def cast(self, dataType):
""" Convert the column into type ``dataType``.
>>> df.select(df.age.cast("string").alias('ages')).collect()
[Row(ages=u'2'), Row(ages=u'5')]
>>> df.select(df.age.cast(StringType()).alias('ages')).collect()
[Row(ages=u'2'), Row(ages=u'5')]
"""
... | [
"Convert",
"the",
"column",
"into",
"type",
"dataType",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L576-L593 | [
"def",
"cast",
"(",
"self",
",",
"dataType",
")",
":",
"if",
"isinstance",
"(",
"dataType",
",",
"basestring",
")",
":",
"jc",
"=",
"self",
".",
"_jc",
".",
"cast",
"(",
"dataType",
")",
"elif",
"isinstance",
"(",
"dataType",
",",
"DataType",
")",
":... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Column.when | Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
See :func:`pyspark.sql.functions.when` for example usage.
:param condition: a boolean :class:`Column` expression.
... | python/pyspark/sql/column.py | def when(self, condition, value):
"""
Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
See :func:`pyspark.sql.functions.when` for example usage.
:param ... | def when(self, condition, value):
"""
Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
See :func:`pyspark.sql.functions.when` for example usage.
:param ... | [
"Evaluates",
"a",
"list",
"of",
"conditions",
"and",
"returns",
"one",
"of",
"multiple",
"possible",
"result",
"expressions",
".",
"If",
":",
"func",
":",
"Column",
".",
"otherwise",
"is",
"not",
"invoked",
"None",
"is",
"returned",
"for",
"unmatched",
"cond... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L614-L637 | [
"def",
"when",
"(",
"self",
",",
"condition",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"condition",
",",
"Column",
")",
":",
"raise",
"TypeError",
"(",
"\"condition should be a Column\"",
")",
"v",
"=",
"value",
".",
"_jc",
"if",
"isinstance... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Column.otherwise | Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
See :func:`pyspark.sql.functions.when` for example usage.
:param value: a literal value, or a :class:`Column` expressio... | python/pyspark/sql/column.py | def otherwise(self, value):
"""
Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
See :func:`pyspark.sql.functions.when` for example usage.
:param value:... | def otherwise(self, value):
"""
Evaluates a list of conditions and returns one of multiple possible result expressions.
If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions.
See :func:`pyspark.sql.functions.when` for example usage.
:param value:... | [
"Evaluates",
"a",
"list",
"of",
"conditions",
"and",
"returns",
"one",
"of",
"multiple",
"possible",
"result",
"expressions",
".",
"If",
":",
"func",
":",
"Column",
".",
"otherwise",
"is",
"not",
"invoked",
"None",
"is",
"returned",
"for",
"unmatched",
"cond... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L640-L660 | [
"def",
"otherwise",
"(",
"self",
",",
"value",
")",
":",
"v",
"=",
"value",
".",
"_jc",
"if",
"isinstance",
"(",
"value",
",",
"Column",
")",
"else",
"value",
"jc",
"=",
"self",
".",
"_jc",
".",
"otherwise",
"(",
"v",
")",
"return",
"Column",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Column.over | Define a windowing column.
:param window: a :class:`WindowSpec`
:return: a Column
>>> from pyspark.sql import Window
>>> window = Window.partitionBy("name").orderBy("age").rowsBetween(-1, 1)
>>> from pyspark.sql.functions import rank, min
>>> # df.select(rank().over(win... | python/pyspark/sql/column.py | def over(self, window):
"""
Define a windowing column.
:param window: a :class:`WindowSpec`
:return: a Column
>>> from pyspark.sql import Window
>>> window = Window.partitionBy("name").orderBy("age").rowsBetween(-1, 1)
>>> from pyspark.sql.functions import rank,... | def over(self, window):
"""
Define a windowing column.
:param window: a :class:`WindowSpec`
:return: a Column
>>> from pyspark.sql import Window
>>> window = Window.partitionBy("name").orderBy("age").rowsBetween(-1, 1)
>>> from pyspark.sql.functions import rank,... | [
"Define",
"a",
"windowing",
"column",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/column.py#L663-L679 | [
"def",
"over",
"(",
"self",
",",
"window",
")",
":",
"from",
"pyspark",
".",
"sql",
".",
"window",
"import",
"WindowSpec",
"if",
"not",
"isinstance",
"(",
"window",
",",
"WindowSpec",
")",
":",
"raise",
"TypeError",
"(",
"\"window should be WindowSpec\"",
")... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | JavaVectorTransformer.transform | Applies transformation on a vector or an RDD[Vector].
.. note:: In Python, transform cannot currently be used within
an RDD transformation or action.
Call transform directly on the RDD instead.
:param vector: Vector or RDD of Vector to be transformed. | python/pyspark/mllib/feature.py | def transform(self, vector):
"""
Applies transformation on a vector or an RDD[Vector].
.. note:: In Python, transform cannot currently be used within
an RDD transformation or action.
Call transform directly on the RDD instead.
:param vector: Vector or RDD of Vec... | def transform(self, vector):
"""
Applies transformation on a vector or an RDD[Vector].
.. note:: In Python, transform cannot currently be used within
an RDD transformation or action.
Call transform directly on the RDD instead.
:param vector: Vector or RDD of Vec... | [
"Applies",
"transformation",
"on",
"a",
"vector",
"or",
"an",
"RDD",
"[",
"Vector",
"]",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L111-L125 | [
"def",
"transform",
"(",
"self",
",",
"vector",
")",
":",
"if",
"isinstance",
"(",
"vector",
",",
"RDD",
")",
":",
"vector",
"=",
"vector",
".",
"map",
"(",
"_convert_to_vector",
")",
"else",
":",
"vector",
"=",
"_convert_to_vector",
"(",
"vector",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StandardScaler.fit | Computes the mean and variance and stores as a model to be used
for later scaling.
:param dataset: The data used to compute the mean and variance
to build the transformation model.
:return: a StandardScalarModel | python/pyspark/mllib/feature.py | def fit(self, dataset):
"""
Computes the mean and variance and stores as a model to be used
for later scaling.
:param dataset: The data used to compute the mean and variance
to build the transformation model.
:return: a StandardScalarModel
"""
... | def fit(self, dataset):
"""
Computes the mean and variance and stores as a model to be used
for later scaling.
:param dataset: The data used to compute the mean and variance
to build the transformation model.
:return: a StandardScalarModel
"""
... | [
"Computes",
"the",
"mean",
"and",
"variance",
"and",
"stores",
"as",
"a",
"model",
"to",
"be",
"used",
"for",
"later",
"scaling",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L240-L251 | [
"def",
"fit",
"(",
"self",
",",
"dataset",
")",
":",
"dataset",
"=",
"dataset",
".",
"map",
"(",
"_convert_to_vector",
")",
"jmodel",
"=",
"callMLlibFunc",
"(",
"\"fitStandardScaler\"",
",",
"self",
".",
"withMean",
",",
"self",
".",
"withStd",
",",
"datas... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | ChiSqSelector.fit | Returns a ChiSquared feature selector.
:param data: an `RDD[LabeledPoint]` containing the labeled dataset
with categorical features. Real-valued features will be
treated as categorical for each distinct value.
Apply feature discretizer before using... | python/pyspark/mllib/feature.py | def fit(self, data):
"""
Returns a ChiSquared feature selector.
:param data: an `RDD[LabeledPoint]` containing the labeled dataset
with categorical features. Real-valued features will be
treated as categorical for each distinct value.
... | def fit(self, data):
"""
Returns a ChiSquared feature selector.
:param data: an `RDD[LabeledPoint]` containing the labeled dataset
with categorical features. Real-valued features will be
treated as categorical for each distinct value.
... | [
"Returns",
"a",
"ChiSquared",
"feature",
"selector",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L383-L394 | [
"def",
"fit",
"(",
"self",
",",
"data",
")",
":",
"jmodel",
"=",
"callMLlibFunc",
"(",
"\"fitChiSqSelector\"",
",",
"self",
".",
"selectorType",
",",
"self",
".",
"numTopFeatures",
",",
"self",
".",
"percentile",
",",
"self",
".",
"fpr",
",",
"self",
"."... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | PCA.fit | Computes a [[PCAModel]] that contains the principal components of the input vectors.
:param data: source vectors | python/pyspark/mllib/feature.py | def fit(self, data):
"""
Computes a [[PCAModel]] that contains the principal components of the input vectors.
:param data: source vectors
"""
jmodel = callMLlibFunc("fitPCA", self.k, data)
return PCAModel(jmodel) | def fit(self, data):
"""
Computes a [[PCAModel]] that contains the principal components of the input vectors.
:param data: source vectors
"""
jmodel = callMLlibFunc("fitPCA", self.k, data)
return PCAModel(jmodel) | [
"Computes",
"a",
"[[",
"PCAModel",
"]]",
"that",
"contains",
"the",
"principal",
"components",
"of",
"the",
"input",
"vectors",
".",
":",
"param",
"data",
":",
"source",
"vectors"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L428-L434 | [
"def",
"fit",
"(",
"self",
",",
"data",
")",
":",
"jmodel",
"=",
"callMLlibFunc",
"(",
"\"fitPCA\"",
",",
"self",
".",
"k",
",",
"data",
")",
"return",
"PCAModel",
"(",
"jmodel",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | HashingTF.transform | Transforms the input document (list of terms) to term frequency
vectors, or transform the RDD of document to RDD of term
frequency vectors. | python/pyspark/mllib/feature.py | def transform(self, document):
"""
Transforms the input document (list of terms) to term frequency
vectors, or transform the RDD of document to RDD of term
frequency vectors.
"""
if isinstance(document, RDD):
return document.map(self.transform)
freq =... | def transform(self, document):
"""
Transforms the input document (list of terms) to term frequency
vectors, or transform the RDD of document to RDD of term
frequency vectors.
"""
if isinstance(document, RDD):
return document.map(self.transform)
freq =... | [
"Transforms",
"the",
"input",
"document",
"(",
"list",
"of",
"terms",
")",
"to",
"term",
"frequency",
"vectors",
"or",
"transform",
"the",
"RDD",
"of",
"document",
"to",
"RDD",
"of",
"term",
"frequency",
"vectors",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L473-L486 | [
"def",
"transform",
"(",
"self",
",",
"document",
")",
":",
"if",
"isinstance",
"(",
"document",
",",
"RDD",
")",
":",
"return",
"document",
".",
"map",
"(",
"self",
".",
"transform",
")",
"freq",
"=",
"{",
"}",
"for",
"term",
"in",
"document",
":",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | IDF.fit | Computes the inverse document frequency.
:param dataset: an RDD of term frequency vectors | python/pyspark/mllib/feature.py | def fit(self, dataset):
"""
Computes the inverse document frequency.
:param dataset: an RDD of term frequency vectors
"""
if not isinstance(dataset, RDD):
raise TypeError("dataset should be an RDD of term frequency vectors")
jmodel = callMLlibFunc("fitIDF", s... | def fit(self, dataset):
"""
Computes the inverse document frequency.
:param dataset: an RDD of term frequency vectors
"""
if not isinstance(dataset, RDD):
raise TypeError("dataset should be an RDD of term frequency vectors")
jmodel = callMLlibFunc("fitIDF", s... | [
"Computes",
"the",
"inverse",
"document",
"frequency",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L577-L586 | [
"def",
"fit",
"(",
"self",
",",
"dataset",
")",
":",
"if",
"not",
"isinstance",
"(",
"dataset",
",",
"RDD",
")",
":",
"raise",
"TypeError",
"(",
"\"dataset should be an RDD of term frequency vectors\"",
")",
"jmodel",
"=",
"callMLlibFunc",
"(",
"\"fitIDF\"",
","... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Word2VecModel.findSynonyms | Find synonyms of a word
:param word: a word or a vector representation of word
:param num: number of synonyms to find
:return: array of (word, cosineSimilarity)
.. note:: Local use only | python/pyspark/mllib/feature.py | def findSynonyms(self, word, num):
"""
Find synonyms of a word
:param word: a word or a vector representation of word
:param num: number of synonyms to find
:return: array of (word, cosineSimilarity)
.. note:: Local use only
"""
if not isinstance(word, b... | def findSynonyms(self, word, num):
"""
Find synonyms of a word
:param word: a word or a vector representation of word
:param num: number of synonyms to find
:return: array of (word, cosineSimilarity)
.. note:: Local use only
"""
if not isinstance(word, b... | [
"Find",
"synonyms",
"of",
"a",
"word"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L611-L624 | [
"def",
"findSynonyms",
"(",
"self",
",",
"word",
",",
"num",
")",
":",
"if",
"not",
"isinstance",
"(",
"word",
",",
"basestring",
")",
":",
"word",
"=",
"_convert_to_vector",
"(",
"word",
")",
"words",
",",
"similarity",
"=",
"self",
".",
"call",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Word2VecModel.load | Load a model from the given path. | python/pyspark/mllib/feature.py | def load(cls, sc, path):
"""
Load a model from the given path.
"""
jmodel = sc._jvm.org.apache.spark.mllib.feature \
.Word2VecModel.load(sc._jsc.sc(), path)
model = sc._jvm.org.apache.spark.mllib.api.python.Word2VecModelWrapper(jmodel)
return Word2VecModel(mod... | def load(cls, sc, path):
"""
Load a model from the given path.
"""
jmodel = sc._jvm.org.apache.spark.mllib.feature \
.Word2VecModel.load(sc._jsc.sc(), path)
model = sc._jvm.org.apache.spark.mllib.api.python.Word2VecModelWrapper(jmodel)
return Word2VecModel(mod... | [
"Load",
"a",
"model",
"from",
"the",
"given",
"path",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L635-L642 | [
"def",
"load",
"(",
"cls",
",",
"sc",
",",
"path",
")",
":",
"jmodel",
"=",
"sc",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"mllib",
".",
"feature",
".",
"Word2VecModel",
".",
"load",
"(",
"sc",
".",
"_jsc",
".",
"sc",
"(",
")"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | ElementwiseProduct.transform | Computes the Hadamard product of the vector. | python/pyspark/mllib/feature.py | def transform(self, vector):
"""
Computes the Hadamard product of the vector.
"""
if isinstance(vector, RDD):
vector = vector.map(_convert_to_vector)
else:
vector = _convert_to_vector(vector)
return callMLlibFunc("elementwiseProductVector", self.s... | def transform(self, vector):
"""
Computes the Hadamard product of the vector.
"""
if isinstance(vector, RDD):
vector = vector.map(_convert_to_vector)
else:
vector = _convert_to_vector(vector)
return callMLlibFunc("elementwiseProductVector", self.s... | [
"Computes",
"the",
"Hadamard",
"product",
"of",
"the",
"vector",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/feature.py#L810-L819 | [
"def",
"transform",
"(",
"self",
",",
"vector",
")",
":",
"if",
"isinstance",
"(",
"vector",
",",
"RDD",
")",
":",
"vector",
"=",
"vector",
".",
"map",
"(",
"_convert_to_vector",
")",
"else",
":",
"vector",
"=",
"_convert_to_vector",
"(",
"vector",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | TreeEnsembleModel.predict | Predict values for a single data point or an RDD of points using
the model trained.
.. note:: In Python, predict cannot currently be used within an RDD
transformation or action.
Call predict directly on the RDD instead. | python/pyspark/mllib/tree.py | def predict(self, x):
"""
Predict values for a single data point or an RDD of points using
the model trained.
.. note:: In Python, predict cannot currently be used within an RDD
transformation or action.
Call predict directly on the RDD instead.
"""
... | def predict(self, x):
"""
Predict values for a single data point or an RDD of points using
the model trained.
.. note:: In Python, predict cannot currently be used within an RDD
transformation or action.
Call predict directly on the RDD instead.
"""
... | [
"Predict",
"values",
"for",
"a",
"single",
"data",
"point",
"or",
"an",
"RDD",
"of",
"points",
"using",
"the",
"model",
"trained",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/tree.py#L39-L52 | [
"def",
"predict",
"(",
"self",
",",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"RDD",
")",
":",
"return",
"self",
".",
"call",
"(",
"\"predict\"",
",",
"x",
".",
"map",
"(",
"_convert_to_vector",
")",
")",
"else",
":",
"return",
"self",
".",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DecisionTree.trainClassifier | Train a decision tree model for classification.
:param data:
Training data: RDD of LabeledPoint. Labels should take values
{0, 1, ..., numClasses-1}.
:param numClasses:
Number of classes for classification.
:param categoricalFeaturesInfo:
Map storing arit... | python/pyspark/mllib/tree.py | def trainClassifier(cls, data, numClasses, categoricalFeaturesInfo,
impurity="gini", maxDepth=5, maxBins=32, minInstancesPerNode=1,
minInfoGain=0.0):
"""
Train a decision tree model for classification.
:param data:
Training data: RDD of ... | def trainClassifier(cls, data, numClasses, categoricalFeaturesInfo,
impurity="gini", maxDepth=5, maxBins=32, minInstancesPerNode=1,
minInfoGain=0.0):
"""
Train a decision tree model for classification.
:param data:
Training data: RDD of ... | [
"Train",
"a",
"decision",
"tree",
"model",
"for",
"classification",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/tree.py#L149-L217 | [
"def",
"trainClassifier",
"(",
"cls",
",",
"data",
",",
"numClasses",
",",
"categoricalFeaturesInfo",
",",
"impurity",
"=",
"\"gini\"",
",",
"maxDepth",
"=",
"5",
",",
"maxBins",
"=",
"32",
",",
"minInstancesPerNode",
"=",
"1",
",",
"minInfoGain",
"=",
"0.0"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DecisionTree.trainRegressor | Train a decision tree model for regression.
:param data:
Training data: RDD of LabeledPoint. Labels are real numbers.
:param categoricalFeaturesInfo:
Map storing arity of categorical features. An entry (n -> k)
indicates that feature n is categorical with k categories
... | python/pyspark/mllib/tree.py | def trainRegressor(cls, data, categoricalFeaturesInfo,
impurity="variance", maxDepth=5, maxBins=32, minInstancesPerNode=1,
minInfoGain=0.0):
"""
Train a decision tree model for regression.
:param data:
Training data: RDD of LabeledPoint. L... | def trainRegressor(cls, data, categoricalFeaturesInfo,
impurity="variance", maxDepth=5, maxBins=32, minInstancesPerNode=1,
minInfoGain=0.0):
"""
Train a decision tree model for regression.
:param data:
Training data: RDD of LabeledPoint. L... | [
"Train",
"a",
"decision",
"tree",
"model",
"for",
"regression",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/tree.py#L221-L277 | [
"def",
"trainRegressor",
"(",
"cls",
",",
"data",
",",
"categoricalFeaturesInfo",
",",
"impurity",
"=",
"\"variance\"",
",",
"maxDepth",
"=",
"5",
",",
"maxBins",
"=",
"32",
",",
"minInstancesPerNode",
"=",
"1",
",",
"minInfoGain",
"=",
"0.0",
")",
":",
"r... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | RandomForest.trainClassifier | Train a random forest model for binary or multiclass
classification.
:param data:
Training dataset: RDD of LabeledPoint. Labels should take values
{0, 1, ..., numClasses-1}.
:param numClasses:
Number of classes for classification.
:param categoricalFeatures... | python/pyspark/mllib/tree.py | def trainClassifier(cls, data, numClasses, categoricalFeaturesInfo, numTrees,
featureSubsetStrategy="auto", impurity="gini", maxDepth=4, maxBins=32,
seed=None):
"""
Train a random forest model for binary or multiclass
classification.
:para... | def trainClassifier(cls, data, numClasses, categoricalFeaturesInfo, numTrees,
featureSubsetStrategy="auto", impurity="gini", maxDepth=4, maxBins=32,
seed=None):
"""
Train a random forest model for binary or multiclass
classification.
:para... | [
"Train",
"a",
"random",
"forest",
"model",
"for",
"binary",
"or",
"multiclass",
"classification",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/tree.py#L319-L407 | [
"def",
"trainClassifier",
"(",
"cls",
",",
"data",
",",
"numClasses",
",",
"categoricalFeaturesInfo",
",",
"numTrees",
",",
"featureSubsetStrategy",
"=",
"\"auto\"",
",",
"impurity",
"=",
"\"gini\"",
",",
"maxDepth",
"=",
"4",
",",
"maxBins",
"=",
"32",
",",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | RandomForest.trainRegressor | Train a random forest model for regression.
:param data:
Training dataset: RDD of LabeledPoint. Labels are real numbers.
:param categoricalFeaturesInfo:
Map storing arity of categorical features. An entry (n -> k)
indicates that feature n is categorical with k categories
... | python/pyspark/mllib/tree.py | def trainRegressor(cls, data, categoricalFeaturesInfo, numTrees, featureSubsetStrategy="auto",
impurity="variance", maxDepth=4, maxBins=32, seed=None):
"""
Train a random forest model for regression.
:param data:
Training dataset: RDD of LabeledPoint. Labels are... | def trainRegressor(cls, data, categoricalFeaturesInfo, numTrees, featureSubsetStrategy="auto",
impurity="variance", maxDepth=4, maxBins=32, seed=None):
"""
Train a random forest model for regression.
:param data:
Training dataset: RDD of LabeledPoint. Labels are... | [
"Train",
"a",
"random",
"forest",
"model",
"for",
"regression",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/tree.py#L411-L476 | [
"def",
"trainRegressor",
"(",
"cls",
",",
"data",
",",
"categoricalFeaturesInfo",
",",
"numTrees",
",",
"featureSubsetStrategy",
"=",
"\"auto\"",
",",
"impurity",
"=",
"\"variance\"",
",",
"maxDepth",
"=",
"4",
",",
"maxBins",
"=",
"32",
",",
"seed",
"=",
"N... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | GradientBoostedTrees.trainClassifier | Train a gradient-boosted trees model for classification.
:param data:
Training dataset: RDD of LabeledPoint. Labels should take values
{0, 1}.
:param categoricalFeaturesInfo:
Map storing arity of categorical features. An entry (n -> k)
indicates that feature n is... | python/pyspark/mllib/tree.py | def trainClassifier(cls, data, categoricalFeaturesInfo,
loss="logLoss", numIterations=100, learningRate=0.1, maxDepth=3,
maxBins=32):
"""
Train a gradient-boosted trees model for classification.
:param data:
Training dataset: RDD of Labe... | def trainClassifier(cls, data, categoricalFeaturesInfo,
loss="logLoss", numIterations=100, learningRate=0.1, maxDepth=3,
maxBins=32):
"""
Train a gradient-boosted trees model for classification.
:param data:
Training dataset: RDD of Labe... | [
"Train",
"a",
"gradient",
"-",
"boosted",
"trees",
"model",
"for",
"classification",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/tree.py#L511-L576 | [
"def",
"trainClassifier",
"(",
"cls",
",",
"data",
",",
"categoricalFeaturesInfo",
",",
"loss",
"=",
"\"logLoss\"",
",",
"numIterations",
"=",
"100",
",",
"learningRate",
"=",
"0.1",
",",
"maxDepth",
"=",
"3",
",",
"maxBins",
"=",
"32",
")",
":",
"return",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparkConf.set | Set a configuration property. | python/pyspark/conf.py | def set(self, key, value):
"""Set a configuration property."""
# Try to set self._jconf first if JVM is created, set self._conf if JVM is not created yet.
if self._jconf is not None:
self._jconf.set(key, unicode(value))
else:
self._conf[key] = unicode(value)
... | def set(self, key, value):
"""Set a configuration property."""
# Try to set self._jconf first if JVM is created, set self._conf if JVM is not created yet.
if self._jconf is not None:
self._jconf.set(key, unicode(value))
else:
self._conf[key] = unicode(value)
... | [
"Set",
"a",
"configuration",
"property",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L123-L130 | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"# Try to set self._jconf first if JVM is created, set self._conf if JVM is not created yet.",
"if",
"self",
".",
"_jconf",
"is",
"not",
"None",
":",
"self",
".",
"_jconf",
".",
"set",
"(",
"key",
",",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparkConf.setIfMissing | Set a configuration property, if not already set. | python/pyspark/conf.py | def setIfMissing(self, key, value):
"""Set a configuration property, if not already set."""
if self.get(key) is None:
self.set(key, value)
return self | def setIfMissing(self, key, value):
"""Set a configuration property, if not already set."""
if self.get(key) is None:
self.set(key, value)
return self | [
"Set",
"a",
"configuration",
"property",
"if",
"not",
"already",
"set",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L132-L136 | [
"def",
"setIfMissing",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"self",
".",
"get",
"(",
"key",
")",
"is",
"None",
":",
"self",
".",
"set",
"(",
"key",
",",
"value",
")",
"return",
"self"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparkConf.setExecutorEnv | Set an environment variable to be passed to executors. | python/pyspark/conf.py | def setExecutorEnv(self, key=None, value=None, pairs=None):
"""Set an environment variable to be passed to executors."""
if (key is not None and pairs is not None) or (key is None and pairs is None):
raise Exception("Either pass one key-value pair or a list of pairs")
elif key is not... | def setExecutorEnv(self, key=None, value=None, pairs=None):
"""Set an environment variable to be passed to executors."""
if (key is not None and pairs is not None) or (key is None and pairs is None):
raise Exception("Either pass one key-value pair or a list of pairs")
elif key is not... | [
"Set",
"an",
"environment",
"variable",
"to",
"be",
"passed",
"to",
"executors",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L153-L162 | [
"def",
"setExecutorEnv",
"(",
"self",
",",
"key",
"=",
"None",
",",
"value",
"=",
"None",
",",
"pairs",
"=",
"None",
")",
":",
"if",
"(",
"key",
"is",
"not",
"None",
"and",
"pairs",
"is",
"not",
"None",
")",
"or",
"(",
"key",
"is",
"None",
"and",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparkConf.setAll | Set multiple parameters, passed as a list of key-value pairs.
:param pairs: list of key-value pairs to set | python/pyspark/conf.py | def setAll(self, pairs):
"""
Set multiple parameters, passed as a list of key-value pairs.
:param pairs: list of key-value pairs to set
"""
for (k, v) in pairs:
self.set(k, v)
return self | def setAll(self, pairs):
"""
Set multiple parameters, passed as a list of key-value pairs.
:param pairs: list of key-value pairs to set
"""
for (k, v) in pairs:
self.set(k, v)
return self | [
"Set",
"multiple",
"parameters",
"passed",
"as",
"a",
"list",
"of",
"key",
"-",
"value",
"pairs",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L164-L172 | [
"def",
"setAll",
"(",
"self",
",",
"pairs",
")",
":",
"for",
"(",
"k",
",",
"v",
")",
"in",
"pairs",
":",
"self",
".",
"set",
"(",
"k",
",",
"v",
")",
"return",
"self"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparkConf.get | Get the configured value for some key, or return a default otherwise. | python/pyspark/conf.py | def get(self, key, defaultValue=None):
"""Get the configured value for some key, or return a default otherwise."""
if defaultValue is None: # Py4J doesn't call the right get() if we pass None
if self._jconf is not None:
if not self._jconf.contains(key):
... | def get(self, key, defaultValue=None):
"""Get the configured value for some key, or return a default otherwise."""
if defaultValue is None: # Py4J doesn't call the right get() if we pass None
if self._jconf is not None:
if not self._jconf.contains(key):
... | [
"Get",
"the",
"configured",
"value",
"for",
"some",
"key",
"or",
"return",
"a",
"default",
"otherwise",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L174-L189 | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"defaultValue",
"=",
"None",
")",
":",
"if",
"defaultValue",
"is",
"None",
":",
"# Py4J doesn't call the right get() if we pass None",
"if",
"self",
".",
"_jconf",
"is",
"not",
"None",
":",
"if",
"not",
"self",
"."... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparkConf.getAll | Get all values as a list of key-value pairs. | python/pyspark/conf.py | def getAll(self):
"""Get all values as a list of key-value pairs."""
if self._jconf is not None:
return [(elem._1(), elem._2()) for elem in self._jconf.getAll()]
else:
return self._conf.items() | def getAll(self):
"""Get all values as a list of key-value pairs."""
if self._jconf is not None:
return [(elem._1(), elem._2()) for elem in self._jconf.getAll()]
else:
return self._conf.items() | [
"Get",
"all",
"values",
"as",
"a",
"list",
"of",
"key",
"-",
"value",
"pairs",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L191-L196 | [
"def",
"getAll",
"(",
"self",
")",
":",
"if",
"self",
".",
"_jconf",
"is",
"not",
"None",
":",
"return",
"[",
"(",
"elem",
".",
"_1",
"(",
")",
",",
"elem",
".",
"_2",
"(",
")",
")",
"for",
"elem",
"in",
"self",
".",
"_jconf",
".",
"getAll",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparkConf.contains | Does this configuration contain a given key? | python/pyspark/conf.py | def contains(self, key):
"""Does this configuration contain a given key?"""
if self._jconf is not None:
return self._jconf.contains(key)
else:
return key in self._conf | def contains(self, key):
"""Does this configuration contain a given key?"""
if self._jconf is not None:
return self._jconf.contains(key)
else:
return key in self._conf | [
"Does",
"this",
"configuration",
"contain",
"a",
"given",
"key?"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L198-L203 | [
"def",
"contains",
"(",
"self",
",",
"key",
")",
":",
"if",
"self",
".",
"_jconf",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_jconf",
".",
"contains",
"(",
"key",
")",
"else",
":",
"return",
"key",
"in",
"self",
".",
"_conf"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | SparkConf.toDebugString | Returns a printable version of the configuration, as a list of
key=value pairs, one per line. | python/pyspark/conf.py | def toDebugString(self):
"""
Returns a printable version of the configuration, as a list of
key=value pairs, one per line.
"""
if self._jconf is not None:
return self._jconf.toDebugString()
else:
return '\n'.join('%s=%s' % (k, v) for k, v in self._... | def toDebugString(self):
"""
Returns a printable version of the configuration, as a list of
key=value pairs, one per line.
"""
if self._jconf is not None:
return self._jconf.toDebugString()
else:
return '\n'.join('%s=%s' % (k, v) for k, v in self._... | [
"Returns",
"a",
"printable",
"version",
"of",
"the",
"configuration",
"as",
"a",
"list",
"of",
"key",
"=",
"value",
"pairs",
"one",
"per",
"line",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/conf.py#L205-L213 | [
"def",
"toDebugString",
"(",
"self",
")",
":",
"if",
"self",
".",
"_jconf",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_jconf",
".",
"toDebugString",
"(",
")",
"else",
":",
"return",
"'\\n'",
".",
"join",
"(",
"'%s=%s'",
"%",
"(",
"k",
",",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Catalog.listDatabases | Returns a list of databases available across all sessions. | python/pyspark/sql/catalog.py | def listDatabases(self):
"""Returns a list of databases available across all sessions."""
iter = self._jcatalog.listDatabases().toLocalIterator()
databases = []
while iter.hasNext():
jdb = iter.next()
databases.append(Database(
name=jdb.name(),
... | def listDatabases(self):
"""Returns a list of databases available across all sessions."""
iter = self._jcatalog.listDatabases().toLocalIterator()
databases = []
while iter.hasNext():
jdb = iter.next()
databases.append(Database(
name=jdb.name(),
... | [
"Returns",
"a",
"list",
"of",
"databases",
"available",
"across",
"all",
"sessions",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/catalog.py#L61-L71 | [
"def",
"listDatabases",
"(",
"self",
")",
":",
"iter",
"=",
"self",
".",
"_jcatalog",
".",
"listDatabases",
"(",
")",
".",
"toLocalIterator",
"(",
")",
"databases",
"=",
"[",
"]",
"while",
"iter",
".",
"hasNext",
"(",
")",
":",
"jdb",
"=",
"iter",
".... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Catalog.listTables | Returns a list of tables/views in the specified database.
If no database is specified, the current database is used.
This includes all temporary views. | python/pyspark/sql/catalog.py | def listTables(self, dbName=None):
"""Returns a list of tables/views in the specified database.
If no database is specified, the current database is used.
This includes all temporary views.
"""
if dbName is None:
dbName = self.currentDatabase()
iter = self._j... | def listTables(self, dbName=None):
"""Returns a list of tables/views in the specified database.
If no database is specified, the current database is used.
This includes all temporary views.
"""
if dbName is None:
dbName = self.currentDatabase()
iter = self._j... | [
"Returns",
"a",
"list",
"of",
"tables",
"/",
"views",
"in",
"the",
"specified",
"database",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/catalog.py#L75-L93 | [
"def",
"listTables",
"(",
"self",
",",
"dbName",
"=",
"None",
")",
":",
"if",
"dbName",
"is",
"None",
":",
"dbName",
"=",
"self",
".",
"currentDatabase",
"(",
")",
"iter",
"=",
"self",
".",
"_jcatalog",
".",
"listTables",
"(",
"dbName",
")",
".",
"to... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Catalog.listFunctions | Returns a list of functions registered in the specified database.
If no database is specified, the current database is used.
This includes all temporary functions. | python/pyspark/sql/catalog.py | def listFunctions(self, dbName=None):
"""Returns a list of functions registered in the specified database.
If no database is specified, the current database is used.
This includes all temporary functions.
"""
if dbName is None:
dbName = self.currentDatabase()
... | def listFunctions(self, dbName=None):
"""Returns a list of functions registered in the specified database.
If no database is specified, the current database is used.
This includes all temporary functions.
"""
if dbName is None:
dbName = self.currentDatabase()
... | [
"Returns",
"a",
"list",
"of",
"functions",
"registered",
"in",
"the",
"specified",
"database",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/catalog.py#L97-L114 | [
"def",
"listFunctions",
"(",
"self",
",",
"dbName",
"=",
"None",
")",
":",
"if",
"dbName",
"is",
"None",
":",
"dbName",
"=",
"self",
".",
"currentDatabase",
"(",
")",
"iter",
"=",
"self",
".",
"_jcatalog",
".",
"listFunctions",
"(",
"dbName",
")",
".",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Catalog.listColumns | Returns a list of columns for the given table/view in the specified database.
If no database is specified, the current database is used.
Note: the order of arguments here is different from that of its JVM counterpart
because Python does not support method overloading. | python/pyspark/sql/catalog.py | def listColumns(self, tableName, dbName=None):
"""Returns a list of columns for the given table/view in the specified database.
If no database is specified, the current database is used.
Note: the order of arguments here is different from that of its JVM counterpart
because Python does... | def listColumns(self, tableName, dbName=None):
"""Returns a list of columns for the given table/view in the specified database.
If no database is specified, the current database is used.
Note: the order of arguments here is different from that of its JVM counterpart
because Python does... | [
"Returns",
"a",
"list",
"of",
"columns",
"for",
"the",
"given",
"table",
"/",
"view",
"in",
"the",
"specified",
"database",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/catalog.py#L118-L139 | [
"def",
"listColumns",
"(",
"self",
",",
"tableName",
",",
"dbName",
"=",
"None",
")",
":",
"if",
"dbName",
"is",
"None",
":",
"dbName",
"=",
"self",
".",
"currentDatabase",
"(",
")",
"iter",
"=",
"self",
".",
"_jcatalog",
".",
"listColumns",
"(",
"dbNa... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Catalog.createExternalTable | Creates a 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.sources.default... | python/pyspark/sql/catalog.py | def createExternalTable(self, tableName, path=None, source=None, schema=None, **options):
"""Creates a 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 `... | def createExternalTable(self, tableName, path=None, source=None, schema=None, **options):
"""Creates a 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 `... | [
"Creates",
"a",
"table",
"based",
"on",
"the",
"dataset",
"in",
"a",
"data",
"source",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/catalog.py#L142-L159 | [
"def",
"createExternalTable",
"(",
"self",
",",
"tableName",
",",
"path",
"=",
"None",
",",
"source",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"warnings",
".",
"warn",
"(",
"\"createExternalTable is deprecated since Spark 2.... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | Catalog.createTable | Creates a table based on the dataset in a data source.
It returns the DataFrame associated with the 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.sources.default`` will b... | python/pyspark/sql/catalog.py | def createTable(self, tableName, path=None, source=None, schema=None, **options):
"""Creates a table based on the dataset in a data source.
It returns the DataFrame associated with the table.
The data source is specified by the ``source`` and a set of ``options``.
If ``source`` is not ... | def createTable(self, tableName, path=None, source=None, schema=None, **options):
"""Creates a table based on the dataset in a data source.
It returns the DataFrame associated with the table.
The data source is specified by the ``source`` and a set of ``options``.
If ``source`` is not ... | [
"Creates",
"a",
"table",
"based",
"on",
"the",
"dataset",
"in",
"a",
"data",
"source",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/catalog.py#L162-L188 | [
"def",
"createTable",
"(",
"self",
",",
"tableName",
",",
"path",
"=",
"None",
",",
"source",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"if",
"path",
"is",
"not",
"None",
":",
"options",
"[",
"\"path\"",
"]",
"=",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _load_from_socket | Load data from a given socket, this is a blocking method thus only return when the socket
connection has been closed. | python/pyspark/taskcontext.py | def _load_from_socket(port, auth_secret):
"""
Load data from a given socket, this is a blocking method thus only return when the socket
connection has been closed.
"""
(sockfile, sock) = local_connect_and_auth(port, auth_secret)
# The barrier() call may block forever, so no timeout
sock.sett... | def _load_from_socket(port, auth_secret):
"""
Load data from a given socket, this is a blocking method thus only return when the socket
connection has been closed.
"""
(sockfile, sock) = local_connect_and_auth(port, auth_secret)
# The barrier() call may block forever, so no timeout
sock.sett... | [
"Load",
"data",
"from",
"a",
"given",
"socket",
"this",
"is",
"a",
"blocking",
"method",
"thus",
"only",
"return",
"when",
"the",
"socket",
"connection",
"has",
"been",
"closed",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/taskcontext.py#L102-L121 | [
"def",
"_load_from_socket",
"(",
"port",
",",
"auth_secret",
")",
":",
"(",
"sockfile",
",",
"sock",
")",
"=",
"local_connect_and_auth",
"(",
"port",
",",
"auth_secret",
")",
"# The barrier() call may block forever, so no timeout",
"sock",
".",
"settimeout",
"(",
"N... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | BarrierTaskContext._getOrCreate | Internal function to get or create global BarrierTaskContext. We need to make sure
BarrierTaskContext is returned from here because it is needed in python worker reuse
scenario, see SPARK-25921 for more details. | python/pyspark/taskcontext.py | def _getOrCreate(cls):
"""
Internal function to get or create global BarrierTaskContext. We need to make sure
BarrierTaskContext is returned from here because it is needed in python worker reuse
scenario, see SPARK-25921 for more details.
"""
if not isinstance(cls._taskCo... | def _getOrCreate(cls):
"""
Internal function to get or create global BarrierTaskContext. We need to make sure
BarrierTaskContext is returned from here because it is needed in python worker reuse
scenario, see SPARK-25921 for more details.
"""
if not isinstance(cls._taskCo... | [
"Internal",
"function",
"to",
"get",
"or",
"create",
"global",
"BarrierTaskContext",
".",
"We",
"need",
"to",
"make",
"sure",
"BarrierTaskContext",
"is",
"returned",
"from",
"here",
"because",
"it",
"is",
"needed",
"in",
"python",
"worker",
"reuse",
"scenario",
... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/taskcontext.py#L139-L147 | [
"def",
"_getOrCreate",
"(",
"cls",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"_taskContext",
",",
"BarrierTaskContext",
")",
":",
"cls",
".",
"_taskContext",
"=",
"object",
".",
"__new__",
"(",
"cls",
")",
"return",
"cls",
".",
"_taskContext"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | BarrierTaskContext._initialize | Initialize BarrierTaskContext, other methods within BarrierTaskContext can only be called
after BarrierTaskContext is initialized. | python/pyspark/taskcontext.py | def _initialize(cls, port, secret):
"""
Initialize BarrierTaskContext, other methods within BarrierTaskContext can only be called
after BarrierTaskContext is initialized.
"""
cls._port = port
cls._secret = secret | def _initialize(cls, port, secret):
"""
Initialize BarrierTaskContext, other methods within BarrierTaskContext can only be called
after BarrierTaskContext is initialized.
"""
cls._port = port
cls._secret = secret | [
"Initialize",
"BarrierTaskContext",
"other",
"methods",
"within",
"BarrierTaskContext",
"can",
"only",
"be",
"called",
"after",
"BarrierTaskContext",
"is",
"initialized",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/taskcontext.py#L163-L169 | [
"def",
"_initialize",
"(",
"cls",
",",
"port",
",",
"secret",
")",
":",
"cls",
".",
"_port",
"=",
"port",
"cls",
".",
"_secret",
"=",
"secret"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | BarrierTaskContext.barrier | .. note:: Experimental
Sets a global barrier and waits until all tasks in this stage hit this barrier.
Similar to `MPI_Barrier` function in MPI, this function blocks until all tasks
in the same stage have reached this routine.
.. warning:: In a barrier stage, each task much have the sa... | python/pyspark/taskcontext.py | def barrier(self):
"""
.. note:: Experimental
Sets a global barrier and waits until all tasks in this stage hit this barrier.
Similar to `MPI_Barrier` function in MPI, this function blocks until all tasks
in the same stage have reached this routine.
.. warning:: In a ba... | def barrier(self):
"""
.. note:: Experimental
Sets a global barrier and waits until all tasks in this stage hit this barrier.
Similar to `MPI_Barrier` function in MPI, this function blocks until all tasks
in the same stage have reached this routine.
.. warning:: In a ba... | [
"..",
"note",
"::",
"Experimental"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/taskcontext.py#L171-L189 | [
"def",
"barrier",
"(",
"self",
")",
":",
"if",
"self",
".",
"_port",
"is",
"None",
"or",
"self",
".",
"_secret",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Not supported to call barrier() before initialize \"",
"+",
"\"BarrierTaskContext.\"",
")",
"else",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | BarrierTaskContext.getTaskInfos | .. note:: Experimental
Returns :class:`BarrierTaskInfo` for all tasks in this barrier stage,
ordered by partition ID.
.. versionadded:: 2.4.0 | python/pyspark/taskcontext.py | def getTaskInfos(self):
"""
.. note:: Experimental
Returns :class:`BarrierTaskInfo` for all tasks in this barrier stage,
ordered by partition ID.
.. versionadded:: 2.4.0
"""
if self._port is None or self._secret is None:
raise Exception("Not supporte... | def getTaskInfos(self):
"""
.. note:: Experimental
Returns :class:`BarrierTaskInfo` for all tasks in this barrier stage,
ordered by partition ID.
.. versionadded:: 2.4.0
"""
if self._port is None or self._secret is None:
raise Exception("Not supporte... | [
"..",
"note",
"::",
"Experimental"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/taskcontext.py#L191-L205 | [
"def",
"getTaskInfos",
"(",
"self",
")",
":",
"if",
"self",
".",
"_port",
"is",
"None",
"or",
"self",
".",
"_secret",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Not supported to call getTaskInfos() before initialize \"",
"+",
"\"BarrierTaskContext.\"",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | since | A decorator that annotates a function to append the version of Spark the function was added. | python/pyspark/__init__.py | def since(version):
"""
A decorator that annotates a function to append the version of Spark the function was added.
"""
import re
indent_p = re.compile(r'\n( +)')
def deco(f):
indents = indent_p.findall(f.__doc__)
indent = ' ' * (min(len(m) for m in indents) if indents else 0)
... | def since(version):
"""
A decorator that annotates a function to append the version of Spark the function was added.
"""
import re
indent_p = re.compile(r'\n( +)')
def deco(f):
indents = indent_p.findall(f.__doc__)
indent = ' ' * (min(len(m) for m in indents) if indents else 0)
... | [
"A",
"decorator",
"that",
"annotates",
"a",
"function",
"to",
"append",
"the",
"version",
"of",
"Spark",
"the",
"function",
"was",
"added",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/__init__.py#L65-L77 | [
"def",
"since",
"(",
"version",
")",
":",
"import",
"re",
"indent_p",
"=",
"re",
".",
"compile",
"(",
"r'\\n( +)'",
")",
"def",
"deco",
"(",
"f",
")",
":",
"indents",
"=",
"indent_p",
".",
"findall",
"(",
"f",
".",
"__doc__",
")",
"indent",
"=",
"'... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | copy_func | Returns a function with same code, globals, defaults, closure, and
name (or provide a new name). | python/pyspark/__init__.py | def copy_func(f, name=None, sinceversion=None, doc=None):
"""
Returns a function with same code, globals, defaults, closure, and
name (or provide a new name).
"""
# See
# http://stackoverflow.com/questions/6527633/how-can-i-make-a-deepcopy-of-a-function-in-python
fn = types.FunctionType(f.__... | def copy_func(f, name=None, sinceversion=None, doc=None):
"""
Returns a function with same code, globals, defaults, closure, and
name (or provide a new name).
"""
# See
# http://stackoverflow.com/questions/6527633/how-can-i-make-a-deepcopy-of-a-function-in-python
fn = types.FunctionType(f.__... | [
"Returns",
"a",
"function",
"with",
"same",
"code",
"globals",
"defaults",
"closure",
"and",
"name",
"(",
"or",
"provide",
"a",
"new",
"name",
")",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/__init__.py#L80-L95 | [
"def",
"copy_func",
"(",
"f",
",",
"name",
"=",
"None",
",",
"sinceversion",
"=",
"None",
",",
"doc",
"=",
"None",
")",
":",
"# See",
"# http://stackoverflow.com/questions/6527633/how-can-i-make-a-deepcopy-of-a-function-in-python",
"fn",
"=",
"types",
".",
"FunctionTy... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | keyword_only | A decorator that forces keyword arguments in the wrapped method
and saves actual input keyword arguments in `_input_kwargs`.
.. note:: Should only be used to wrap a method where first arg is `self` | python/pyspark/__init__.py | def keyword_only(func):
"""
A decorator that forces keyword arguments in the wrapped method
and saves actual input keyword arguments in `_input_kwargs`.
.. note:: Should only be used to wrap a method where first arg is `self`
"""
@wraps(func)
def wrapper(self, *args, **kwargs):
if l... | def keyword_only(func):
"""
A decorator that forces keyword arguments in the wrapped method
and saves actual input keyword arguments in `_input_kwargs`.
.. note:: Should only be used to wrap a method where first arg is `self`
"""
@wraps(func)
def wrapper(self, *args, **kwargs):
if l... | [
"A",
"decorator",
"that",
"forces",
"keyword",
"arguments",
"in",
"the",
"wrapped",
"method",
"and",
"saves",
"actual",
"input",
"keyword",
"arguments",
"in",
"_input_kwargs",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/__init__.py#L98-L111 | [
"def",
"keyword_only",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"0",
":",
"raise",
"TypeError",
"(",
"\"Method %... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _gen_param_header | Generates the header part for shared variables
:param name: param name
:param doc: param doc | python/pyspark/ml/param/_shared_params_code_gen.py | def _gen_param_header(name, doc, defaultValueStr, typeConverter):
"""
Generates the header part for shared variables
:param name: param name
:param doc: param doc
"""
template = '''class Has$Name(Params):
"""
Mixin for param $name: $doc
"""
$name = Param(Params._dummy(), "$name... | def _gen_param_header(name, doc, defaultValueStr, typeConverter):
"""
Generates the header part for shared variables
:param name: param name
:param doc: param doc
"""
template = '''class Has$Name(Params):
"""
Mixin for param $name: $doc
"""
$name = Param(Params._dummy(), "$name... | [
"Generates",
"the",
"header",
"part",
"for",
"shared",
"variables"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/param/_shared_params_code_gen.py#L41-L70 | [
"def",
"_gen_param_header",
"(",
"name",
",",
"doc",
",",
"defaultValueStr",
",",
"typeConverter",
")",
":",
"template",
"=",
"'''class Has$Name(Params):\n \"\"\"\n Mixin for param $name: $doc\n \"\"\"\n\n $name = Param(Params._dummy(), \"$name\", \"$doc\", typeConverter=$typ... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _gen_param_code | Generates Python code for a shared param class.
:param name: param name
:param doc: param doc
:param defaultValueStr: string representation of the default value
:return: code string | python/pyspark/ml/param/_shared_params_code_gen.py | def _gen_param_code(name, doc, defaultValueStr):
"""
Generates Python code for a shared param class.
:param name: param name
:param doc: param doc
:param defaultValueStr: string representation of the default value
:return: code string
"""
# TODO: How to correctly inherit instance attrib... | def _gen_param_code(name, doc, defaultValueStr):
"""
Generates Python code for a shared param class.
:param name: param name
:param doc: param doc
:param defaultValueStr: string representation of the default value
:return: code string
"""
# TODO: How to correctly inherit instance attrib... | [
"Generates",
"Python",
"code",
"for",
"a",
"shared",
"param",
"class",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/param/_shared_params_code_gen.py#L73-L101 | [
"def",
"_gen_param_code",
"(",
"name",
",",
"doc",
",",
"defaultValueStr",
")",
":",
"# TODO: How to correctly inherit instance attributes?",
"template",
"=",
"'''\n def set$Name(self, value):\n \"\"\"\n Sets the value of :py:attr:`$name`.\n \"\"\"\n return s... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | BisectingKMeans.train | Runs the bisecting k-means algorithm return the model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
The desired number of leaf clusters. The actual number could
be smaller if there are no divisible leaf clusters.
... | python/pyspark/mllib/clustering.py | def train(self, rdd, k=4, maxIterations=20, minDivisibleClusterSize=1.0, seed=-1888008604):
"""
Runs the bisecting k-means algorithm return the model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
The desired n... | def train(self, rdd, k=4, maxIterations=20, minDivisibleClusterSize=1.0, seed=-1888008604):
"""
Runs the bisecting k-means algorithm return the model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
The desired n... | [
"Runs",
"the",
"bisecting",
"k",
"-",
"means",
"algorithm",
"return",
"the",
"model",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L142-L167 | [
"def",
"train",
"(",
"self",
",",
"rdd",
",",
"k",
"=",
"4",
",",
"maxIterations",
"=",
"20",
",",
"minDivisibleClusterSize",
"=",
"1.0",
",",
"seed",
"=",
"-",
"1888008604",
")",
":",
"java_model",
"=",
"callMLlibFunc",
"(",
"\"trainBisectingKMeans\"",
",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | KMeans.train | Train a k-means clustering model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
Number of clusters to create.
:param maxIterations:
Maximum number of iterations allowed.
(default: 100)
:para... | python/pyspark/mllib/clustering.py | def train(cls, rdd, k, maxIterations=100, runs=1, initializationMode="k-means||",
seed=None, initializationSteps=2, epsilon=1e-4, initialModel=None):
"""
Train a k-means clustering model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequen... | def train(cls, rdd, k, maxIterations=100, runs=1, initializationMode="k-means||",
seed=None, initializationSteps=2, epsilon=1e-4, initialModel=None):
"""
Train a k-means clustering model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequen... | [
"Train",
"a",
"k",
"-",
"means",
"clustering",
"model",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L307-L357 | [
"def",
"train",
"(",
"cls",
",",
"rdd",
",",
"k",
",",
"maxIterations",
"=",
"100",
",",
"runs",
"=",
"1",
",",
"initializationMode",
"=",
"\"k-means||\"",
",",
"seed",
"=",
"None",
",",
"initializationSteps",
"=",
"2",
",",
"epsilon",
"=",
"1e-4",
","... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | GaussianMixture.train | Train a Gaussian Mixture clustering model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
Number of independent Gaussians in the mixture model.
:param convergenceTol:
Maximum change in log-likelihood at which ... | python/pyspark/mllib/clustering.py | def train(cls, rdd, k, convergenceTol=1e-3, maxIterations=100, seed=None, initialModel=None):
"""
Train a Gaussian Mixture clustering model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
Number of independent G... | def train(cls, rdd, k, convergenceTol=1e-3, maxIterations=100, seed=None, initialModel=None):
"""
Train a Gaussian Mixture clustering model.
:param rdd:
Training points as an `RDD` of `Vector` or convertible
sequence types.
:param k:
Number of independent G... | [
"Train",
"a",
"Gaussian",
"Mixture",
"clustering",
"model",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L515-L553 | [
"def",
"train",
"(",
"cls",
",",
"rdd",
",",
"k",
",",
"convergenceTol",
"=",
"1e-3",
",",
"maxIterations",
"=",
"100",
",",
"seed",
"=",
"None",
",",
"initialModel",
"=",
"None",
")",
":",
"initialModelWeights",
"=",
"None",
"initialModelMu",
"=",
"None... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | PowerIterationClusteringModel.load | Load a model from the given path. | python/pyspark/mllib/clustering.py | def load(cls, sc, path):
"""
Load a model from the given path.
"""
model = cls._load_java(sc, path)
wrapper =\
sc._jvm.org.apache.spark.mllib.api.python.PowerIterationClusteringModelWrapper(model)
return PowerIterationClusteringModel(wrapper) | def load(cls, sc, path):
"""
Load a model from the given path.
"""
model = cls._load_java(sc, path)
wrapper =\
sc._jvm.org.apache.spark.mllib.api.python.PowerIterationClusteringModelWrapper(model)
return PowerIterationClusteringModel(wrapper) | [
"Load",
"a",
"model",
"from",
"the",
"given",
"path",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L625-L632 | [
"def",
"load",
"(",
"cls",
",",
"sc",
",",
"path",
")",
":",
"model",
"=",
"cls",
".",
"_load_java",
"(",
"sc",
",",
"path",
")",
"wrapper",
"=",
"sc",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",
"mllib",
".",
"api",
".",
"python... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | PowerIterationClustering.train | r"""
:param rdd:
An RDD of (i, j, s\ :sub:`ij`\) tuples representing the
affinity matrix, which is the matrix A in the PIC paper. The
similarity s\ :sub:`ij`\ must be nonnegative. This is a symmetric
matrix and hence s\ :sub:`ij`\ = s\ :sub:`ji`\ For any (i, j) with
... | python/pyspark/mllib/clustering.py | def train(cls, rdd, k, maxIterations=100, initMode="random"):
r"""
:param rdd:
An RDD of (i, j, s\ :sub:`ij`\) tuples representing the
affinity matrix, which is the matrix A in the PIC paper. The
similarity s\ :sub:`ij`\ must be nonnegative. This is a symmetric
... | def train(cls, rdd, k, maxIterations=100, initMode="random"):
r"""
:param rdd:
An RDD of (i, j, s\ :sub:`ij`\) tuples representing the
affinity matrix, which is the matrix A in the PIC paper. The
similarity s\ :sub:`ij`\ must be nonnegative. This is a symmetric
... | [
"r",
":",
"param",
"rdd",
":",
"An",
"RDD",
"of",
"(",
"i",
"j",
"s",
"\\",
":",
"sub",
":",
"ij",
"\\",
")",
"tuples",
"representing",
"the",
"affinity",
"matrix",
"which",
"is",
"the",
"matrix",
"A",
"in",
"the",
"PIC",
"paper",
".",
"The",
"si... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L648-L671 | [
"def",
"train",
"(",
"cls",
",",
"rdd",
",",
"k",
",",
"maxIterations",
"=",
"100",
",",
"initMode",
"=",
"\"random\"",
")",
":",
"model",
"=",
"callMLlibFunc",
"(",
"\"trainPowerIterationClusteringModel\"",
",",
"rdd",
".",
"map",
"(",
"_convert_to_vector",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StreamingKMeansModel.update | Update the centroids, according to data
:param data:
RDD with new data for the model update.
:param decayFactor:
Forgetfulness of the previous centroids.
:param timeUnit:
Can be "batches" or "points". If points, then the decay factor
is raised to the powe... | python/pyspark/mllib/clustering.py | def update(self, data, decayFactor, timeUnit):
"""Update the centroids, according to data
:param data:
RDD with new data for the model update.
:param decayFactor:
Forgetfulness of the previous centroids.
:param timeUnit:
Can be "batches" or "points". If poi... | def update(self, data, decayFactor, timeUnit):
"""Update the centroids, according to data
:param data:
RDD with new data for the model update.
:param decayFactor:
Forgetfulness of the previous centroids.
:param timeUnit:
Can be "batches" or "points". If poi... | [
"Update",
"the",
"centroids",
"according",
"to",
"data"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L752-L777 | [
"def",
"update",
"(",
"self",
",",
"data",
",",
"decayFactor",
",",
"timeUnit",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"RDD",
")",
":",
"raise",
"TypeError",
"(",
"\"Data should be of an RDD, got %s.\"",
"%",
"type",
"(",
"data",
")",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StreamingKMeans.setHalfLife | Set number of batches after which the centroids of that
particular batch has half the weightage. | python/pyspark/mllib/clustering.py | def setHalfLife(self, halfLife, timeUnit):
"""
Set number of batches after which the centroids of that
particular batch has half the weightage.
"""
self._timeUnit = timeUnit
self._decayFactor = exp(log(0.5) / halfLife)
return self | def setHalfLife(self, halfLife, timeUnit):
"""
Set number of batches after which the centroids of that
particular batch has half the weightage.
"""
self._timeUnit = timeUnit
self._decayFactor = exp(log(0.5) / halfLife)
return self | [
"Set",
"number",
"of",
"batches",
"after",
"which",
"the",
"centroids",
"of",
"that",
"particular",
"batch",
"has",
"half",
"the",
"weightage",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L838-L845 | [
"def",
"setHalfLife",
"(",
"self",
",",
"halfLife",
",",
"timeUnit",
")",
":",
"self",
".",
"_timeUnit",
"=",
"timeUnit",
"self",
".",
"_decayFactor",
"=",
"exp",
"(",
"log",
"(",
"0.5",
")",
"/",
"halfLife",
")",
"return",
"self"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StreamingKMeans.setInitialCenters | Set initial centers. Should be set before calling trainOn. | python/pyspark/mllib/clustering.py | def setInitialCenters(self, centers, weights):
"""
Set initial centers. Should be set before calling trainOn.
"""
self._model = StreamingKMeansModel(centers, weights)
return self | def setInitialCenters(self, centers, weights):
"""
Set initial centers. Should be set before calling trainOn.
"""
self._model = StreamingKMeansModel(centers, weights)
return self | [
"Set",
"initial",
"centers",
".",
"Should",
"be",
"set",
"before",
"calling",
"trainOn",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L848-L853 | [
"def",
"setInitialCenters",
"(",
"self",
",",
"centers",
",",
"weights",
")",
":",
"self",
".",
"_model",
"=",
"StreamingKMeansModel",
"(",
"centers",
",",
"weights",
")",
"return",
"self"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StreamingKMeans.setRandomCenters | Set the initial centres to be random samples from
a gaussian population with constant weights. | python/pyspark/mllib/clustering.py | def setRandomCenters(self, dim, weight, seed):
"""
Set the initial centres to be random samples from
a gaussian population with constant weights.
"""
rng = random.RandomState(seed)
clusterCenters = rng.randn(self._k, dim)
clusterWeights = tile(weight, self._k)
... | def setRandomCenters(self, dim, weight, seed):
"""
Set the initial centres to be random samples from
a gaussian population with constant weights.
"""
rng = random.RandomState(seed)
clusterCenters = rng.randn(self._k, dim)
clusterWeights = tile(weight, self._k)
... | [
"Set",
"the",
"initial",
"centres",
"to",
"be",
"random",
"samples",
"from",
"a",
"gaussian",
"population",
"with",
"constant",
"weights",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L856-L865 | [
"def",
"setRandomCenters",
"(",
"self",
",",
"dim",
",",
"weight",
",",
"seed",
")",
":",
"rng",
"=",
"random",
".",
"RandomState",
"(",
"seed",
")",
"clusterCenters",
"=",
"rng",
".",
"randn",
"(",
"self",
".",
"_k",
",",
"dim",
")",
"clusterWeights",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StreamingKMeans.trainOn | Train the model on the incoming dstream. | python/pyspark/mllib/clustering.py | def trainOn(self, dstream):
"""Train the model on the incoming dstream."""
self._validate(dstream)
def update(rdd):
self._model.update(rdd, self._decayFactor, self._timeUnit)
dstream.foreachRDD(update) | def trainOn(self, dstream):
"""Train the model on the incoming dstream."""
self._validate(dstream)
def update(rdd):
self._model.update(rdd, self._decayFactor, self._timeUnit)
dstream.foreachRDD(update) | [
"Train",
"the",
"model",
"on",
"the",
"incoming",
"dstream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L868-L875 | [
"def",
"trainOn",
"(",
"self",
",",
"dstream",
")",
":",
"self",
".",
"_validate",
"(",
"dstream",
")",
"def",
"update",
"(",
"rdd",
")",
":",
"self",
".",
"_model",
".",
"update",
"(",
"rdd",
",",
"self",
".",
"_decayFactor",
",",
"self",
".",
"_t... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StreamingKMeans.predictOn | Make predictions on a dstream.
Returns a transformed dstream object | python/pyspark/mllib/clustering.py | def predictOn(self, dstream):
"""
Make predictions on a dstream.
Returns a transformed dstream object
"""
self._validate(dstream)
return dstream.map(lambda x: self._model.predict(x)) | def predictOn(self, dstream):
"""
Make predictions on a dstream.
Returns a transformed dstream object
"""
self._validate(dstream)
return dstream.map(lambda x: self._model.predict(x)) | [
"Make",
"predictions",
"on",
"a",
"dstream",
".",
"Returns",
"a",
"transformed",
"dstream",
"object"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L878-L884 | [
"def",
"predictOn",
"(",
"self",
",",
"dstream",
")",
":",
"self",
".",
"_validate",
"(",
"dstream",
")",
"return",
"dstream",
".",
"map",
"(",
"lambda",
"x",
":",
"self",
".",
"_model",
".",
"predict",
"(",
"x",
")",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | StreamingKMeans.predictOnValues | Make predictions on a keyed dstream.
Returns a transformed dstream object. | python/pyspark/mllib/clustering.py | def predictOnValues(self, dstream):
"""
Make predictions on a keyed dstream.
Returns a transformed dstream object.
"""
self._validate(dstream)
return dstream.mapValues(lambda x: self._model.predict(x)) | def predictOnValues(self, dstream):
"""
Make predictions on a keyed dstream.
Returns a transformed dstream object.
"""
self._validate(dstream)
return dstream.mapValues(lambda x: self._model.predict(x)) | [
"Make",
"predictions",
"on",
"a",
"keyed",
"dstream",
".",
"Returns",
"a",
"transformed",
"dstream",
"object",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L887-L893 | [
"def",
"predictOnValues",
"(",
"self",
",",
"dstream",
")",
":",
"self",
".",
"_validate",
"(",
"dstream",
")",
"return",
"dstream",
".",
"mapValues",
"(",
"lambda",
"x",
":",
"self",
".",
"_model",
".",
"predict",
"(",
"x",
")",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | LDAModel.describeTopics | Return the topics described by weighted terms.
WARNING: If vocabSize and k are large, this can return a large object!
:param maxTermsPerTopic:
Maximum number of terms to collect for each topic.
(default: vocabulary size)
:return:
Array over topics. Each topic is r... | python/pyspark/mllib/clustering.py | def describeTopics(self, maxTermsPerTopic=None):
"""Return the topics described by weighted terms.
WARNING: If vocabSize and k are large, this can return a large object!
:param maxTermsPerTopic:
Maximum number of terms to collect for each topic.
(default: vocabulary size)
... | def describeTopics(self, maxTermsPerTopic=None):
"""Return the topics described by weighted terms.
WARNING: If vocabSize and k are large, this can return a large object!
:param maxTermsPerTopic:
Maximum number of terms to collect for each topic.
(default: vocabulary size)
... | [
"Return",
"the",
"topics",
"described",
"by",
"weighted",
"terms",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L955-L972 | [
"def",
"describeTopics",
"(",
"self",
",",
"maxTermsPerTopic",
"=",
"None",
")",
":",
"if",
"maxTermsPerTopic",
"is",
"None",
":",
"topics",
"=",
"self",
".",
"call",
"(",
"\"describeTopics\"",
")",
"else",
":",
"topics",
"=",
"self",
".",
"call",
"(",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | LDAModel.load | Load the LDAModel from disk.
:param sc:
SparkContext.
:param path:
Path to where the model is stored. | python/pyspark/mllib/clustering.py | def load(cls, sc, path):
"""Load the LDAModel from disk.
:param sc:
SparkContext.
:param path:
Path to where the model is stored.
"""
if not isinstance(sc, SparkContext):
raise TypeError("sc should be a SparkContext, got type %s" % type(sc))
... | def load(cls, sc, path):
"""Load the LDAModel from disk.
:param sc:
SparkContext.
:param path:
Path to where the model is stored.
"""
if not isinstance(sc, SparkContext):
raise TypeError("sc should be a SparkContext, got type %s" % type(sc))
... | [
"Load",
"the",
"LDAModel",
"from",
"disk",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L976-L989 | [
"def",
"load",
"(",
"cls",
",",
"sc",
",",
"path",
")",
":",
"if",
"not",
"isinstance",
"(",
"sc",
",",
"SparkContext",
")",
":",
"raise",
"TypeError",
"(",
"\"sc should be a SparkContext, got type %s\"",
"%",
"type",
"(",
"sc",
")",
")",
"if",
"not",
"i... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | LDA.train | Train a LDA model.
:param rdd:
RDD of documents, which are tuples of document IDs and term
(word) count vectors. The term count vectors are "bags of
words" with a fixed-size vocabulary (where the vocabulary size
is the length of the vector). Document IDs must be unique
... | python/pyspark/mllib/clustering.py | def train(cls, rdd, k=10, maxIterations=20, docConcentration=-1.0,
topicConcentration=-1.0, seed=None, checkpointInterval=10, optimizer="em"):
"""Train a LDA model.
:param rdd:
RDD of documents, which are tuples of document IDs and term
(word) count vectors. The term c... | def train(cls, rdd, k=10, maxIterations=20, docConcentration=-1.0,
topicConcentration=-1.0, seed=None, checkpointInterval=10, optimizer="em"):
"""Train a LDA model.
:param rdd:
RDD of documents, which are tuples of document IDs and term
(word) count vectors. The term c... | [
"Train",
"a",
"LDA",
"model",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L999-L1039 | [
"def",
"train",
"(",
"cls",
",",
"rdd",
",",
"k",
"=",
"10",
",",
"maxIterations",
"=",
"20",
",",
"docConcentration",
"=",
"-",
"1.0",
",",
"topicConcentration",
"=",
"-",
"1.0",
",",
"seed",
"=",
"None",
",",
"checkpointInterval",
"=",
"10",
",",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _to_java_object_rdd | Return a JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever the
RDD is serialized in batch or not. | python/pyspark/mllib/common.py | def _to_java_object_rdd(rdd):
""" Return a JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever the
RDD is serialized in batch or not.
"""
rdd = rdd._reserialize(AutoBatchedSerializer(PickleSerializer()))
return rdd.ctx._jvm.org.apache.spark.... | def _to_java_object_rdd(rdd):
""" Return a JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever the
RDD is serialized in batch or not.
"""
rdd = rdd._reserialize(AutoBatchedSerializer(PickleSerializer()))
return rdd.ctx._jvm.org.apache.spark.... | [
"Return",
"a",
"JavaRDD",
"of",
"Object",
"by",
"unpickling"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/common.py#L62-L69 | [
"def",
"_to_java_object_rdd",
"(",
"rdd",
")",
":",
"rdd",
"=",
"rdd",
".",
"_reserialize",
"(",
"AutoBatchedSerializer",
"(",
"PickleSerializer",
"(",
")",
")",
")",
"return",
"rdd",
".",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | _py2java | Convert Python object into Java | python/pyspark/mllib/common.py | def _py2java(sc, obj):
""" Convert Python object into Java """
if isinstance(obj, RDD):
obj = _to_java_object_rdd(obj)
elif isinstance(obj, DataFrame):
obj = obj._jdf
elif isinstance(obj, SparkContext):
obj = obj._jsc
elif isinstance(obj, list):
obj = [_py2java(sc, x)... | def _py2java(sc, obj):
""" Convert Python object into Java """
if isinstance(obj, RDD):
obj = _to_java_object_rdd(obj)
elif isinstance(obj, DataFrame):
obj = obj._jdf
elif isinstance(obj, SparkContext):
obj = obj._jsc
elif isinstance(obj, list):
obj = [_py2java(sc, x)... | [
"Convert",
"Python",
"object",
"into",
"Java"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/common.py#L72-L89 | [
"def",
"_py2java",
"(",
"sc",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"RDD",
")",
":",
"obj",
"=",
"_to_java_object_rdd",
"(",
"obj",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"DataFrame",
")",
":",
"obj",
"=",
"obj",
".",
"_jd... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | callJavaFunc | Call Java Function | python/pyspark/mllib/common.py | def callJavaFunc(sc, func, *args):
""" Call Java Function """
args = [_py2java(sc, a) for a in args]
return _java2py(sc, func(*args)) | def callJavaFunc(sc, func, *args):
""" Call Java Function """
args = [_py2java(sc, a) for a in args]
return _java2py(sc, func(*args)) | [
"Call",
"Java",
"Function"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/common.py#L120-L123 | [
"def",
"callJavaFunc",
"(",
"sc",
",",
"func",
",",
"*",
"args",
")",
":",
"args",
"=",
"[",
"_py2java",
"(",
"sc",
",",
"a",
")",
"for",
"a",
"in",
"args",
"]",
"return",
"_java2py",
"(",
"sc",
",",
"func",
"(",
"*",
"args",
")",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | callMLlibFunc | Call API in PythonMLLibAPI | python/pyspark/mllib/common.py | def callMLlibFunc(name, *args):
""" Call API in PythonMLLibAPI """
sc = SparkContext.getOrCreate()
api = getattr(sc._jvm.PythonMLLibAPI(), name)
return callJavaFunc(sc, api, *args) | def callMLlibFunc(name, *args):
""" Call API in PythonMLLibAPI """
sc = SparkContext.getOrCreate()
api = getattr(sc._jvm.PythonMLLibAPI(), name)
return callJavaFunc(sc, api, *args) | [
"Call",
"API",
"in",
"PythonMLLibAPI"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/common.py#L126-L130 | [
"def",
"callMLlibFunc",
"(",
"name",
",",
"*",
"args",
")",
":",
"sc",
"=",
"SparkContext",
".",
"getOrCreate",
"(",
")",
"api",
"=",
"getattr",
"(",
"sc",
".",
"_jvm",
".",
"PythonMLLibAPI",
"(",
")",
",",
"name",
")",
"return",
"callJavaFunc",
"(",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | inherit_doc | A decorator that makes a class inherit documentation from its parents. | python/pyspark/mllib/common.py | def inherit_doc(cls):
"""
A decorator that makes a class inherit documentation from its parents.
"""
for name, func in vars(cls).items():
# only inherit docstring for public functions
if name.startswith("_"):
continue
if not func.__doc__:
for parent in cls... | def inherit_doc(cls):
"""
A decorator that makes a class inherit documentation from its parents.
"""
for name, func in vars(cls).items():
# only inherit docstring for public functions
if name.startswith("_"):
continue
if not func.__doc__:
for parent in cls... | [
"A",
"decorator",
"that",
"makes",
"a",
"class",
"inherit",
"documentation",
"from",
"its",
"parents",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/common.py#L149-L163 | [
"def",
"inherit_doc",
"(",
"cls",
")",
":",
"for",
"name",
",",
"func",
"in",
"vars",
"(",
"cls",
")",
".",
"items",
"(",
")",
":",
"# only inherit docstring for public functions",
"if",
"name",
".",
"startswith",
"(",
"\"_\"",
")",
":",
"continue",
"if",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | JavaModelWrapper.call | Call method of java_model | python/pyspark/mllib/common.py | def call(self, name, *a):
"""Call method of java_model"""
return callJavaFunc(self._sc, getattr(self._java_model, name), *a) | def call(self, name, *a):
"""Call method of java_model"""
return callJavaFunc(self._sc, getattr(self._java_model, name), *a) | [
"Call",
"method",
"of",
"java_model"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/common.py#L144-L146 | [
"def",
"call",
"(",
"self",
",",
"name",
",",
"*",
"a",
")",
":",
"return",
"callJavaFunc",
"(",
"self",
".",
"_sc",
",",
"getattr",
"(",
"self",
".",
"_java_model",
",",
"name",
")",
",",
"*",
"a",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.count | Return a new DStream in which each RDD has a single element
generated by counting each RDD of this DStream. | python/pyspark/streaming/dstream.py | def count(self):
"""
Return a new DStream in which each RDD has a single element
generated by counting each RDD of this DStream.
"""
return self.mapPartitions(lambda i: [sum(1 for _ in i)]).reduce(operator.add) | def count(self):
"""
Return a new DStream in which each RDD has a single element
generated by counting each RDD of this DStream.
"""
return self.mapPartitions(lambda i: [sum(1 for _ in i)]).reduce(operator.add) | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"has",
"a",
"single",
"element",
"generated",
"by",
"counting",
"each",
"RDD",
"of",
"this",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L73-L78 | [
"def",
"count",
"(",
"self",
")",
":",
"return",
"self",
".",
"mapPartitions",
"(",
"lambda",
"i",
":",
"[",
"sum",
"(",
"1",
"for",
"_",
"in",
"i",
")",
"]",
")",
".",
"reduce",
"(",
"operator",
".",
"add",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.filter | Return a new DStream containing only the elements that satisfy predicate. | python/pyspark/streaming/dstream.py | def filter(self, f):
"""
Return a new DStream containing only the elements that satisfy predicate.
"""
def func(iterator):
return filter(f, iterator)
return self.mapPartitions(func, True) | def filter(self, f):
"""
Return a new DStream containing only the elements that satisfy predicate.
"""
def func(iterator):
return filter(f, iterator)
return self.mapPartitions(func, True) | [
"Return",
"a",
"new",
"DStream",
"containing",
"only",
"the",
"elements",
"that",
"satisfy",
"predicate",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L80-L86 | [
"def",
"filter",
"(",
"self",
",",
"f",
")",
":",
"def",
"func",
"(",
"iterator",
")",
":",
"return",
"filter",
"(",
"f",
",",
"iterator",
")",
"return",
"self",
".",
"mapPartitions",
"(",
"func",
",",
"True",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.map | Return a new DStream by applying a function to each element of DStream. | python/pyspark/streaming/dstream.py | def map(self, f, preservesPartitioning=False):
"""
Return a new DStream by applying a function to each element of DStream.
"""
def func(iterator):
return map(f, iterator)
return self.mapPartitions(func, preservesPartitioning) | def map(self, f, preservesPartitioning=False):
"""
Return a new DStream by applying a function to each element of DStream.
"""
def func(iterator):
return map(f, iterator)
return self.mapPartitions(func, preservesPartitioning) | [
"Return",
"a",
"new",
"DStream",
"by",
"applying",
"a",
"function",
"to",
"each",
"element",
"of",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L97-L103 | [
"def",
"map",
"(",
"self",
",",
"f",
",",
"preservesPartitioning",
"=",
"False",
")",
":",
"def",
"func",
"(",
"iterator",
")",
":",
"return",
"map",
"(",
"f",
",",
"iterator",
")",
"return",
"self",
".",
"mapPartitions",
"(",
"func",
",",
"preservesPa... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.mapPartitionsWithIndex | Return a new DStream in which each RDD is generated by applying
mapPartitionsWithIndex() to each RDDs of this DStream. | python/pyspark/streaming/dstream.py | def mapPartitionsWithIndex(self, f, preservesPartitioning=False):
"""
Return a new DStream in which each RDD is generated by applying
mapPartitionsWithIndex() to each RDDs of this DStream.
"""
return self.transform(lambda rdd: rdd.mapPartitionsWithIndex(f, preservesPartitioning)) | def mapPartitionsWithIndex(self, f, preservesPartitioning=False):
"""
Return a new DStream in which each RDD is generated by applying
mapPartitionsWithIndex() to each RDDs of this DStream.
"""
return self.transform(lambda rdd: rdd.mapPartitionsWithIndex(f, preservesPartitioning)) | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"is",
"generated",
"by",
"applying",
"mapPartitionsWithIndex",
"()",
"to",
"each",
"RDDs",
"of",
"this",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L114-L119 | [
"def",
"mapPartitionsWithIndex",
"(",
"self",
",",
"f",
",",
"preservesPartitioning",
"=",
"False",
")",
":",
"return",
"self",
".",
"transform",
"(",
"lambda",
"rdd",
":",
"rdd",
".",
"mapPartitionsWithIndex",
"(",
"f",
",",
"preservesPartitioning",
")",
")"
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.reduce | Return a new DStream in which each RDD has a single element
generated by reducing each RDD of this DStream. | python/pyspark/streaming/dstream.py | def reduce(self, func):
"""
Return a new DStream in which each RDD has a single element
generated by reducing each RDD of this DStream.
"""
return self.map(lambda x: (None, x)).reduceByKey(func, 1).map(lambda x: x[1]) | def reduce(self, func):
"""
Return a new DStream in which each RDD has a single element
generated by reducing each RDD of this DStream.
"""
return self.map(lambda x: (None, x)).reduceByKey(func, 1).map(lambda x: x[1]) | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"has",
"a",
"single",
"element",
"generated",
"by",
"reducing",
"each",
"RDD",
"of",
"this",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L121-L126 | [
"def",
"reduce",
"(",
"self",
",",
"func",
")",
":",
"return",
"self",
".",
"map",
"(",
"lambda",
"x",
":",
"(",
"None",
",",
"x",
")",
")",
".",
"reduceByKey",
"(",
"func",
",",
"1",
")",
".",
"map",
"(",
"lambda",
"x",
":",
"x",
"[",
"1",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.reduceByKey | Return a new DStream by applying reduceByKey to each RDD. | python/pyspark/streaming/dstream.py | def reduceByKey(self, func, numPartitions=None):
"""
Return a new DStream by applying reduceByKey to each RDD.
"""
if numPartitions is None:
numPartitions = self._sc.defaultParallelism
return self.combineByKey(lambda x: x, func, func, numPartitions) | def reduceByKey(self, func, numPartitions=None):
"""
Return a new DStream by applying reduceByKey to each RDD.
"""
if numPartitions is None:
numPartitions = self._sc.defaultParallelism
return self.combineByKey(lambda x: x, func, func, numPartitions) | [
"Return",
"a",
"new",
"DStream",
"by",
"applying",
"reduceByKey",
"to",
"each",
"RDD",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L128-L134 | [
"def",
"reduceByKey",
"(",
"self",
",",
"func",
",",
"numPartitions",
"=",
"None",
")",
":",
"if",
"numPartitions",
"is",
"None",
":",
"numPartitions",
"=",
"self",
".",
"_sc",
".",
"defaultParallelism",
"return",
"self",
".",
"combineByKey",
"(",
"lambda",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.combineByKey | Return a new DStream by applying combineByKey to each RDD. | python/pyspark/streaming/dstream.py | def combineByKey(self, createCombiner, mergeValue, mergeCombiners,
numPartitions=None):
"""
Return a new DStream by applying combineByKey to each RDD.
"""
if numPartitions is None:
numPartitions = self._sc.defaultParallelism
def func(rdd):
... | def combineByKey(self, createCombiner, mergeValue, mergeCombiners,
numPartitions=None):
"""
Return a new DStream by applying combineByKey to each RDD.
"""
if numPartitions is None:
numPartitions = self._sc.defaultParallelism
def func(rdd):
... | [
"Return",
"a",
"new",
"DStream",
"by",
"applying",
"combineByKey",
"to",
"each",
"RDD",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L136-L146 | [
"def",
"combineByKey",
"(",
"self",
",",
"createCombiner",
",",
"mergeValue",
",",
"mergeCombiners",
",",
"numPartitions",
"=",
"None",
")",
":",
"if",
"numPartitions",
"is",
"None",
":",
"numPartitions",
"=",
"self",
".",
"_sc",
".",
"defaultParallelism",
"de... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.partitionBy | Return a copy of the DStream in which each RDD are partitioned
using the specified partitioner. | python/pyspark/streaming/dstream.py | def partitionBy(self, numPartitions, partitionFunc=portable_hash):
"""
Return a copy of the DStream in which each RDD are partitioned
using the specified partitioner.
"""
return self.transform(lambda rdd: rdd.partitionBy(numPartitions, partitionFunc)) | def partitionBy(self, numPartitions, partitionFunc=portable_hash):
"""
Return a copy of the DStream in which each RDD are partitioned
using the specified partitioner.
"""
return self.transform(lambda rdd: rdd.partitionBy(numPartitions, partitionFunc)) | [
"Return",
"a",
"copy",
"of",
"the",
"DStream",
"in",
"which",
"each",
"RDD",
"are",
"partitioned",
"using",
"the",
"specified",
"partitioner",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L148-L153 | [
"def",
"partitionBy",
"(",
"self",
",",
"numPartitions",
",",
"partitionFunc",
"=",
"portable_hash",
")",
":",
"return",
"self",
".",
"transform",
"(",
"lambda",
"rdd",
":",
"rdd",
".",
"partitionBy",
"(",
"numPartitions",
",",
"partitionFunc",
")",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.foreachRDD | Apply a function to each RDD in this DStream. | python/pyspark/streaming/dstream.py | def foreachRDD(self, func):
"""
Apply a function to each RDD in this DStream.
"""
if func.__code__.co_argcount == 1:
old_func = func
func = lambda t, rdd: old_func(rdd)
jfunc = TransformFunction(self._sc, func, self._jrdd_deserializer)
api = self._... | def foreachRDD(self, func):
"""
Apply a function to each RDD in this DStream.
"""
if func.__code__.co_argcount == 1:
old_func = func
func = lambda t, rdd: old_func(rdd)
jfunc = TransformFunction(self._sc, func, self._jrdd_deserializer)
api = self._... | [
"Apply",
"a",
"function",
"to",
"each",
"RDD",
"in",
"this",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L155-L164 | [
"def",
"foreachRDD",
"(",
"self",
",",
"func",
")",
":",
"if",
"func",
".",
"__code__",
".",
"co_argcount",
"==",
"1",
":",
"old_func",
"=",
"func",
"func",
"=",
"lambda",
"t",
",",
"rdd",
":",
"old_func",
"(",
"rdd",
")",
"jfunc",
"=",
"TransformFun... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.pprint | Print the first num elements of each RDD generated in this DStream.
@param num: the number of elements from the first will be printed. | python/pyspark/streaming/dstream.py | def pprint(self, num=10):
"""
Print the first num elements of each RDD generated in this DStream.
@param num: the number of elements from the first will be printed.
"""
def takeAndPrint(time, rdd):
taken = rdd.take(num + 1)
print("------------------------... | def pprint(self, num=10):
"""
Print the first num elements of each RDD generated in this DStream.
@param num: the number of elements from the first will be printed.
"""
def takeAndPrint(time, rdd):
taken = rdd.take(num + 1)
print("------------------------... | [
"Print",
"the",
"first",
"num",
"elements",
"of",
"each",
"RDD",
"generated",
"in",
"this",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L166-L183 | [
"def",
"pprint",
"(",
"self",
",",
"num",
"=",
"10",
")",
":",
"def",
"takeAndPrint",
"(",
"time",
",",
"rdd",
")",
":",
"taken",
"=",
"rdd",
".",
"take",
"(",
"num",
"+",
"1",
")",
"print",
"(",
"\"-------------------------------------------\"",
")",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.persist | Persist the RDDs of this DStream with the given storage level | python/pyspark/streaming/dstream.py | def persist(self, storageLevel):
"""
Persist the RDDs of this DStream with the given storage level
"""
self.is_cached = True
javaStorageLevel = self._sc._getJavaStorageLevel(storageLevel)
self._jdstream.persist(javaStorageLevel)
return self | def persist(self, storageLevel):
"""
Persist the RDDs of this DStream with the given storage level
"""
self.is_cached = True
javaStorageLevel = self._sc._getJavaStorageLevel(storageLevel)
self._jdstream.persist(javaStorageLevel)
return self | [
"Persist",
"the",
"RDDs",
"of",
"this",
"DStream",
"with",
"the",
"given",
"storage",
"level"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L219-L226 | [
"def",
"persist",
"(",
"self",
",",
"storageLevel",
")",
":",
"self",
".",
"is_cached",
"=",
"True",
"javaStorageLevel",
"=",
"self",
".",
"_sc",
".",
"_getJavaStorageLevel",
"(",
"storageLevel",
")",
"self",
".",
"_jdstream",
".",
"persist",
"(",
"javaStora... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.checkpoint | Enable periodic checkpointing of RDDs of this DStream
@param interval: time in seconds, after each period of that, generated
RDD will be checkpointed | python/pyspark/streaming/dstream.py | def checkpoint(self, interval):
"""
Enable periodic checkpointing of RDDs of this DStream
@param interval: time in seconds, after each period of that, generated
RDD will be checkpointed
"""
self.is_checkpointed = True
self._jdstream.checkpoint(se... | def checkpoint(self, interval):
"""
Enable periodic checkpointing of RDDs of this DStream
@param interval: time in seconds, after each period of that, generated
RDD will be checkpointed
"""
self.is_checkpointed = True
self._jdstream.checkpoint(se... | [
"Enable",
"periodic",
"checkpointing",
"of",
"RDDs",
"of",
"this",
"DStream"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L228-L237 | [
"def",
"checkpoint",
"(",
"self",
",",
"interval",
")",
":",
"self",
".",
"is_checkpointed",
"=",
"True",
"self",
".",
"_jdstream",
".",
"checkpoint",
"(",
"self",
".",
"_ssc",
".",
"_jduration",
"(",
"interval",
")",
")",
"return",
"self"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.groupByKey | Return a new DStream by applying groupByKey on each RDD. | python/pyspark/streaming/dstream.py | def groupByKey(self, numPartitions=None):
"""
Return a new DStream by applying groupByKey on each RDD.
"""
if numPartitions is None:
numPartitions = self._sc.defaultParallelism
return self.transform(lambda rdd: rdd.groupByKey(numPartitions)) | def groupByKey(self, numPartitions=None):
"""
Return a new DStream by applying groupByKey on each RDD.
"""
if numPartitions is None:
numPartitions = self._sc.defaultParallelism
return self.transform(lambda rdd: rdd.groupByKey(numPartitions)) | [
"Return",
"a",
"new",
"DStream",
"by",
"applying",
"groupByKey",
"on",
"each",
"RDD",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L239-L245 | [
"def",
"groupByKey",
"(",
"self",
",",
"numPartitions",
"=",
"None",
")",
":",
"if",
"numPartitions",
"is",
"None",
":",
"numPartitions",
"=",
"self",
".",
"_sc",
".",
"defaultParallelism",
"return",
"self",
".",
"transform",
"(",
"lambda",
"rdd",
":",
"rd... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.countByValue | Return a new DStream in which each RDD contains the counts of each
distinct value in each RDD of this DStream. | python/pyspark/streaming/dstream.py | def countByValue(self):
"""
Return a new DStream in which each RDD contains the counts of each
distinct value in each RDD of this DStream.
"""
return self.map(lambda x: (x, 1)).reduceByKey(lambda x, y: x+y) | def countByValue(self):
"""
Return a new DStream in which each RDD contains the counts of each
distinct value in each RDD of this DStream.
"""
return self.map(lambda x: (x, 1)).reduceByKey(lambda x, y: x+y) | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"contains",
"the",
"counts",
"of",
"each",
"distinct",
"value",
"in",
"each",
"RDD",
"of",
"this",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L247-L252 | [
"def",
"countByValue",
"(",
"self",
")",
":",
"return",
"self",
".",
"map",
"(",
"lambda",
"x",
":",
"(",
"x",
",",
"1",
")",
")",
".",
"reduceByKey",
"(",
"lambda",
"x",
",",
"y",
":",
"x",
"+",
"y",
")"
] | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.saveAsTextFiles | Save each RDD in this DStream as at text file, using string
representation of elements. | python/pyspark/streaming/dstream.py | def saveAsTextFiles(self, prefix, suffix=None):
"""
Save each RDD in this DStream as at text file, using string
representation of elements.
"""
def saveAsTextFile(t, rdd):
path = rddToFileName(prefix, suffix, t)
try:
rdd.saveAsTextFile(path... | def saveAsTextFiles(self, prefix, suffix=None):
"""
Save each RDD in this DStream as at text file, using string
representation of elements.
"""
def saveAsTextFile(t, rdd):
path = rddToFileName(prefix, suffix, t)
try:
rdd.saveAsTextFile(path... | [
"Save",
"each",
"RDD",
"in",
"this",
"DStream",
"as",
"at",
"text",
"file",
"using",
"string",
"representation",
"of",
"elements",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L254-L268 | [
"def",
"saveAsTextFiles",
"(",
"self",
",",
"prefix",
",",
"suffix",
"=",
"None",
")",
":",
"def",
"saveAsTextFile",
"(",
"t",
",",
"rdd",
")",
":",
"path",
"=",
"rddToFileName",
"(",
"prefix",
",",
"suffix",
",",
"t",
")",
"try",
":",
"rdd",
".",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.transform | Return a new DStream in which each RDD is generated by applying a function
on each RDD of this DStream.
`func` can have one argument of `rdd`, or have two arguments of
(`time`, `rdd`) | python/pyspark/streaming/dstream.py | def transform(self, func):
"""
Return a new DStream in which each RDD is generated by applying a function
on each RDD of this DStream.
`func` can have one argument of `rdd`, or have two arguments of
(`time`, `rdd`)
"""
if func.__code__.co_argcount == 1:
... | def transform(self, func):
"""
Return a new DStream in which each RDD is generated by applying a function
on each RDD of this DStream.
`func` can have one argument of `rdd`, or have two arguments of
(`time`, `rdd`)
"""
if func.__code__.co_argcount == 1:
... | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"is",
"generated",
"by",
"applying",
"a",
"function",
"on",
"each",
"RDD",
"of",
"this",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L287-L299 | [
"def",
"transform",
"(",
"self",
",",
"func",
")",
":",
"if",
"func",
".",
"__code__",
".",
"co_argcount",
"==",
"1",
":",
"oldfunc",
"=",
"func",
"func",
"=",
"lambda",
"t",
",",
"rdd",
":",
"oldfunc",
"(",
"rdd",
")",
"assert",
"func",
".",
"__co... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.transformWith | Return a new DStream in which each RDD is generated by applying a function
on each RDD of this DStream and 'other' DStream.
`func` can have two arguments of (`rdd_a`, `rdd_b`) or have three
arguments of (`time`, `rdd_a`, `rdd_b`) | python/pyspark/streaming/dstream.py | def transformWith(self, func, other, keepSerializer=False):
"""
Return a new DStream in which each RDD is generated by applying a function
on each RDD of this DStream and 'other' DStream.
`func` can have two arguments of (`rdd_a`, `rdd_b`) or have three
arguments of (`time`, `rd... | def transformWith(self, func, other, keepSerializer=False):
"""
Return a new DStream in which each RDD is generated by applying a function
on each RDD of this DStream and 'other' DStream.
`func` can have two arguments of (`rdd_a`, `rdd_b`) or have three
arguments of (`time`, `rd... | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"is",
"generated",
"by",
"applying",
"a",
"function",
"on",
"each",
"RDD",
"of",
"this",
"DStream",
"and",
"other",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L301-L317 | [
"def",
"transformWith",
"(",
"self",
",",
"func",
",",
"other",
",",
"keepSerializer",
"=",
"False",
")",
":",
"if",
"func",
".",
"__code__",
".",
"co_argcount",
"==",
"2",
":",
"oldfunc",
"=",
"func",
"func",
"=",
"lambda",
"t",
",",
"a",
",",
"b",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.union | Return a new DStream by unifying data of another DStream with this DStream.
@param other: Another DStream having the same interval (i.e., slideDuration)
as this DStream. | python/pyspark/streaming/dstream.py | def union(self, other):
"""
Return a new DStream by unifying data of another DStream with this DStream.
@param other: Another DStream having the same interval (i.e., slideDuration)
as this DStream.
"""
if self._slideDuration != other._slideDuration:
... | def union(self, other):
"""
Return a new DStream by unifying data of another DStream with this DStream.
@param other: Another DStream having the same interval (i.e., slideDuration)
as this DStream.
"""
if self._slideDuration != other._slideDuration:
... | [
"Return",
"a",
"new",
"DStream",
"by",
"unifying",
"data",
"of",
"another",
"DStream",
"with",
"this",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L332-L341 | [
"def",
"union",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"_slideDuration",
"!=",
"other",
".",
"_slideDuration",
":",
"raise",
"ValueError",
"(",
"\"the two DStream should have same slide duration\"",
")",
"return",
"self",
".",
"transformWith",
"("... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.cogroup | Return a new DStream by applying 'cogroup' between RDDs of this
DStream and `other` DStream.
Hash partitioning is used to generate the RDDs with `numPartitions` partitions. | python/pyspark/streaming/dstream.py | def cogroup(self, other, numPartitions=None):
"""
Return a new DStream by applying 'cogroup' between RDDs of this
DStream and `other` DStream.
Hash partitioning is used to generate the RDDs with `numPartitions` partitions.
"""
if numPartitions is None:
numPar... | def cogroup(self, other, numPartitions=None):
"""
Return a new DStream by applying 'cogroup' between RDDs of this
DStream and `other` DStream.
Hash partitioning is used to generate the RDDs with `numPartitions` partitions.
"""
if numPartitions is None:
numPar... | [
"Return",
"a",
"new",
"DStream",
"by",
"applying",
"cogroup",
"between",
"RDDs",
"of",
"this",
"DStream",
"and",
"other",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L343-L352 | [
"def",
"cogroup",
"(",
"self",
",",
"other",
",",
"numPartitions",
"=",
"None",
")",
":",
"if",
"numPartitions",
"is",
"None",
":",
"numPartitions",
"=",
"self",
".",
"_sc",
".",
"defaultParallelism",
"return",
"self",
".",
"transformWith",
"(",
"lambda",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream._jtime | Convert datetime or unix_timestamp into Time | python/pyspark/streaming/dstream.py | def _jtime(self, timestamp):
""" Convert datetime or unix_timestamp into Time
"""
if isinstance(timestamp, datetime):
timestamp = time.mktime(timestamp.timetuple())
return self._sc._jvm.Time(long(timestamp * 1000)) | def _jtime(self, timestamp):
""" Convert datetime or unix_timestamp into Time
"""
if isinstance(timestamp, datetime):
timestamp = time.mktime(timestamp.timetuple())
return self._sc._jvm.Time(long(timestamp * 1000)) | [
"Convert",
"datetime",
"or",
"unix_timestamp",
"into",
"Time"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L402-L407 | [
"def",
"_jtime",
"(",
"self",
",",
"timestamp",
")",
":",
"if",
"isinstance",
"(",
"timestamp",
",",
"datetime",
")",
":",
"timestamp",
"=",
"time",
".",
"mktime",
"(",
"timestamp",
".",
"timetuple",
"(",
")",
")",
"return",
"self",
".",
"_sc",
".",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.slice | Return all the RDDs between 'begin' to 'end' (both included)
`begin`, `end` could be datetime.datetime() or unix_timestamp | python/pyspark/streaming/dstream.py | def slice(self, begin, end):
"""
Return all the RDDs between 'begin' to 'end' (both included)
`begin`, `end` could be datetime.datetime() or unix_timestamp
"""
jrdds = self._jdstream.slice(self._jtime(begin), self._jtime(end))
return [RDD(jrdd, self._sc, self._jrdd_deser... | def slice(self, begin, end):
"""
Return all the RDDs between 'begin' to 'end' (both included)
`begin`, `end` could be datetime.datetime() or unix_timestamp
"""
jrdds = self._jdstream.slice(self._jtime(begin), self._jtime(end))
return [RDD(jrdd, self._sc, self._jrdd_deser... | [
"Return",
"all",
"the",
"RDDs",
"between",
"begin",
"to",
"end",
"(",
"both",
"included",
")"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L409-L416 | [
"def",
"slice",
"(",
"self",
",",
"begin",
",",
"end",
")",
":",
"jrdds",
"=",
"self",
".",
"_jdstream",
".",
"slice",
"(",
"self",
".",
"_jtime",
"(",
"begin",
")",
",",
"self",
".",
"_jtime",
"(",
"end",
")",
")",
"return",
"[",
"RDD",
"(",
"... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.window | Return a new DStream in which each RDD contains all the elements in seen in a
sliding window of time over this DStream.
@param windowDuration: width of the window; must be a multiple of this DStream's
batching interval
@param slideDuration: sliding interval of the... | python/pyspark/streaming/dstream.py | def window(self, windowDuration, slideDuration=None):
"""
Return a new DStream in which each RDD contains all the elements in seen in a
sliding window of time over this DStream.
@param windowDuration: width of the window; must be a multiple of this DStream's
... | def window(self, windowDuration, slideDuration=None):
"""
Return a new DStream in which each RDD contains all the elements in seen in a
sliding window of time over this DStream.
@param windowDuration: width of the window; must be a multiple of this DStream's
... | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"contains",
"all",
"the",
"elements",
"in",
"seen",
"in",
"a",
"sliding",
"window",
"of",
"time",
"over",
"this",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L427-L443 | [
"def",
"window",
"(",
"self",
",",
"windowDuration",
",",
"slideDuration",
"=",
"None",
")",
":",
"self",
".",
"_validate_window_param",
"(",
"windowDuration",
",",
"slideDuration",
")",
"d",
"=",
"self",
".",
"_ssc",
".",
"_jduration",
"(",
"windowDuration",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.reduceByWindow | Return a new DStream in which each RDD has a single element generated by reducing all
elements in a sliding window over this DStream.
if `invReduceFunc` is not None, the reduction is done incrementally
using the old window's reduced value :
1. reduce the new values that entered the win... | python/pyspark/streaming/dstream.py | def reduceByWindow(self, reduceFunc, invReduceFunc, windowDuration, slideDuration):
"""
Return a new DStream in which each RDD has a single element generated by reducing all
elements in a sliding window over this DStream.
if `invReduceFunc` is not None, the reduction is done incremental... | def reduceByWindow(self, reduceFunc, invReduceFunc, windowDuration, slideDuration):
"""
Return a new DStream in which each RDD has a single element generated by reducing all
elements in a sliding window over this DStream.
if `invReduceFunc` is not None, the reduction is done incremental... | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"has",
"a",
"single",
"element",
"generated",
"by",
"reducing",
"all",
"elements",
"in",
"a",
"sliding",
"window",
"over",
"this",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L445-L471 | [
"def",
"reduceByWindow",
"(",
"self",
",",
"reduceFunc",
",",
"invReduceFunc",
",",
"windowDuration",
",",
"slideDuration",
")",
":",
"keyed",
"=",
"self",
".",
"map",
"(",
"lambda",
"x",
":",
"(",
"1",
",",
"x",
")",
")",
"reduced",
"=",
"keyed",
".",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.countByWindow | Return a new DStream in which each RDD has a single element generated
by counting the number of elements in a window over this DStream.
windowDuration and slideDuration are as defined in the window() operation.
This is equivalent to window(windowDuration, slideDuration).count(),
but wil... | python/pyspark/streaming/dstream.py | def countByWindow(self, windowDuration, slideDuration):
"""
Return a new DStream in which each RDD has a single element generated
by counting the number of elements in a window over this DStream.
windowDuration and slideDuration are as defined in the window() operation.
This is ... | def countByWindow(self, windowDuration, slideDuration):
"""
Return a new DStream in which each RDD has a single element generated
by counting the number of elements in a window over this DStream.
windowDuration and slideDuration are as defined in the window() operation.
This is ... | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"has",
"a",
"single",
"element",
"generated",
"by",
"counting",
"the",
"number",
"of",
"elements",
"in",
"a",
"window",
"over",
"this",
"DStream",
".",
"windowDuration",
"and",
"slideDuration",
"... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L473-L483 | [
"def",
"countByWindow",
"(",
"self",
",",
"windowDuration",
",",
"slideDuration",
")",
":",
"return",
"self",
".",
"map",
"(",
"lambda",
"x",
":",
"1",
")",
".",
"reduceByWindow",
"(",
"operator",
".",
"add",
",",
"operator",
".",
"sub",
",",
"windowDura... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.countByValueAndWindow | Return a new DStream in which each RDD contains the count of distinct elements in
RDDs in a sliding window over this DStream.
@param windowDuration: width of the window; must be a multiple of this DStream's
batching interval
@param slideDuration: sliding interval ... | python/pyspark/streaming/dstream.py | def countByValueAndWindow(self, windowDuration, slideDuration, numPartitions=None):
"""
Return a new DStream in which each RDD contains the count of distinct elements in
RDDs in a sliding window over this DStream.
@param windowDuration: width of the window; must be a multiple of this DS... | def countByValueAndWindow(self, windowDuration, slideDuration, numPartitions=None):
"""
Return a new DStream in which each RDD contains the count of distinct elements in
RDDs in a sliding window over this DStream.
@param windowDuration: width of the window; must be a multiple of this DS... | [
"Return",
"a",
"new",
"DStream",
"in",
"which",
"each",
"RDD",
"contains",
"the",
"count",
"of",
"distinct",
"elements",
"in",
"RDDs",
"in",
"a",
"sliding",
"window",
"over",
"this",
"DStream",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L485-L500 | [
"def",
"countByValueAndWindow",
"(",
"self",
",",
"windowDuration",
",",
"slideDuration",
",",
"numPartitions",
"=",
"None",
")",
":",
"keyed",
"=",
"self",
".",
"map",
"(",
"lambda",
"x",
":",
"(",
"x",
",",
"1",
")",
")",
"counted",
"=",
"keyed",
"."... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.groupByKeyAndWindow | Return a new DStream by applying `groupByKey` over a sliding window.
Similar to `DStream.groupByKey()`, but applies it over a sliding window.
@param windowDuration: width of the window; must be a multiple of this DStream's
batching interval
@param slideDuration: s... | python/pyspark/streaming/dstream.py | def groupByKeyAndWindow(self, windowDuration, slideDuration, numPartitions=None):
"""
Return a new DStream by applying `groupByKey` over a sliding window.
Similar to `DStream.groupByKey()`, but applies it over a sliding window.
@param windowDuration: width of the window; must be a multi... | def groupByKeyAndWindow(self, windowDuration, slideDuration, numPartitions=None):
"""
Return a new DStream by applying `groupByKey` over a sliding window.
Similar to `DStream.groupByKey()`, but applies it over a sliding window.
@param windowDuration: width of the window; must be a multi... | [
"Return",
"a",
"new",
"DStream",
"by",
"applying",
"groupByKey",
"over",
"a",
"sliding",
"window",
".",
"Similar",
"to",
"DStream",
".",
"groupByKey",
"()",
"but",
"applies",
"it",
"over",
"a",
"sliding",
"window",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L502-L517 | [
"def",
"groupByKeyAndWindow",
"(",
"self",
",",
"windowDuration",
",",
"slideDuration",
",",
"numPartitions",
"=",
"None",
")",
":",
"ls",
"=",
"self",
".",
"mapValues",
"(",
"lambda",
"x",
":",
"[",
"x",
"]",
")",
"grouped",
"=",
"ls",
".",
"reduceByKey... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.reduceByKeyAndWindow | Return a new DStream by applying incremental `reduceByKey` over a sliding window.
The reduced value of over a new window is calculated using the old window's reduce value :
1. reduce the new values that entered the window (e.g., adding new counts)
2. "inverse reduce" the old values that left ... | python/pyspark/streaming/dstream.py | def reduceByKeyAndWindow(self, func, invFunc, windowDuration, slideDuration=None,
numPartitions=None, filterFunc=None):
"""
Return a new DStream by applying incremental `reduceByKey` over a sliding window.
The reduced value of over a new window is calculated using t... | def reduceByKeyAndWindow(self, func, invFunc, windowDuration, slideDuration=None,
numPartitions=None, filterFunc=None):
"""
Return a new DStream by applying incremental `reduceByKey` over a sliding window.
The reduced value of over a new window is calculated using t... | [
"Return",
"a",
"new",
"DStream",
"by",
"applying",
"incremental",
"reduceByKey",
"over",
"a",
"sliding",
"window",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L519-L574 | [
"def",
"reduceByKeyAndWindow",
"(",
"self",
",",
"func",
",",
"invFunc",
",",
"windowDuration",
",",
"slideDuration",
"=",
"None",
",",
"numPartitions",
"=",
"None",
",",
"filterFunc",
"=",
"None",
")",
":",
"self",
".",
"_validate_window_param",
"(",
"windowD... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | DStream.updateStateByKey | Return a new "state" DStream where the state for each key is updated by applying
the given function on the previous state of the key and the new values of the key.
@param updateFunc: State update function. If this function returns None, then
corresponding state key-value pair... | python/pyspark/streaming/dstream.py | def updateStateByKey(self, updateFunc, numPartitions=None, initialRDD=None):
"""
Return a new "state" DStream where the state for each key is updated by applying
the given function on the previous state of the key and the new values of the key.
@param updateFunc: State update function. ... | def updateStateByKey(self, updateFunc, numPartitions=None, initialRDD=None):
"""
Return a new "state" DStream where the state for each key is updated by applying
the given function on the previous state of the key and the new values of the key.
@param updateFunc: State update function. ... | [
"Return",
"a",
"new",
"state",
"DStream",
"where",
"the",
"state",
"for",
"each",
"key",
"is",
"updated",
"by",
"applying",
"the",
"given",
"function",
"on",
"the",
"previous",
"state",
"of",
"the",
"key",
"and",
"the",
"new",
"values",
"of",
"the",
"key... | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/dstream.py#L576-L608 | [
"def",
"updateStateByKey",
"(",
"self",
",",
"updateFunc",
",",
"numPartitions",
"=",
"None",
",",
"initialRDD",
"=",
"None",
")",
":",
"if",
"numPartitions",
"is",
"None",
":",
"numPartitions",
"=",
"self",
".",
"_sc",
".",
"defaultParallelism",
"if",
"init... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | FPGrowth.setParams | setParams(self, minSupport=0.3, minConfidence=0.8, itemsCol="items", \
predictionCol="prediction", numPartitions=None) | python/pyspark/ml/fpm.py | def setParams(self, minSupport=0.3, minConfidence=0.8, itemsCol="items",
predictionCol="prediction", numPartitions=None):
"""
setParams(self, minSupport=0.3, minConfidence=0.8, itemsCol="items", \
predictionCol="prediction", numPartitions=None)
"""
kwa... | def setParams(self, minSupport=0.3, minConfidence=0.8, itemsCol="items",
predictionCol="prediction", numPartitions=None):
"""
setParams(self, minSupport=0.3, minConfidence=0.8, itemsCol="items", \
predictionCol="prediction", numPartitions=None)
"""
kwa... | [
"setParams",
"(",
"self",
"minSupport",
"=",
"0",
".",
"3",
"minConfidence",
"=",
"0",
".",
"8",
"itemsCol",
"=",
"items",
"\\",
"predictionCol",
"=",
"prediction",
"numPartitions",
"=",
"None",
")"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/fpm.py#L237-L244 | [
"def",
"setParams",
"(",
"self",
",",
"minSupport",
"=",
"0.3",
",",
"minConfidence",
"=",
"0.8",
",",
"itemsCol",
"=",
"\"items\"",
",",
"predictionCol",
"=",
"\"prediction\"",
",",
"numPartitions",
"=",
"None",
")",
":",
"kwargs",
"=",
"self",
".",
"_inp... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | PrefixSpan.setParams | setParams(self, minSupport=0.1, maxPatternLength=10, maxLocalProjDBSize=32000000, \
sequenceCol="sequence") | python/pyspark/ml/fpm.py | def setParams(self, minSupport=0.1, maxPatternLength=10, maxLocalProjDBSize=32000000,
sequenceCol="sequence"):
"""
setParams(self, minSupport=0.1, maxPatternLength=10, maxLocalProjDBSize=32000000, \
sequenceCol="sequence")
"""
kwargs = self._input_kwar... | def setParams(self, minSupport=0.1, maxPatternLength=10, maxLocalProjDBSize=32000000,
sequenceCol="sequence"):
"""
setParams(self, minSupport=0.1, maxPatternLength=10, maxLocalProjDBSize=32000000, \
sequenceCol="sequence")
"""
kwargs = self._input_kwar... | [
"setParams",
"(",
"self",
"minSupport",
"=",
"0",
".",
"1",
"maxPatternLength",
"=",
"10",
"maxLocalProjDBSize",
"=",
"32000000",
"\\",
"sequenceCol",
"=",
"sequence",
")"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/fpm.py#L304-L311 | [
"def",
"setParams",
"(",
"self",
",",
"minSupport",
"=",
"0.1",
",",
"maxPatternLength",
"=",
"10",
",",
"maxLocalProjDBSize",
"=",
"32000000",
",",
"sequenceCol",
"=",
"\"sequence\"",
")",
":",
"kwargs",
"=",
"self",
".",
"_input_kwargs",
"return",
"self",
... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | PrefixSpan.findFrequentSequentialPatterns | .. note:: Experimental
Finds the complete set of frequent sequential patterns in the input sequences of itemsets.
:param dataset: A dataframe containing a sequence column which is
`ArrayType(ArrayType(T))` type, T is the item type for the input dataset.
:return: A `Data... | python/pyspark/ml/fpm.py | def findFrequentSequentialPatterns(self, dataset):
"""
.. note:: Experimental
Finds the complete set of frequent sequential patterns in the input sequences of itemsets.
:param dataset: A dataframe containing a sequence column which is
`ArrayType(ArrayType(T))` t... | def findFrequentSequentialPatterns(self, dataset):
"""
.. note:: Experimental
Finds the complete set of frequent sequential patterns in the input sequences of itemsets.
:param dataset: A dataframe containing a sequence column which is
`ArrayType(ArrayType(T))` t... | [
"..",
"note",
"::",
"Experimental"
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/fpm.py#L314-L349 | [
"def",
"findFrequentSequentialPatterns",
"(",
"self",
",",
"dataset",
")",
":",
"self",
".",
"_transfer_params_to_java",
"(",
")",
"jdf",
"=",
"self",
".",
"_java_obj",
".",
"findFrequentSequentialPatterns",
"(",
"dataset",
".",
"_jdf",
")",
"return",
"DataFrame",... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
train | first_spark_call | Return a CallSite representing the first Spark call in the current call stack. | python/pyspark/traceback_utils.py | def first_spark_call():
"""
Return a CallSite representing the first Spark call in the current call stack.
"""
tb = traceback.extract_stack()
if len(tb) == 0:
return None
file, line, module, what = tb[len(tb) - 1]
sparkpath = os.path.dirname(file)
first_spark_frame = len(tb) - 1
... | def first_spark_call():
"""
Return a CallSite representing the first Spark call in the current call stack.
"""
tb = traceback.extract_stack()
if len(tb) == 0:
return None
file, line, module, what = tb[len(tb) - 1]
sparkpath = os.path.dirname(file)
first_spark_frame = len(tb) - 1
... | [
"Return",
"a",
"CallSite",
"representing",
"the",
"first",
"Spark",
"call",
"in",
"the",
"current",
"call",
"stack",
"."
] | apache/spark | python | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/traceback_utils.py#L26-L46 | [
"def",
"first_spark_call",
"(",
")",
":",
"tb",
"=",
"traceback",
".",
"extract_stack",
"(",
")",
"if",
"len",
"(",
"tb",
")",
"==",
"0",
":",
"return",
"None",
"file",
",",
"line",
",",
"module",
",",
"what",
"=",
"tb",
"[",
"len",
"(",
"tb",
")... | 618d6bff71073c8c93501ab7392c3cc579730f0b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.