repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
apple/turicreate | src/unity/python/turicreate/util/_cloudpickle.py | CloudPickler.save_partial | def save_partial(self, obj):
"""Partial objects do not serialize correctly in python2.x -- this fixes the bugs"""
self.save_reduce(_genpartial, (obj.func, obj.args, obj.keywords)) | python | def save_partial(self, obj):
"""Partial objects do not serialize correctly in python2.x -- this fixes the bugs"""
self.save_reduce(_genpartial, (obj.func, obj.args, obj.keywords)) | [
"def",
"save_partial",
"(",
"self",
",",
"obj",
")",
":",
"self",
".",
"save_reduce",
"(",
"_genpartial",
",",
"(",
"obj",
".",
"func",
",",
"obj",
".",
"args",
",",
"obj",
".",
"keywords",
")",
")"
] | Partial objects do not serialize correctly in python2.x -- this fixes the bugs | [
"Partial",
"objects",
"do",
"not",
"serialize",
"correctly",
"in",
"python2",
".",
"x",
"--",
"this",
"fixes",
"the",
"bugs"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/util/_cloudpickle.py#L839-L841 | train |
apple/turicreate | src/unity/python/turicreate/util/_cloudpickle.py | CloudPickler.save_file | def save_file(self, obj):
"""Save a file"""
try:
import StringIO as pystringIO #we can't use cStringIO as it lacks the name attribute
except ImportError:
import io as pystringIO
if not hasattr(obj, 'name') or not hasattr(obj, 'mode'):
raise pickle.Pi... | python | def save_file(self, obj):
"""Save a file"""
try:
import StringIO as pystringIO #we can't use cStringIO as it lacks the name attribute
except ImportError:
import io as pystringIO
if not hasattr(obj, 'name') or not hasattr(obj, 'mode'):
raise pickle.Pi... | [
"def",
"save_file",
"(",
"self",
",",
"obj",
")",
":",
"try",
":",
"import",
"StringIO",
"as",
"pystringIO",
"#we can't use cStringIO as it lacks the name attribute",
"except",
"ImportError",
":",
"import",
"io",
"as",
"pystringIO",
"if",
"not",
"hasattr",
"(",
"o... | Save a file | [
"Save",
"a",
"file"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/util/_cloudpickle.py#L847-L886 | train |
apple/turicreate | src/unity/python/turicreate/util/_cloudpickle.py | CloudPickler.save_ufunc | def save_ufunc(self, obj):
"""Hack function for saving numpy ufunc objects"""
name = obj.__name__
numpy_tst_mods = ['numpy', 'scipy.special']
for tst_mod_name in numpy_tst_mods:
tst_mod = sys.modules.get(tst_mod_name, None)
if tst_mod and name in tst_mod.__dict__:... | python | def save_ufunc(self, obj):
"""Hack function for saving numpy ufunc objects"""
name = obj.__name__
numpy_tst_mods = ['numpy', 'scipy.special']
for tst_mod_name in numpy_tst_mods:
tst_mod = sys.modules.get(tst_mod_name, None)
if tst_mod and name in tst_mod.__dict__:... | [
"def",
"save_ufunc",
"(",
"self",
",",
"obj",
")",
":",
"name",
"=",
"obj",
".",
"__name__",
"numpy_tst_mods",
"=",
"[",
"'numpy'",
",",
"'scipy.special'",
"]",
"for",
"tst_mod_name",
"in",
"numpy_tst_mods",
":",
"tst_mod",
"=",
"sys",
".",
"modules",
".",... | Hack function for saving numpy ufunc objects | [
"Hack",
"function",
"for",
"saving",
"numpy",
"ufunc",
"objects"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/util/_cloudpickle.py#L915-L924 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/descriptor_database.py | _ExtractSymbols | def _ExtractSymbols(desc_proto, package):
"""Pulls out all the symbols from a descriptor proto.
Args:
desc_proto: The proto to extract symbols from.
package: The package containing the descriptor type.
Yields:
The fully qualified name found in the descriptor.
"""
message_name = '.'.join((packag... | python | def _ExtractSymbols(desc_proto, package):
"""Pulls out all the symbols from a descriptor proto.
Args:
desc_proto: The proto to extract symbols from.
package: The package containing the descriptor type.
Yields:
The fully qualified name found in the descriptor.
"""
message_name = '.'.join((packag... | [
"def",
"_ExtractSymbols",
"(",
"desc_proto",
",",
"package",
")",
":",
"message_name",
"=",
"'.'",
".",
"join",
"(",
"(",
"package",
",",
"desc_proto",
".",
"name",
")",
")",
"yield",
"message_name",
"for",
"nested_type",
"in",
"desc_proto",
".",
"nested_typ... | Pulls out all the symbols from a descriptor proto.
Args:
desc_proto: The proto to extract symbols from.
package: The package containing the descriptor type.
Yields:
The fully qualified name found in the descriptor. | [
"Pulls",
"out",
"all",
"the",
"symbols",
"from",
"a",
"descriptor",
"proto",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/descriptor_database.py#L127-L144 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/descriptor_database.py | DescriptorDatabase.Add | def Add(self, file_desc_proto):
"""Adds the FileDescriptorProto and its types to this database.
Args:
file_desc_proto: The FileDescriptorProto to add.
Raises:
DescriptorDatabaseConflictingDefinitionError: if an attempt is made to
add a proto with the same name but different definition t... | python | def Add(self, file_desc_proto):
"""Adds the FileDescriptorProto and its types to this database.
Args:
file_desc_proto: The FileDescriptorProto to add.
Raises:
DescriptorDatabaseConflictingDefinitionError: if an attempt is made to
add a proto with the same name but different definition t... | [
"def",
"Add",
"(",
"self",
",",
"file_desc_proto",
")",
":",
"proto_name",
"=",
"file_desc_proto",
".",
"name",
"if",
"proto_name",
"not",
"in",
"self",
".",
"_file_desc_protos_by_file",
":",
"self",
".",
"_file_desc_protos_by_file",
"[",
"proto_name",
"]",
"=",... | Adds the FileDescriptorProto and its types to this database.
Args:
file_desc_proto: The FileDescriptorProto to add.
Raises:
DescriptorDatabaseConflictingDefinitionError: if an attempt is made to
add a proto with the same name but different definition than an
exisiting proto in the d... | [
"Adds",
"the",
"FileDescriptorProto",
"and",
"its",
"types",
"to",
"this",
"database",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/descriptor_database.py#L51-L81 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_normalizer.py | convert | def convert(model, input_features, output_features):
"""Convert a normalizer model to the protobuf spec.
Parameters
----------
model: Normalizer
A Normalizer.
input_features: str
Name of the input column.
output_features: str
Name of the output column.
Returns
... | python | def convert(model, input_features, output_features):
"""Convert a normalizer model to the protobuf spec.
Parameters
----------
model: Normalizer
A Normalizer.
input_features: str
Name of the input column.
output_features: str
Name of the output column.
Returns
... | [
"def",
"convert",
"(",
"model",
",",
"input_features",
",",
"output_features",
")",
":",
"if",
"not",
"(",
"_HAS_SKLEARN",
")",
":",
"raise",
"RuntimeError",
"(",
"'scikit-learn not found. scikit-learn conversion API is disabled.'",
")",
"# Test the scikit-learn model",
"... | Convert a normalizer model to the protobuf spec.
Parameters
----------
model: Normalizer
A Normalizer.
input_features: str
Name of the input column.
output_features: str
Name of the output column.
Returns
-------
model_spec: An object of type Model_pb.
... | [
"Convert",
"a",
"normalizer",
"model",
"to",
"the",
"protobuf",
"spec",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_normalizer.py#L24-L64 | train |
apple/turicreate | src/external/xgboost/subtree/rabit/tracker/rabit_mpi.py | mpi_submit | def mpi_submit(nslave, worker_args, worker_envs):
"""
customized submit script, that submit nslave jobs, each must contain args as parameter
note this can be a lambda function containing additional parameters in input
Parameters
nslave number of slave process to start up
args arg... | python | def mpi_submit(nslave, worker_args, worker_envs):
"""
customized submit script, that submit nslave jobs, each must contain args as parameter
note this can be a lambda function containing additional parameters in input
Parameters
nslave number of slave process to start up
args arg... | [
"def",
"mpi_submit",
"(",
"nslave",
",",
"worker_args",
",",
"worker_envs",
")",
":",
"worker_args",
"+=",
"[",
"'%s=%s'",
"%",
"(",
"k",
",",
"str",
"(",
"v",
")",
")",
"for",
"k",
",",
"v",
"in",
"worker_envs",
".",
"items",
"(",
")",
"]",
"sargs... | customized submit script, that submit nslave jobs, each must contain args as parameter
note this can be a lambda function containing additional parameters in input
Parameters
nslave number of slave process to start up
args arguments to launch each job
this usually includes th... | [
"customized",
"submit",
"script",
"that",
"submit",
"nslave",
"jobs",
"each",
"must",
"contain",
"args",
"as",
"parameter",
"note",
"this",
"can",
"be",
"a",
"lambda",
"function",
"containing",
"additional",
"parameters",
"in",
"input",
"Parameters",
"nslave",
"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/subtree/rabit/tracker/rabit_mpi.py#L24-L40 | train |
apple/turicreate | src/unity/python/turicreate/meta/bytecodetools/bytecode_consumer.py | ByteCodeConsumer.consume | def consume(self):
'''
Consume byte-code
'''
generic_consume = getattr(self, 'generic_consume', None)
for instr in disassembler(self.code):
method_name = 'consume_%s' % (instr.opname)
method = getattr(self, method_name, generic_consume)
... | python | def consume(self):
'''
Consume byte-code
'''
generic_consume = getattr(self, 'generic_consume', None)
for instr in disassembler(self.code):
method_name = 'consume_%s' % (instr.opname)
method = getattr(self, method_name, generic_consume)
... | [
"def",
"consume",
"(",
"self",
")",
":",
"generic_consume",
"=",
"getattr",
"(",
"self",
",",
"'generic_consume'",
",",
"None",
")",
"for",
"instr",
"in",
"disassembler",
"(",
"self",
".",
"code",
")",
":",
"method_name",
"=",
"'consume_%s'",
"%",
"(",
"... | Consume byte-code | [
"Consume",
"byte",
"-",
"code"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/meta/bytecodetools/bytecode_consumer.py#L25-L39 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/classifier/random_forest_classifier.py | create | def create(dataset, target,
features=None,
max_iterations=10,
validation_set='auto',
verbose=True, class_weights=None,
random_seed=None,
metric='auto',
**kwargs):
"""
Create a (binary or multi-class) classifier model of type
:class... | python | def create(dataset, target,
features=None,
max_iterations=10,
validation_set='auto',
verbose=True, class_weights=None,
random_seed=None,
metric='auto',
**kwargs):
"""
Create a (binary or multi-class) classifier model of type
:class... | [
"def",
"create",
"(",
"dataset",
",",
"target",
",",
"features",
"=",
"None",
",",
"max_iterations",
"=",
"10",
",",
"validation_set",
"=",
"'auto'",
",",
"verbose",
"=",
"True",
",",
"class_weights",
"=",
"None",
",",
"random_seed",
"=",
"None",
",",
"m... | Create a (binary or multi-class) classifier model of type
:class:`~turicreate.random_forest_classifier.RandomForestClassifier` using
an ensemble of decision trees trained on subsets of the data.
Parameters
----------
dataset : SFrame
A training dataset containing feature columns and a targe... | [
"Create",
"a",
"(",
"binary",
"or",
"multi",
"-",
"class",
")",
"classifier",
"model",
"of",
"type",
":",
"class",
":",
"~turicreate",
".",
"random_forest_classifier",
".",
"RandomForestClassifier",
"using",
"an",
"ensemble",
"of",
"decision",
"trees",
"trained"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/classifier/random_forest_classifier.py#L443-L610 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/classifier/random_forest_classifier.py | RandomForestClassifier.classify | def classify(self, dataset, missing_value_action='auto'):
"""
Return a classification, for each example in the ``dataset``, using the
trained random forest model. The output SFrame contains predictions
as class labels (0 or 1) and probabilities associated with the the example.
P... | python | def classify(self, dataset, missing_value_action='auto'):
"""
Return a classification, for each example in the ``dataset``, using the
trained random forest model. The output SFrame contains predictions
as class labels (0 or 1) and probabilities associated with the the example.
P... | [
"def",
"classify",
"(",
"self",
",",
"dataset",
",",
"missing_value_action",
"=",
"'auto'",
")",
":",
"return",
"super",
"(",
"RandomForestClassifier",
",",
"self",
")",
".",
"classify",
"(",
"dataset",
",",
"missing_value_action",
"=",
"missing_value_action",
"... | Return a classification, for each example in the ``dataset``, using the
trained random forest model. The output SFrame contains predictions
as class labels (0 or 1) and probabilities associated with the the example.
Parameters
----------
dataset : SFrame
Dataset of n... | [
"Return",
"a",
"classification",
"for",
"each",
"example",
"in",
"the",
"dataset",
"using",
"the",
"trained",
"random",
"forest",
"model",
".",
"The",
"output",
"SFrame",
"contains",
"predictions",
"as",
"class",
"labels",
"(",
"0",
"or",
"1",
")",
"and",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/classifier/random_forest_classifier.py#L360-L406 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_keras_converter.py | _get_layer_converter_fn | def _get_layer_converter_fn(layer):
"""Get the right converter function for Keras
"""
layer_type = type(layer)
if layer_type in _KERAS_LAYER_REGISTRY:
return _KERAS_LAYER_REGISTRY[layer_type]
else:
raise TypeError("Keras layer of type %s is not supported." % type(layer)) | python | def _get_layer_converter_fn(layer):
"""Get the right converter function for Keras
"""
layer_type = type(layer)
if layer_type in _KERAS_LAYER_REGISTRY:
return _KERAS_LAYER_REGISTRY[layer_type]
else:
raise TypeError("Keras layer of type %s is not supported." % type(layer)) | [
"def",
"_get_layer_converter_fn",
"(",
"layer",
")",
":",
"layer_type",
"=",
"type",
"(",
"layer",
")",
"if",
"layer_type",
"in",
"_KERAS_LAYER_REGISTRY",
":",
"return",
"_KERAS_LAYER_REGISTRY",
"[",
"layer_type",
"]",
"else",
":",
"raise",
"TypeError",
"(",
"\"... | Get the right converter function for Keras | [
"Get",
"the",
"right",
"converter",
"function",
"for",
"Keras"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_keras_converter.py#L103-L110 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_keras_converter.py | convertToSpec | def convertToSpec(model,
input_names = None,
output_names = None,
image_input_names = None,
input_name_shape_dict = {},
is_bgr = False,
red_bias = 0.0,
green_bias = 0.0,
blue_b... | python | def convertToSpec(model,
input_names = None,
output_names = None,
image_input_names = None,
input_name_shape_dict = {},
is_bgr = False,
red_bias = 0.0,
green_bias = 0.0,
blue_b... | [
"def",
"convertToSpec",
"(",
"model",
",",
"input_names",
"=",
"None",
",",
"output_names",
"=",
"None",
",",
"image_input_names",
"=",
"None",
",",
"input_name_shape_dict",
"=",
"{",
"}",
",",
"is_bgr",
"=",
"False",
",",
"red_bias",
"=",
"0.0",
",",
"gre... | Convert a Keras model to Core ML protobuf specification (.mlmodel).
Parameters
----------
model: Keras model object | str | (str, str)
A trained Keras neural network model which can be one of the following:
- a Keras model object
- a string with the path to a Keras model file (h5)
... | [
"Convert",
"a",
"Keras",
"model",
"to",
"Core",
"ML",
"protobuf",
"specification",
"(",
".",
"mlmodel",
")",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_keras_converter.py#L333-L564 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_keras_converter.py | convert | def convert(model,
input_names = None,
output_names = None,
image_input_names = None,
input_name_shape_dict = {},
is_bgr = False,
red_bias = 0.0,
green_bias = 0.0,
blue_bias = ... | python | def convert(model,
input_names = None,
output_names = None,
image_input_names = None,
input_name_shape_dict = {},
is_bgr = False,
red_bias = 0.0,
green_bias = 0.0,
blue_bias = ... | [
"def",
"convert",
"(",
"model",
",",
"input_names",
"=",
"None",
",",
"output_names",
"=",
"None",
",",
"image_input_names",
"=",
"None",
",",
"input_name_shape_dict",
"=",
"{",
"}",
",",
"is_bgr",
"=",
"False",
",",
"red_bias",
"=",
"0.0",
",",
"green_bia... | Convert a Keras model to Core ML protobuf specification (.mlmodel).
Parameters
----------
model: Keras model object | str | (str, str)
A trained Keras neural network model which can be one of the following:
- a Keras model object
- a string with the path to a Keras model file (h5)... | [
"Convert",
"a",
"Keras",
"model",
"to",
"Core",
"ML",
"protobuf",
"specification",
"(",
".",
"mlmodel",
")",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_keras_converter.py#L567-L762 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_random_forest_regressor.py | convert | def convert(model, feature_names, target):
"""Convert a boosted tree model to protobuf format.
Parameters
----------
decision_tree : RandomForestRegressor
A trained scikit-learn tree model.
feature_names: [str]
Name of the input columns.
target: str
Name of the output ... | python | def convert(model, feature_names, target):
"""Convert a boosted tree model to protobuf format.
Parameters
----------
decision_tree : RandomForestRegressor
A trained scikit-learn tree model.
feature_names: [str]
Name of the input columns.
target: str
Name of the output ... | [
"def",
"convert",
"(",
"model",
",",
"feature_names",
",",
"target",
")",
":",
"if",
"not",
"(",
"_HAS_SKLEARN",
")",
":",
"raise",
"RuntimeError",
"(",
"'scikit-learn not found. scikit-learn conversion API is disabled.'",
")",
"_sklearn_util",
".",
"check_expected_type... | Convert a boosted tree model to protobuf format.
Parameters
----------
decision_tree : RandomForestRegressor
A trained scikit-learn tree model.
feature_names: [str]
Name of the input columns.
target: str
Name of the output column.
Returns
-------
model_spec: A... | [
"Convert",
"a",
"boosted",
"tree",
"model",
"to",
"protobuf",
"format",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_random_forest_regressor.py#L19-L53 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/clustering/dbscan.py | create | def create(dataset, features=None, distance=None, radius=1.,
min_core_neighbors=10, verbose=True):
"""
Create a DBSCAN clustering model. The DBSCAN method partitions the input
dataset into three types of points, based on the estimated probability
density at each point.
- **Core** points ... | python | def create(dataset, features=None, distance=None, radius=1.,
min_core_neighbors=10, verbose=True):
"""
Create a DBSCAN clustering model. The DBSCAN method partitions the input
dataset into three types of points, based on the estimated probability
density at each point.
- **Core** points ... | [
"def",
"create",
"(",
"dataset",
",",
"features",
"=",
"None",
",",
"distance",
"=",
"None",
",",
"radius",
"=",
"1.",
",",
"min_core_neighbors",
"=",
"10",
",",
"verbose",
"=",
"True",
")",
":",
"## Start the training time clock and instantiate an empty model",
... | Create a DBSCAN clustering model. The DBSCAN method partitions the input
dataset into three types of points, based on the estimated probability
density at each point.
- **Core** points have a large number of points within a given neighborhood.
Specifically, `min_core_neighbors` must be within distanc... | [
"Create",
"a",
"DBSCAN",
"clustering",
"model",
".",
"The",
"DBSCAN",
"method",
"partitions",
"the",
"input",
"dataset",
"into",
"three",
"types",
"of",
"points",
"based",
"on",
"the",
"estimated",
"probability",
"density",
"at",
"each",
"point",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/clustering/dbscan.py#L24-L322 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/libpath.py | find_lib_path | def find_lib_path():
"""Load find the path to xgboost dynamic library files.
Returns
-------
lib_path: list(string)
List of all found library path to xgboost
"""
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
# make pythonpack hack: copy this directory one... | python | def find_lib_path():
"""Load find the path to xgboost dynamic library files.
Returns
-------
lib_path: list(string)
List of all found library path to xgboost
"""
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
# make pythonpack hack: copy this directory one... | [
"def",
"find_lib_path",
"(",
")",
":",
"curr_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"__file__",
")",
")",
")",
"# make pythonpack hack: copy this directory one le... | Load find the path to xgboost dynamic library files.
Returns
-------
lib_path: list(string)
List of all found library path to xgboost | [
"Load",
"find",
"the",
"path",
"to",
"xgboost",
"dynamic",
"library",
"files",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/libpath.py#L13-L45 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_sklearn_util.py | check_expected_type | def check_expected_type(model, expected_type):
"""Check if a model is of the right type. Raise error if not.
Parameters
----------
model: model
Any scikit-learn model
expected_type: Type
Expected type of the scikit-learn.
"""
if (model.__class__.__name__ != expected_type.__... | python | def check_expected_type(model, expected_type):
"""Check if a model is of the right type. Raise error if not.
Parameters
----------
model: model
Any scikit-learn model
expected_type: Type
Expected type of the scikit-learn.
"""
if (model.__class__.__name__ != expected_type.__... | [
"def",
"check_expected_type",
"(",
"model",
",",
"expected_type",
")",
":",
"if",
"(",
"model",
".",
"__class__",
".",
"__name__",
"!=",
"expected_type",
".",
"__name__",
")",
":",
"raise",
"TypeError",
"(",
"\"Expected model of type '%s' (got %s)\"",
"%",
"(",
... | Check if a model is of the right type. Raise error if not.
Parameters
----------
model: model
Any scikit-learn model
expected_type: Type
Expected type of the scikit-learn. | [
"Check",
"if",
"a",
"model",
"is",
"of",
"the",
"right",
"type",
".",
"Raise",
"error",
"if",
"not",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_sklearn_util.py#L20-L33 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/libsvm/__init__.py | convert | def convert(model, input_names='input', target_name='target',
probability='classProbability', input_length='auto'):
"""
Convert a LIBSVM model to Core ML format.
Parameters
----------
model: a libsvm model (C-SVC, nu-SVC, epsilon-SVR, or nu-SVR)
or string path to a saved model.... | python | def convert(model, input_names='input', target_name='target',
probability='classProbability', input_length='auto'):
"""
Convert a LIBSVM model to Core ML format.
Parameters
----------
model: a libsvm model (C-SVC, nu-SVC, epsilon-SVR, or nu-SVR)
or string path to a saved model.... | [
"def",
"convert",
"(",
"model",
",",
"input_names",
"=",
"'input'",
",",
"target_name",
"=",
"'target'",
",",
"probability",
"=",
"'classProbability'",
",",
"input_length",
"=",
"'auto'",
")",
":",
"if",
"not",
"(",
"_HAS_LIBSVM",
")",
":",
"raise",
"Runtime... | Convert a LIBSVM model to Core ML format.
Parameters
----------
model: a libsvm model (C-SVC, nu-SVC, epsilon-SVR, or nu-SVR)
or string path to a saved model.
input_names: str | [str]
Name of the input column(s).
If a single string is used (the default) the input will be an ar... | [
"Convert",
"a",
"LIBSVM",
"model",
"to",
"Core",
"ML",
"format",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/libsvm/__init__.py#L17-L93 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py | RepeatedScalarFieldContainer.append | def append(self, value):
"""Appends an item to the list. Similar to list.append()."""
self._values.append(self._type_checker.CheckValue(value))
if not self._message_listener.dirty:
self._message_listener.Modified() | python | def append(self, value):
"""Appends an item to the list. Similar to list.append()."""
self._values.append(self._type_checker.CheckValue(value))
if not self._message_listener.dirty:
self._message_listener.Modified() | [
"def",
"append",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_values",
".",
"append",
"(",
"self",
".",
"_type_checker",
".",
"CheckValue",
"(",
"value",
")",
")",
"if",
"not",
"self",
".",
"_message_listener",
".",
"dirty",
":",
"self",
".",
... | Appends an item to the list. Similar to list.append(). | [
"Appends",
"an",
"item",
"to",
"the",
"list",
".",
"Similar",
"to",
"list",
".",
"append",
"()",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py#L249-L253 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py | RepeatedScalarFieldContainer.insert | def insert(self, key, value):
"""Inserts the item at the specified position. Similar to list.insert()."""
self._values.insert(key, self._type_checker.CheckValue(value))
if not self._message_listener.dirty:
self._message_listener.Modified() | python | def insert(self, key, value):
"""Inserts the item at the specified position. Similar to list.insert()."""
self._values.insert(key, self._type_checker.CheckValue(value))
if not self._message_listener.dirty:
self._message_listener.Modified() | [
"def",
"insert",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"_values",
".",
"insert",
"(",
"key",
",",
"self",
".",
"_type_checker",
".",
"CheckValue",
"(",
"value",
")",
")",
"if",
"not",
"self",
".",
"_message_listener",
".",
"di... | Inserts the item at the specified position. Similar to list.insert(). | [
"Inserts",
"the",
"item",
"at",
"the",
"specified",
"position",
".",
"Similar",
"to",
"list",
".",
"insert",
"()",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py#L255-L259 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py | RepeatedScalarFieldContainer.extend | def extend(self, elem_seq):
"""Extends by appending the given iterable. Similar to list.extend()."""
if elem_seq is None:
return
try:
elem_seq_iter = iter(elem_seq)
except TypeError:
if not elem_seq:
# silently ignore falsy inputs :-/.
# TODO(ptucker): Deprecate this b... | python | def extend(self, elem_seq):
"""Extends by appending the given iterable. Similar to list.extend()."""
if elem_seq is None:
return
try:
elem_seq_iter = iter(elem_seq)
except TypeError:
if not elem_seq:
# silently ignore falsy inputs :-/.
# TODO(ptucker): Deprecate this b... | [
"def",
"extend",
"(",
"self",
",",
"elem_seq",
")",
":",
"if",
"elem_seq",
"is",
"None",
":",
"return",
"try",
":",
"elem_seq_iter",
"=",
"iter",
"(",
"elem_seq",
")",
"except",
"TypeError",
":",
"if",
"not",
"elem_seq",
":",
"# silently ignore falsy inputs ... | Extends by appending the given iterable. Similar to list.extend(). | [
"Extends",
"by",
"appending",
"the",
"given",
"iterable",
".",
"Similar",
"to",
"list",
".",
"extend",
"()",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py#L261-L278 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py | RepeatedScalarFieldContainer.MergeFrom | def MergeFrom(self, other):
"""Appends the contents of another repeated field of the same type to this
one. We do not check the types of the individual fields.
"""
self._values.extend(other._values)
self._message_listener.Modified() | python | def MergeFrom(self, other):
"""Appends the contents of another repeated field of the same type to this
one. We do not check the types of the individual fields.
"""
self._values.extend(other._values)
self._message_listener.Modified() | [
"def",
"MergeFrom",
"(",
"self",
",",
"other",
")",
":",
"self",
".",
"_values",
".",
"extend",
"(",
"other",
".",
"_values",
")",
"self",
".",
"_message_listener",
".",
"Modified",
"(",
")"
] | Appends the contents of another repeated field of the same type to this
one. We do not check the types of the individual fields. | [
"Appends",
"the",
"contents",
"of",
"another",
"repeated",
"field",
"of",
"the",
"same",
"type",
"to",
"this",
"one",
".",
"We",
"do",
"not",
"check",
"the",
"types",
"of",
"the",
"individual",
"fields",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py#L280-L285 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py | RepeatedScalarFieldContainer.remove | def remove(self, elem):
"""Removes an item from the list. Similar to list.remove()."""
self._values.remove(elem)
self._message_listener.Modified() | python | def remove(self, elem):
"""Removes an item from the list. Similar to list.remove()."""
self._values.remove(elem)
self._message_listener.Modified() | [
"def",
"remove",
"(",
"self",
",",
"elem",
")",
":",
"self",
".",
"_values",
".",
"remove",
"(",
"elem",
")",
"self",
".",
"_message_listener",
".",
"Modified",
"(",
")"
] | Removes an item from the list. Similar to list.remove(). | [
"Removes",
"an",
"item",
"from",
"the",
"list",
".",
"Similar",
"to",
"list",
".",
"remove",
"()",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py#L287-L290 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py | RepeatedScalarFieldContainer.pop | def pop(self, key=-1):
"""Removes and returns an item at a given index. Similar to list.pop()."""
value = self._values[key]
self.__delitem__(key)
return value | python | def pop(self, key=-1):
"""Removes and returns an item at a given index. Similar to list.pop()."""
value = self._values[key]
self.__delitem__(key)
return value | [
"def",
"pop",
"(",
"self",
",",
"key",
"=",
"-",
"1",
")",
":",
"value",
"=",
"self",
".",
"_values",
"[",
"key",
"]",
"self",
".",
"__delitem__",
"(",
"key",
")",
"return",
"value"
] | Removes and returns an item at a given index. Similar to list.pop(). | [
"Removes",
"and",
"returns",
"an",
"item",
"at",
"a",
"given",
"index",
".",
"Similar",
"to",
"list",
".",
"pop",
"()",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py#L292-L296 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py | RepeatedCompositeFieldContainer.add | def add(self, **kwargs):
"""Adds a new element at the end of the list and returns it. Keyword
arguments may be used to initialize the element.
"""
new_element = self._message_descriptor._concrete_class(**kwargs)
new_element._SetListener(self._message_listener)
self._values.append(new_element)
... | python | def add(self, **kwargs):
"""Adds a new element at the end of the list and returns it. Keyword
arguments may be used to initialize the element.
"""
new_element = self._message_descriptor._concrete_class(**kwargs)
new_element._SetListener(self._message_listener)
self._values.append(new_element)
... | [
"def",
"add",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"new_element",
"=",
"self",
".",
"_message_descriptor",
".",
"_concrete_class",
"(",
"*",
"*",
"kwargs",
")",
"new_element",
".",
"_SetListener",
"(",
"self",
".",
"_message_listener",
")",
"sel... | Adds a new element at the end of the list and returns it. Keyword
arguments may be used to initialize the element. | [
"Adds",
"a",
"new",
"element",
"at",
"the",
"end",
"of",
"the",
"list",
"and",
"returns",
"it",
".",
"Keyword",
"arguments",
"may",
"be",
"used",
"to",
"initialize",
"the",
"element",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py#L368-L377 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py | RepeatedCompositeFieldContainer.extend | def extend(self, elem_seq):
"""Extends by appending the given sequence of elements of the same type
as this one, copying each individual message.
"""
message_class = self._message_descriptor._concrete_class
listener = self._message_listener
values = self._values
for message in elem_seq:
... | python | def extend(self, elem_seq):
"""Extends by appending the given sequence of elements of the same type
as this one, copying each individual message.
"""
message_class = self._message_descriptor._concrete_class
listener = self._message_listener
values = self._values
for message in elem_seq:
... | [
"def",
"extend",
"(",
"self",
",",
"elem_seq",
")",
":",
"message_class",
"=",
"self",
".",
"_message_descriptor",
".",
"_concrete_class",
"listener",
"=",
"self",
".",
"_message_listener",
"values",
"=",
"self",
".",
"_values",
"for",
"message",
"in",
"elem_s... | Extends by appending the given sequence of elements of the same type
as this one, copying each individual message. | [
"Extends",
"by",
"appending",
"the",
"given",
"sequence",
"of",
"elements",
"of",
"the",
"same",
"type",
"as",
"this",
"one",
"copying",
"each",
"individual",
"message",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/containers.py#L379-L391 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/util/set.py | difference | def difference (b, a):
""" Returns the elements of B that are not in A.
"""
a = set(a)
result = []
for item in b:
if item not in a:
result.append(item)
return result | python | def difference (b, a):
""" Returns the elements of B that are not in A.
"""
a = set(a)
result = []
for item in b:
if item not in a:
result.append(item)
return result | [
"def",
"difference",
"(",
"b",
",",
"a",
")",
":",
"a",
"=",
"set",
"(",
"a",
")",
"result",
"=",
"[",
"]",
"for",
"item",
"in",
"b",
":",
"if",
"item",
"not",
"in",
"a",
":",
"result",
".",
"append",
"(",
"item",
")",
"return",
"result"
] | Returns the elements of B that are not in A. | [
"Returns",
"the",
"elements",
"of",
"B",
"that",
"are",
"not",
"in",
"A",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/set.py#L10-L18 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/util/set.py | intersection | def intersection (set1, set2):
""" Removes from set1 any items which don't appear in set2 and returns the result.
"""
assert is_iterable(set1)
assert is_iterable(set2)
result = []
for v in set1:
if v in set2:
result.append (v)
return result | python | def intersection (set1, set2):
""" Removes from set1 any items which don't appear in set2 and returns the result.
"""
assert is_iterable(set1)
assert is_iterable(set2)
result = []
for v in set1:
if v in set2:
result.append (v)
return result | [
"def",
"intersection",
"(",
"set1",
",",
"set2",
")",
":",
"assert",
"is_iterable",
"(",
"set1",
")",
"assert",
"is_iterable",
"(",
"set2",
")",
"result",
"=",
"[",
"]",
"for",
"v",
"in",
"set1",
":",
"if",
"v",
"in",
"set2",
":",
"result",
".",
"a... | Removes from set1 any items which don't appear in set2 and returns the result. | [
"Removes",
"from",
"set1",
"any",
"items",
"which",
"don",
"t",
"appear",
"in",
"set2",
"and",
"returns",
"the",
"result",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/set.py#L20-L29 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/util/set.py | contains | def contains (small, large):
""" Returns true iff all elements of 'small' exist in 'large'.
"""
small = to_seq (small)
large = to_seq (large)
for s in small:
if not s in large:
return False
return True | python | def contains (small, large):
""" Returns true iff all elements of 'small' exist in 'large'.
"""
small = to_seq (small)
large = to_seq (large)
for s in small:
if not s in large:
return False
return True | [
"def",
"contains",
"(",
"small",
",",
"large",
")",
":",
"small",
"=",
"to_seq",
"(",
"small",
")",
"large",
"=",
"to_seq",
"(",
"large",
")",
"for",
"s",
"in",
"small",
":",
"if",
"not",
"s",
"in",
"large",
":",
"return",
"False",
"return",
"True"... | Returns true iff all elements of 'small' exist in 'large'. | [
"Returns",
"true",
"iff",
"all",
"elements",
"of",
"small",
"exist",
"in",
"large",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/set.py#L31-L40 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/util/set.py | equal | def equal (a, b):
""" Returns True iff 'a' contains the same elements as 'b', irrespective of their order.
# TODO: Python 2.4 has a proper set class.
"""
assert is_iterable(a)
assert is_iterable(b)
return contains (a, b) and contains (b, a) | python | def equal (a, b):
""" Returns True iff 'a' contains the same elements as 'b', irrespective of their order.
# TODO: Python 2.4 has a proper set class.
"""
assert is_iterable(a)
assert is_iterable(b)
return contains (a, b) and contains (b, a) | [
"def",
"equal",
"(",
"a",
",",
"b",
")",
":",
"assert",
"is_iterable",
"(",
"a",
")",
"assert",
"is_iterable",
"(",
"b",
")",
"return",
"contains",
"(",
"a",
",",
"b",
")",
"and",
"contains",
"(",
"b",
",",
"a",
")"
] | Returns True iff 'a' contains the same elements as 'b', irrespective of their order.
# TODO: Python 2.4 has a proper set class. | [
"Returns",
"True",
"iff",
"a",
"contains",
"the",
"same",
"elements",
"as",
"b",
"irrespective",
"of",
"their",
"order",
".",
"#",
"TODO",
":",
"Python",
"2",
".",
"4",
"has",
"a",
"proper",
"set",
"class",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/set.py#L42-L48 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/image_classifier/_annotate.py | annotate | def annotate(data, image_column=None, annotation_column='annotations'):
"""
Annotate your images loaded in either an SFrame or SArray Format
The annotate util is a GUI assisted application used to create labels in
SArray Image data. Specifying a column, with dtype Image, in an SFrame
... | python | def annotate(data, image_column=None, annotation_column='annotations'):
"""
Annotate your images loaded in either an SFrame or SArray Format
The annotate util is a GUI assisted application used to create labels in
SArray Image data. Specifying a column, with dtype Image, in an SFrame
... | [
"def",
"annotate",
"(",
"data",
",",
"image_column",
"=",
"None",
",",
"annotation_column",
"=",
"'annotations'",
")",
":",
"# Check Value of Column Variables",
"if",
"image_column",
"==",
"None",
":",
"image_column",
"=",
"_tkutl",
".",
"_find_only_image_column",
"... | Annotate your images loaded in either an SFrame or SArray Format
The annotate util is a GUI assisted application used to create labels in
SArray Image data. Specifying a column, with dtype Image, in an SFrame
works as well since SFrames are composed of multiple SArrays.
When the GUI is... | [
"Annotate",
"your",
"images",
"loaded",
"in",
"either",
"an",
"SFrame",
"or",
"SArray",
"Format"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/image_classifier/_annotate.py#L30-L171 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/image_classifier/_annotate.py | recover_annotation | def recover_annotation():
"""
Recover the last annotated SFrame.
If you annotate an SFrame and forget to assign it to a variable, this
function allows you to recover the last annotated SFrame.
Returns
-------
out : SFrame
A new SFrame th... | python | def recover_annotation():
"""
Recover the last annotated SFrame.
If you annotate an SFrame and forget to assign it to a variable, this
function allows you to recover the last annotated SFrame.
Returns
-------
out : SFrame
A new SFrame th... | [
"def",
"recover_annotation",
"(",
")",
":",
"empty_instance",
"=",
"__tc",
".",
"extensions",
".",
"ImageClassification",
"(",
")",
"annotation_wrapper",
"=",
"empty_instance",
".",
"get_annotation_registry",
"(",
")",
"return",
"annotation_wrapper",
".",
"annotation_... | Recover the last annotated SFrame.
If you annotate an SFrame and forget to assign it to a variable, this
function allows you to recover the last annotated SFrame.
Returns
-------
out : SFrame
A new SFrame that contains the recovered annotation data.... | [
"Recover",
"the",
"last",
"annotated",
"SFrame",
".",
"If",
"you",
"annotate",
"an",
"SFrame",
"and",
"forget",
"to",
"assign",
"it",
"to",
"a",
"variable",
"this",
"function",
"allows",
"you",
"to",
"recover",
"the",
"last",
"annotated",
"SFrame",
".",
"R... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/image_classifier/_annotate.py#L173-L221 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_imputer.py | convert | def convert(model, input_features, output_features):
"""Convert a DictVectorizer model to the protobuf spec.
Parameters
----------
model: DictVectorizer
A fitted DictVectorizer model.
input_features: str
Name of the input column.
output_features: str
Name of the output... | python | def convert(model, input_features, output_features):
"""Convert a DictVectorizer model to the protobuf spec.
Parameters
----------
model: DictVectorizer
A fitted DictVectorizer model.
input_features: str
Name of the input column.
output_features: str
Name of the output... | [
"def",
"convert",
"(",
"model",
",",
"input_features",
",",
"output_features",
")",
":",
"if",
"not",
"(",
"_HAS_SKLEARN",
")",
":",
"raise",
"RuntimeError",
"(",
"'scikit-learn not found. scikit-learn conversion API is disabled.'",
")",
"# Set the interface params.",
"sp... | Convert a DictVectorizer model to the protobuf spec.
Parameters
----------
model: DictVectorizer
A fitted DictVectorizer model.
input_features: str
Name of the input column.
output_features: str
Name of the output column.
Returns
-------
model_spec: An object ... | [
"Convert",
"a",
"DictVectorizer",
"model",
"to",
"the",
"protobuf",
"spec",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_imputer.py#L21-L76 | train |
apple/turicreate | src/unity/python/turicreate/_cython/python_printer_callback.py | print_callback | def print_callback(val):
"""
Internal function.
This function is called via a call back returning from IPC to Cython
to Python. It tries to perform incremental printing to IPython Notebook or
Jupyter Notebook and when all else fails, just prints locally.
"""
success = False
try:
... | python | def print_callback(val):
"""
Internal function.
This function is called via a call back returning from IPC to Cython
to Python. It tries to perform incremental printing to IPython Notebook or
Jupyter Notebook and when all else fails, just prints locally.
"""
success = False
try:
... | [
"def",
"print_callback",
"(",
"val",
")",
":",
"success",
"=",
"False",
"try",
":",
"# for reasons I cannot fathom, regular printing, even directly",
"# to io.stdout does not work.",
"# I have to intrude rather deep into IPython to make it behave",
"if",
"have_ipython",
":",
"if",
... | Internal function.
This function is called via a call back returning from IPC to Cython
to Python. It tries to perform incremental printing to IPython Notebook or
Jupyter Notebook and when all else fails, just prints locally. | [
"Internal",
"function",
".",
"This",
"function",
"is",
"called",
"via",
"a",
"call",
"back",
"returning",
"from",
"IPC",
"to",
"Cython",
"to",
"Python",
".",
"It",
"tries",
"to",
"perform",
"incremental",
"printing",
"to",
"IPython",
"Notebook",
"or",
"Jupyt... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/_cython/python_printer_callback.py#L17-L38 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/_main.py | run | def run(toolkit_name, options, verbose=True, show_progress=False):
"""
Internal function to execute toolkit on the turicreate server.
Parameters
----------
toolkit_name : string
The name of the toolkit.
options : dict
A map containing the required input for the toolkit function... | python | def run(toolkit_name, options, verbose=True, show_progress=False):
"""
Internal function to execute toolkit on the turicreate server.
Parameters
----------
toolkit_name : string
The name of the toolkit.
options : dict
A map containing the required input for the toolkit function... | [
"def",
"run",
"(",
"toolkit_name",
",",
"options",
",",
"verbose",
"=",
"True",
",",
"show_progress",
"=",
"False",
")",
":",
"unity",
"=",
"glconnect",
".",
"get_unity",
"(",
")",
"if",
"(",
"not",
"verbose",
")",
":",
"glconnect",
".",
"get_server",
... | Internal function to execute toolkit on the turicreate server.
Parameters
----------
toolkit_name : string
The name of the toolkit.
options : dict
A map containing the required input for the toolkit function,
for example: {'graph': g, 'reset_prob': 0.15}.
verbose : bool
... | [
"Internal",
"function",
"to",
"execute",
"toolkit",
"on",
"the",
"turicreate",
"server",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_main.py#L25-L69 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | _RoundTowardZero | def _RoundTowardZero(value, divider):
"""Truncates the remainder part after division."""
# For some languanges, the sign of the remainder is implementation
# dependent if any of the operands is negative. Here we enforce
# "rounded toward zero" semantics. For example, for (-5) / 2 an
# implementation may give ... | python | def _RoundTowardZero(value, divider):
"""Truncates the remainder part after division."""
# For some languanges, the sign of the remainder is implementation
# dependent if any of the operands is negative. Here we enforce
# "rounded toward zero" semantics. For example, for (-5) / 2 an
# implementation may give ... | [
"def",
"_RoundTowardZero",
"(",
"value",
",",
"divider",
")",
":",
"# For some languanges, the sign of the remainder is implementation",
"# dependent if any of the operands is negative. Here we enforce",
"# \"rounded toward zero\" semantics. For example, for (-5) / 2 an",
"# implementation may... | Truncates the remainder part after division. | [
"Truncates",
"the",
"remainder",
"part",
"after",
"division",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L378-L390 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | _IsValidPath | def _IsValidPath(message_descriptor, path):
"""Checks whether the path is valid for Message Descriptor."""
parts = path.split('.')
last = parts.pop()
for name in parts:
field = message_descriptor.fields_by_name[name]
if (field is None or
field.label == FieldDescriptor.LABEL_REPEATED or
f... | python | def _IsValidPath(message_descriptor, path):
"""Checks whether the path is valid for Message Descriptor."""
parts = path.split('.')
last = parts.pop()
for name in parts:
field = message_descriptor.fields_by_name[name]
if (field is None or
field.label == FieldDescriptor.LABEL_REPEATED or
f... | [
"def",
"_IsValidPath",
"(",
"message_descriptor",
",",
"path",
")",
":",
"parts",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
"last",
"=",
"parts",
".",
"pop",
"(",
")",
"for",
"name",
"in",
"parts",
":",
"field",
"=",
"message_descriptor",
".",
"field... | Checks whether the path is valid for Message Descriptor. | [
"Checks",
"whether",
"the",
"path",
"is",
"valid",
"for",
"Message",
"Descriptor",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L471-L482 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | _CheckFieldMaskMessage | def _CheckFieldMaskMessage(message):
"""Raises ValueError if message is not a FieldMask."""
message_descriptor = message.DESCRIPTOR
if (message_descriptor.name != 'FieldMask' or
message_descriptor.file.name != 'google/protobuf/field_mask.proto'):
raise ValueError('Message {0} is not a FieldMask.'.format... | python | def _CheckFieldMaskMessage(message):
"""Raises ValueError if message is not a FieldMask."""
message_descriptor = message.DESCRIPTOR
if (message_descriptor.name != 'FieldMask' or
message_descriptor.file.name != 'google/protobuf/field_mask.proto'):
raise ValueError('Message {0} is not a FieldMask.'.format... | [
"def",
"_CheckFieldMaskMessage",
"(",
"message",
")",
":",
"message_descriptor",
"=",
"message",
".",
"DESCRIPTOR",
"if",
"(",
"message_descriptor",
".",
"name",
"!=",
"'FieldMask'",
"or",
"message_descriptor",
".",
"file",
".",
"name",
"!=",
"'google/protobuf/field... | Raises ValueError if message is not a FieldMask. | [
"Raises",
"ValueError",
"if",
"message",
"is",
"not",
"a",
"FieldMask",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L485-L491 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | _SnakeCaseToCamelCase | def _SnakeCaseToCamelCase(path_name):
"""Converts a path name from snake_case to camelCase."""
result = []
after_underscore = False
for c in path_name:
if c.isupper():
raise Error('Fail to print FieldMask to Json string: Path name '
'{0} must not contain uppercase letters.'.format(pa... | python | def _SnakeCaseToCamelCase(path_name):
"""Converts a path name from snake_case to camelCase."""
result = []
after_underscore = False
for c in path_name:
if c.isupper():
raise Error('Fail to print FieldMask to Json string: Path name '
'{0} must not contain uppercase letters.'.format(pa... | [
"def",
"_SnakeCaseToCamelCase",
"(",
"path_name",
")",
":",
"result",
"=",
"[",
"]",
"after_underscore",
"=",
"False",
"for",
"c",
"in",
"path_name",
":",
"if",
"c",
".",
"isupper",
"(",
")",
":",
"raise",
"Error",
"(",
"'Fail to print FieldMask to Json string... | Converts a path name from snake_case to camelCase. | [
"Converts",
"a",
"path",
"name",
"from",
"snake_case",
"to",
"camelCase",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L494-L518 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | _CamelCaseToSnakeCase | def _CamelCaseToSnakeCase(path_name):
"""Converts a field name from camelCase to snake_case."""
result = []
for c in path_name:
if c == '_':
raise ParseError('Fail to parse FieldMask: Path name '
'{0} must not contain "_"s.'.format(path_name))
if c.isupper():
result += '... | python | def _CamelCaseToSnakeCase(path_name):
"""Converts a field name from camelCase to snake_case."""
result = []
for c in path_name:
if c == '_':
raise ParseError('Fail to parse FieldMask: Path name '
'{0} must not contain "_"s.'.format(path_name))
if c.isupper():
result += '... | [
"def",
"_CamelCaseToSnakeCase",
"(",
"path_name",
")",
":",
"result",
"=",
"[",
"]",
"for",
"c",
"in",
"path_name",
":",
"if",
"c",
"==",
"'_'",
":",
"raise",
"ParseError",
"(",
"'Fail to parse FieldMask: Path name '",
"'{0} must not contain \"_\"s.'",
".",
"forma... | Converts a field name from camelCase to snake_case. | [
"Converts",
"a",
"field",
"name",
"from",
"camelCase",
"to",
"snake_case",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L521-L533 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | _MergeMessage | def _MergeMessage(
node, source, destination, replace_message, replace_repeated):
"""Merge all fields specified by a sub-tree from source to destination."""
source_descriptor = source.DESCRIPTOR
for name in node:
child = node[name]
field = source_descriptor.fields_by_name[name]
if field is None:
... | python | def _MergeMessage(
node, source, destination, replace_message, replace_repeated):
"""Merge all fields specified by a sub-tree from source to destination."""
source_descriptor = source.DESCRIPTOR
for name in node:
child = node[name]
field = source_descriptor.fields_by_name[name]
if field is None:
... | [
"def",
"_MergeMessage",
"(",
"node",
",",
"source",
",",
"destination",
",",
"replace_message",
",",
"replace_repeated",
")",
":",
"source_descriptor",
"=",
"source",
".",
"DESCRIPTOR",
"for",
"name",
"in",
"node",
":",
"child",
"=",
"node",
"[",
"name",
"]"... | Merge all fields specified by a sub-tree from source to destination. | [
"Merge",
"all",
"fields",
"specified",
"by",
"a",
"sub",
"-",
"tree",
"from",
"source",
"to",
"destination",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L633-L671 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | _AddFieldPaths | def _AddFieldPaths(node, prefix, field_mask):
"""Adds the field paths descended from node to field_mask."""
if not node:
field_mask.paths.append(prefix)
return
for name in sorted(node):
if prefix:
child_path = prefix + '.' + name
else:
child_path = name
_AddFieldPaths(node[name], c... | python | def _AddFieldPaths(node, prefix, field_mask):
"""Adds the field paths descended from node to field_mask."""
if not node:
field_mask.paths.append(prefix)
return
for name in sorted(node):
if prefix:
child_path = prefix + '.' + name
else:
child_path = name
_AddFieldPaths(node[name], c... | [
"def",
"_AddFieldPaths",
"(",
"node",
",",
"prefix",
",",
"field_mask",
")",
":",
"if",
"not",
"node",
":",
"field_mask",
".",
"paths",
".",
"append",
"(",
"prefix",
")",
"return",
"for",
"name",
"in",
"sorted",
"(",
"node",
")",
":",
"if",
"prefix",
... | Adds the field paths descended from node to field_mask. | [
"Adds",
"the",
"field",
"paths",
"descended",
"from",
"node",
"to",
"field_mask",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L674-L684 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Any.Pack | def Pack(self, msg, type_url_prefix='type.googleapis.com/'):
"""Packs the specified message into current Any message."""
if len(type_url_prefix) < 1 or type_url_prefix[-1] != '/':
self.type_url = '%s/%s' % (type_url_prefix, msg.DESCRIPTOR.full_name)
else:
self.type_url = '%s%s' % (type_url_prefi... | python | def Pack(self, msg, type_url_prefix='type.googleapis.com/'):
"""Packs the specified message into current Any message."""
if len(type_url_prefix) < 1 or type_url_prefix[-1] != '/':
self.type_url = '%s/%s' % (type_url_prefix, msg.DESCRIPTOR.full_name)
else:
self.type_url = '%s%s' % (type_url_prefi... | [
"def",
"Pack",
"(",
"self",
",",
"msg",
",",
"type_url_prefix",
"=",
"'type.googleapis.com/'",
")",
":",
"if",
"len",
"(",
"type_url_prefix",
")",
"<",
"1",
"or",
"type_url_prefix",
"[",
"-",
"1",
"]",
"!=",
"'/'",
":",
"self",
".",
"type_url",
"=",
"'... | Packs the specified message into current Any message. | [
"Packs",
"the",
"specified",
"message",
"into",
"current",
"Any",
"message",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L70-L76 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Any.Unpack | def Unpack(self, msg):
"""Unpacks the current Any message into specified message."""
descriptor = msg.DESCRIPTOR
if not self.Is(descriptor):
return False
msg.ParseFromString(self.value)
return True | python | def Unpack(self, msg):
"""Unpacks the current Any message into specified message."""
descriptor = msg.DESCRIPTOR
if not self.Is(descriptor):
return False
msg.ParseFromString(self.value)
return True | [
"def",
"Unpack",
"(",
"self",
",",
"msg",
")",
":",
"descriptor",
"=",
"msg",
".",
"DESCRIPTOR",
"if",
"not",
"self",
".",
"Is",
"(",
"descriptor",
")",
":",
"return",
"False",
"msg",
".",
"ParseFromString",
"(",
"self",
".",
"value",
")",
"return",
... | Unpacks the current Any message into specified message. | [
"Unpacks",
"the",
"current",
"Any",
"message",
"into",
"specified",
"message",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L78-L84 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Timestamp.ToJsonString | def ToJsonString(self):
"""Converts Timestamp to RFC 3339 date string format.
Returns:
A string converted from timestamp. The string is always Z-normalized
and uses 3, 6 or 9 fractional digits as required to represent the
exact time. Example of the return format: '1972-01-01T10:00:20.021Z'
... | python | def ToJsonString(self):
"""Converts Timestamp to RFC 3339 date string format.
Returns:
A string converted from timestamp. The string is always Z-normalized
and uses 3, 6 or 9 fractional digits as required to represent the
exact time. Example of the return format: '1972-01-01T10:00:20.021Z'
... | [
"def",
"ToJsonString",
"(",
"self",
")",
":",
"nanos",
"=",
"self",
".",
"nanos",
"%",
"_NANOS_PER_SECOND",
"total_sec",
"=",
"self",
".",
"seconds",
"+",
"(",
"self",
".",
"nanos",
"-",
"nanos",
")",
"//",
"_NANOS_PER_SECOND",
"seconds",
"=",
"total_sec",... | Converts Timestamp to RFC 3339 date string format.
Returns:
A string converted from timestamp. The string is always Z-normalized
and uses 3, 6 or 9 fractional digits as required to represent the
exact time. Example of the return format: '1972-01-01T10:00:20.021Z' | [
"Converts",
"Timestamp",
"to",
"RFC",
"3339",
"date",
"string",
"format",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L99-L125 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Timestamp.FromJsonString | def FromJsonString(self, value):
"""Parse a RFC 3339 date string format to Timestamp.
Args:
value: A date string. Any fractional digits (or none) and any offset are
accepted as long as they fit into nano-seconds precision.
Example of accepted format: '1972-01-01T10:00:20.021-05:00'
... | python | def FromJsonString(self, value):
"""Parse a RFC 3339 date string format to Timestamp.
Args:
value: A date string. Any fractional digits (or none) and any offset are
accepted as long as they fit into nano-seconds precision.
Example of accepted format: '1972-01-01T10:00:20.021-05:00'
... | [
"def",
"FromJsonString",
"(",
"self",
",",
"value",
")",
":",
"timezone_offset",
"=",
"value",
".",
"find",
"(",
"'Z'",
")",
"if",
"timezone_offset",
"==",
"-",
"1",
":",
"timezone_offset",
"=",
"value",
".",
"find",
"(",
"'+'",
")",
"if",
"timezone_offs... | Parse a RFC 3339 date string format to Timestamp.
Args:
value: A date string. Any fractional digits (or none) and any offset are
accepted as long as they fit into nano-seconds precision.
Example of accepted format: '1972-01-01T10:00:20.021-05:00'
Raises:
ParseError: On parsing ... | [
"Parse",
"a",
"RFC",
"3339",
"date",
"string",
"format",
"to",
"Timestamp",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L127-L183 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Timestamp.FromNanoseconds | def FromNanoseconds(self, nanos):
"""Converts nanoseconds since epoch to Timestamp."""
self.seconds = nanos // _NANOS_PER_SECOND
self.nanos = nanos % _NANOS_PER_SECOND | python | def FromNanoseconds(self, nanos):
"""Converts nanoseconds since epoch to Timestamp."""
self.seconds = nanos // _NANOS_PER_SECOND
self.nanos = nanos % _NANOS_PER_SECOND | [
"def",
"FromNanoseconds",
"(",
"self",
",",
"nanos",
")",
":",
"self",
".",
"seconds",
"=",
"nanos",
"//",
"_NANOS_PER_SECOND",
"self",
".",
"nanos",
"=",
"nanos",
"%",
"_NANOS_PER_SECOND"
] | Converts nanoseconds since epoch to Timestamp. | [
"Converts",
"nanoseconds",
"since",
"epoch",
"to",
"Timestamp",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L207-L210 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Timestamp.FromMicroseconds | def FromMicroseconds(self, micros):
"""Converts microseconds since epoch to Timestamp."""
self.seconds = micros // _MICROS_PER_SECOND
self.nanos = (micros % _MICROS_PER_SECOND) * _NANOS_PER_MICROSECOND | python | def FromMicroseconds(self, micros):
"""Converts microseconds since epoch to Timestamp."""
self.seconds = micros // _MICROS_PER_SECOND
self.nanos = (micros % _MICROS_PER_SECOND) * _NANOS_PER_MICROSECOND | [
"def",
"FromMicroseconds",
"(",
"self",
",",
"micros",
")",
":",
"self",
".",
"seconds",
"=",
"micros",
"//",
"_MICROS_PER_SECOND",
"self",
".",
"nanos",
"=",
"(",
"micros",
"%",
"_MICROS_PER_SECOND",
")",
"*",
"_NANOS_PER_MICROSECOND"
] | Converts microseconds since epoch to Timestamp. | [
"Converts",
"microseconds",
"since",
"epoch",
"to",
"Timestamp",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L212-L215 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Timestamp.FromMilliseconds | def FromMilliseconds(self, millis):
"""Converts milliseconds since epoch to Timestamp."""
self.seconds = millis // _MILLIS_PER_SECOND
self.nanos = (millis % _MILLIS_PER_SECOND) * _NANOS_PER_MILLISECOND | python | def FromMilliseconds(self, millis):
"""Converts milliseconds since epoch to Timestamp."""
self.seconds = millis // _MILLIS_PER_SECOND
self.nanos = (millis % _MILLIS_PER_SECOND) * _NANOS_PER_MILLISECOND | [
"def",
"FromMilliseconds",
"(",
"self",
",",
"millis",
")",
":",
"self",
".",
"seconds",
"=",
"millis",
"//",
"_MILLIS_PER_SECOND",
"self",
".",
"nanos",
"=",
"(",
"millis",
"%",
"_MILLIS_PER_SECOND",
")",
"*",
"_NANOS_PER_MILLISECOND"
] | Converts milliseconds since epoch to Timestamp. | [
"Converts",
"milliseconds",
"since",
"epoch",
"to",
"Timestamp",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L217-L220 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Timestamp.ToDatetime | def ToDatetime(self):
"""Converts Timestamp to datetime."""
return datetime.utcfromtimestamp(
self.seconds + self.nanos / float(_NANOS_PER_SECOND)) | python | def ToDatetime(self):
"""Converts Timestamp to datetime."""
return datetime.utcfromtimestamp(
self.seconds + self.nanos / float(_NANOS_PER_SECOND)) | [
"def",
"ToDatetime",
"(",
"self",
")",
":",
"return",
"datetime",
".",
"utcfromtimestamp",
"(",
"self",
".",
"seconds",
"+",
"self",
".",
"nanos",
"/",
"float",
"(",
"_NANOS_PER_SECOND",
")",
")"
] | Converts Timestamp to datetime. | [
"Converts",
"Timestamp",
"to",
"datetime",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L227-L230 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Timestamp.FromDatetime | def FromDatetime(self, dt):
"""Converts datetime to Timestamp."""
td = dt - datetime(1970, 1, 1)
self.seconds = td.seconds + td.days * _SECONDS_PER_DAY
self.nanos = td.microseconds * _NANOS_PER_MICROSECOND | python | def FromDatetime(self, dt):
"""Converts datetime to Timestamp."""
td = dt - datetime(1970, 1, 1)
self.seconds = td.seconds + td.days * _SECONDS_PER_DAY
self.nanos = td.microseconds * _NANOS_PER_MICROSECOND | [
"def",
"FromDatetime",
"(",
"self",
",",
"dt",
")",
":",
"td",
"=",
"dt",
"-",
"datetime",
"(",
"1970",
",",
"1",
",",
"1",
")",
"self",
".",
"seconds",
"=",
"td",
".",
"seconds",
"+",
"td",
".",
"days",
"*",
"_SECONDS_PER_DAY",
"self",
".",
"nan... | Converts datetime to Timestamp. | [
"Converts",
"datetime",
"to",
"Timestamp",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L232-L236 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Duration.ToMicroseconds | def ToMicroseconds(self):
"""Converts a Duration to microseconds."""
micros = _RoundTowardZero(self.nanos, _NANOS_PER_MICROSECOND)
return self.seconds * _MICROS_PER_SECOND + micros | python | def ToMicroseconds(self):
"""Converts a Duration to microseconds."""
micros = _RoundTowardZero(self.nanos, _NANOS_PER_MICROSECOND)
return self.seconds * _MICROS_PER_SECOND + micros | [
"def",
"ToMicroseconds",
"(",
"self",
")",
":",
"micros",
"=",
"_RoundTowardZero",
"(",
"self",
".",
"nanos",
",",
"_NANOS_PER_MICROSECOND",
")",
"return",
"self",
".",
"seconds",
"*",
"_MICROS_PER_SECOND",
"+",
"micros"
] | Converts a Duration to microseconds. | [
"Converts",
"a",
"Duration",
"to",
"microseconds",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L310-L313 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Duration.ToMilliseconds | def ToMilliseconds(self):
"""Converts a Duration to milliseconds."""
millis = _RoundTowardZero(self.nanos, _NANOS_PER_MILLISECOND)
return self.seconds * _MILLIS_PER_SECOND + millis | python | def ToMilliseconds(self):
"""Converts a Duration to milliseconds."""
millis = _RoundTowardZero(self.nanos, _NANOS_PER_MILLISECOND)
return self.seconds * _MILLIS_PER_SECOND + millis | [
"def",
"ToMilliseconds",
"(",
"self",
")",
":",
"millis",
"=",
"_RoundTowardZero",
"(",
"self",
".",
"nanos",
",",
"_NANOS_PER_MILLISECOND",
")",
"return",
"self",
".",
"seconds",
"*",
"_MILLIS_PER_SECOND",
"+",
"millis"
] | Converts a Duration to milliseconds. | [
"Converts",
"a",
"Duration",
"to",
"milliseconds",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L315-L318 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Duration.FromMicroseconds | def FromMicroseconds(self, micros):
"""Converts microseconds to Duration."""
self._NormalizeDuration(
micros // _MICROS_PER_SECOND,
(micros % _MICROS_PER_SECOND) * _NANOS_PER_MICROSECOND) | python | def FromMicroseconds(self, micros):
"""Converts microseconds to Duration."""
self._NormalizeDuration(
micros // _MICROS_PER_SECOND,
(micros % _MICROS_PER_SECOND) * _NANOS_PER_MICROSECOND) | [
"def",
"FromMicroseconds",
"(",
"self",
",",
"micros",
")",
":",
"self",
".",
"_NormalizeDuration",
"(",
"micros",
"//",
"_MICROS_PER_SECOND",
",",
"(",
"micros",
"%",
"_MICROS_PER_SECOND",
")",
"*",
"_NANOS_PER_MICROSECOND",
")"
] | Converts microseconds to Duration. | [
"Converts",
"microseconds",
"to",
"Duration",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L329-L333 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Duration.FromMilliseconds | def FromMilliseconds(self, millis):
"""Converts milliseconds to Duration."""
self._NormalizeDuration(
millis // _MILLIS_PER_SECOND,
(millis % _MILLIS_PER_SECOND) * _NANOS_PER_MILLISECOND) | python | def FromMilliseconds(self, millis):
"""Converts milliseconds to Duration."""
self._NormalizeDuration(
millis // _MILLIS_PER_SECOND,
(millis % _MILLIS_PER_SECOND) * _NANOS_PER_MILLISECOND) | [
"def",
"FromMilliseconds",
"(",
"self",
",",
"millis",
")",
":",
"self",
".",
"_NormalizeDuration",
"(",
"millis",
"//",
"_MILLIS_PER_SECOND",
",",
"(",
"millis",
"%",
"_MILLIS_PER_SECOND",
")",
"*",
"_NANOS_PER_MILLISECOND",
")"
] | Converts milliseconds to Duration. | [
"Converts",
"milliseconds",
"to",
"Duration",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L335-L339 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Duration.ToTimedelta | def ToTimedelta(self):
"""Converts Duration to timedelta."""
return timedelta(
seconds=self.seconds, microseconds=_RoundTowardZero(
self.nanos, _NANOS_PER_MICROSECOND)) | python | def ToTimedelta(self):
"""Converts Duration to timedelta."""
return timedelta(
seconds=self.seconds, microseconds=_RoundTowardZero(
self.nanos, _NANOS_PER_MICROSECOND)) | [
"def",
"ToTimedelta",
"(",
"self",
")",
":",
"return",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"seconds",
",",
"microseconds",
"=",
"_RoundTowardZero",
"(",
"self",
".",
"nanos",
",",
"_NANOS_PER_MICROSECOND",
")",
")"
] | Converts Duration to timedelta. | [
"Converts",
"Duration",
"to",
"timedelta",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L346-L350 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Duration.FromTimedelta | def FromTimedelta(self, td):
"""Convertd timedelta to Duration."""
self._NormalizeDuration(td.seconds + td.days * _SECONDS_PER_DAY,
td.microseconds * _NANOS_PER_MICROSECOND) | python | def FromTimedelta(self, td):
"""Convertd timedelta to Duration."""
self._NormalizeDuration(td.seconds + td.days * _SECONDS_PER_DAY,
td.microseconds * _NANOS_PER_MICROSECOND) | [
"def",
"FromTimedelta",
"(",
"self",
",",
"td",
")",
":",
"self",
".",
"_NormalizeDuration",
"(",
"td",
".",
"seconds",
"+",
"td",
".",
"days",
"*",
"_SECONDS_PER_DAY",
",",
"td",
".",
"microseconds",
"*",
"_NANOS_PER_MICROSECOND",
")"
] | Convertd timedelta to Duration. | [
"Convertd",
"timedelta",
"to",
"Duration",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L352-L355 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | Duration._NormalizeDuration | def _NormalizeDuration(self, seconds, nanos):
"""Set Duration by seconds and nonas."""
# Force nanos to be negative if the duration is negative.
if seconds < 0 and nanos > 0:
seconds += 1
nanos -= _NANOS_PER_SECOND
self.seconds = seconds
self.nanos = nanos | python | def _NormalizeDuration(self, seconds, nanos):
"""Set Duration by seconds and nonas."""
# Force nanos to be negative if the duration is negative.
if seconds < 0 and nanos > 0:
seconds += 1
nanos -= _NANOS_PER_SECOND
self.seconds = seconds
self.nanos = nanos | [
"def",
"_NormalizeDuration",
"(",
"self",
",",
"seconds",
",",
"nanos",
")",
":",
"# Force nanos to be negative if the duration is negative.",
"if",
"seconds",
"<",
"0",
"and",
"nanos",
">",
"0",
":",
"seconds",
"+=",
"1",
"nanos",
"-=",
"_NANOS_PER_SECOND",
"self... | Set Duration by seconds and nonas. | [
"Set",
"Duration",
"by",
"seconds",
"and",
"nonas",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L357-L364 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | FieldMask.ToJsonString | def ToJsonString(self):
"""Converts FieldMask to string according to proto3 JSON spec."""
camelcase_paths = []
for path in self.paths:
camelcase_paths.append(_SnakeCaseToCamelCase(path))
return ','.join(camelcase_paths) | python | def ToJsonString(self):
"""Converts FieldMask to string according to proto3 JSON spec."""
camelcase_paths = []
for path in self.paths:
camelcase_paths.append(_SnakeCaseToCamelCase(path))
return ','.join(camelcase_paths) | [
"def",
"ToJsonString",
"(",
"self",
")",
":",
"camelcase_paths",
"=",
"[",
"]",
"for",
"path",
"in",
"self",
".",
"paths",
":",
"camelcase_paths",
".",
"append",
"(",
"_SnakeCaseToCamelCase",
"(",
"path",
")",
")",
"return",
"','",
".",
"join",
"(",
"cam... | Converts FieldMask to string according to proto3 JSON spec. | [
"Converts",
"FieldMask",
"to",
"string",
"according",
"to",
"proto3",
"JSON",
"spec",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L396-L401 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | FieldMask.IsValidForDescriptor | def IsValidForDescriptor(self, message_descriptor):
"""Checks whether the FieldMask is valid for Message Descriptor."""
for path in self.paths:
if not _IsValidPath(message_descriptor, path):
return False
return True | python | def IsValidForDescriptor(self, message_descriptor):
"""Checks whether the FieldMask is valid for Message Descriptor."""
for path in self.paths:
if not _IsValidPath(message_descriptor, path):
return False
return True | [
"def",
"IsValidForDescriptor",
"(",
"self",
",",
"message_descriptor",
")",
":",
"for",
"path",
"in",
"self",
".",
"paths",
":",
"if",
"not",
"_IsValidPath",
"(",
"message_descriptor",
",",
"path",
")",
":",
"return",
"False",
"return",
"True"
] | Checks whether the FieldMask is valid for Message Descriptor. | [
"Checks",
"whether",
"the",
"FieldMask",
"is",
"valid",
"for",
"Message",
"Descriptor",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L409-L414 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | FieldMask.AllFieldsFromDescriptor | def AllFieldsFromDescriptor(self, message_descriptor):
"""Gets all direct fields of Message Descriptor to FieldMask."""
self.Clear()
for field in message_descriptor.fields:
self.paths.append(field.name) | python | def AllFieldsFromDescriptor(self, message_descriptor):
"""Gets all direct fields of Message Descriptor to FieldMask."""
self.Clear()
for field in message_descriptor.fields:
self.paths.append(field.name) | [
"def",
"AllFieldsFromDescriptor",
"(",
"self",
",",
"message_descriptor",
")",
":",
"self",
".",
"Clear",
"(",
")",
"for",
"field",
"in",
"message_descriptor",
".",
"fields",
":",
"self",
".",
"paths",
".",
"append",
"(",
"field",
".",
"name",
")"
] | Gets all direct fields of Message Descriptor to FieldMask. | [
"Gets",
"all",
"direct",
"fields",
"of",
"Message",
"Descriptor",
"to",
"FieldMask",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L416-L420 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | FieldMask.Union | def Union(self, mask1, mask2):
"""Merges mask1 and mask2 into this FieldMask."""
_CheckFieldMaskMessage(mask1)
_CheckFieldMaskMessage(mask2)
tree = _FieldMaskTree(mask1)
tree.MergeFromFieldMask(mask2)
tree.ToFieldMask(self) | python | def Union(self, mask1, mask2):
"""Merges mask1 and mask2 into this FieldMask."""
_CheckFieldMaskMessage(mask1)
_CheckFieldMaskMessage(mask2)
tree = _FieldMaskTree(mask1)
tree.MergeFromFieldMask(mask2)
tree.ToFieldMask(self) | [
"def",
"Union",
"(",
"self",
",",
"mask1",
",",
"mask2",
")",
":",
"_CheckFieldMaskMessage",
"(",
"mask1",
")",
"_CheckFieldMaskMessage",
"(",
"mask2",
")",
"tree",
"=",
"_FieldMaskTree",
"(",
"mask1",
")",
"tree",
".",
"MergeFromFieldMask",
"(",
"mask2",
")... | Merges mask1 and mask2 into this FieldMask. | [
"Merges",
"mask1",
"and",
"mask2",
"into",
"this",
"FieldMask",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L435-L441 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | FieldMask.Intersect | def Intersect(self, mask1, mask2):
"""Intersects mask1 and mask2 into this FieldMask."""
_CheckFieldMaskMessage(mask1)
_CheckFieldMaskMessage(mask2)
tree = _FieldMaskTree(mask1)
intersection = _FieldMaskTree()
for path in mask2.paths:
tree.IntersectPath(path, intersection)
intersection... | python | def Intersect(self, mask1, mask2):
"""Intersects mask1 and mask2 into this FieldMask."""
_CheckFieldMaskMessage(mask1)
_CheckFieldMaskMessage(mask2)
tree = _FieldMaskTree(mask1)
intersection = _FieldMaskTree()
for path in mask2.paths:
tree.IntersectPath(path, intersection)
intersection... | [
"def",
"Intersect",
"(",
"self",
",",
"mask1",
",",
"mask2",
")",
":",
"_CheckFieldMaskMessage",
"(",
"mask1",
")",
"_CheckFieldMaskMessage",
"(",
"mask2",
")",
"tree",
"=",
"_FieldMaskTree",
"(",
"mask1",
")",
"intersection",
"=",
"_FieldMaskTree",
"(",
")",
... | Intersects mask1 and mask2 into this FieldMask. | [
"Intersects",
"mask1",
"and",
"mask2",
"into",
"this",
"FieldMask",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L443-L451 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | FieldMask.MergeMessage | def MergeMessage(
self, source, destination,
replace_message_field=False, replace_repeated_field=False):
"""Merges fields specified in FieldMask from source to destination.
Args:
source: Source message.
destination: The destination message to be merged into.
replace_message_field:... | python | def MergeMessage(
self, source, destination,
replace_message_field=False, replace_repeated_field=False):
"""Merges fields specified in FieldMask from source to destination.
Args:
source: Source message.
destination: The destination message to be merged into.
replace_message_field:... | [
"def",
"MergeMessage",
"(",
"self",
",",
"source",
",",
"destination",
",",
"replace_message_field",
"=",
"False",
",",
"replace_repeated_field",
"=",
"False",
")",
":",
"tree",
"=",
"_FieldMaskTree",
"(",
"self",
")",
"tree",
".",
"MergeMessage",
"(",
"source... | Merges fields specified in FieldMask from source to destination.
Args:
source: Source message.
destination: The destination message to be merged into.
replace_message_field: Replace message field if True. Merge message
field if False.
replace_repeated_field: Replace repeated field... | [
"Merges",
"fields",
"specified",
"in",
"FieldMask",
"from",
"source",
"to",
"destination",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L453-L468 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | _FieldMaskTree.AddPath | def AddPath(self, path):
"""Adds a field path into the tree.
If the field path to add is a sub-path of an existing field path
in the tree (i.e., a leaf node), it means the tree already matches
the given path so nothing will be added to the tree. If the path
matches an existing non-leaf node in the ... | python | def AddPath(self, path):
"""Adds a field path into the tree.
If the field path to add is a sub-path of an existing field path
in the tree (i.e., a leaf node), it means the tree already matches
the given path so nothing will be added to the tree. If the path
matches an existing non-leaf node in the ... | [
"def",
"AddPath",
"(",
"self",
",",
"path",
")",
":",
"node",
"=",
"self",
".",
"_root",
"for",
"name",
"in",
"path",
".",
"split",
"(",
"'.'",
")",
":",
"if",
"name",
"not",
"in",
"node",
":",
"node",
"[",
"name",
"]",
"=",
"{",
"}",
"elif",
... | Adds a field path into the tree.
If the field path to add is a sub-path of an existing field path
in the tree (i.e., a leaf node), it means the tree already matches
the given path so nothing will be added to the tree. If the path
matches an existing non-leaf node in the tree, that non-leaf node
wil... | [
"Adds",
"a",
"field",
"path",
"into",
"the",
"tree",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L560-L583 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | _FieldMaskTree.IntersectPath | def IntersectPath(self, path, intersection):
"""Calculates the intersection part of a field path with this tree.
Args:
path: The field path to calculates.
intersection: The out tree to record the intersection part.
"""
node = self._root
for name in path.split('.'):
if name not in ... | python | def IntersectPath(self, path, intersection):
"""Calculates the intersection part of a field path with this tree.
Args:
path: The field path to calculates.
intersection: The out tree to record the intersection part.
"""
node = self._root
for name in path.split('.'):
if name not in ... | [
"def",
"IntersectPath",
"(",
"self",
",",
"path",
",",
"intersection",
")",
":",
"node",
"=",
"self",
".",
"_root",
"for",
"name",
"in",
"path",
".",
"split",
"(",
"'.'",
")",
":",
"if",
"name",
"not",
"in",
"node",
":",
"return",
"elif",
"not",
"n... | Calculates the intersection part of a field path with this tree.
Args:
path: The field path to calculates.
intersection: The out tree to record the intersection part. | [
"Calculates",
"the",
"intersection",
"part",
"of",
"a",
"field",
"path",
"with",
"this",
"tree",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L590-L605 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | _FieldMaskTree.AddLeafNodes | def AddLeafNodes(self, prefix, node):
"""Adds leaf nodes begin with prefix to this tree."""
if not node:
self.AddPath(prefix)
for name in node:
child_path = prefix + '.' + name
self.AddLeafNodes(child_path, node[name]) | python | def AddLeafNodes(self, prefix, node):
"""Adds leaf nodes begin with prefix to this tree."""
if not node:
self.AddPath(prefix)
for name in node:
child_path = prefix + '.' + name
self.AddLeafNodes(child_path, node[name]) | [
"def",
"AddLeafNodes",
"(",
"self",
",",
"prefix",
",",
"node",
")",
":",
"if",
"not",
"node",
":",
"self",
".",
"AddPath",
"(",
"prefix",
")",
"for",
"name",
"in",
"node",
":",
"child_path",
"=",
"prefix",
"+",
"'.'",
"+",
"name",
"self",
".",
"Ad... | Adds leaf nodes begin with prefix to this tree. | [
"Adds",
"leaf",
"nodes",
"begin",
"with",
"prefix",
"to",
"this",
"tree",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L607-L613 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py | _FieldMaskTree.MergeMessage | def MergeMessage(
self, source, destination,
replace_message, replace_repeated):
"""Merge all fields specified by this tree from source to destination."""
_MergeMessage(
self._root, source, destination, replace_message, replace_repeated) | python | def MergeMessage(
self, source, destination,
replace_message, replace_repeated):
"""Merge all fields specified by this tree from source to destination."""
_MergeMessage(
self._root, source, destination, replace_message, replace_repeated) | [
"def",
"MergeMessage",
"(",
"self",
",",
"source",
",",
"destination",
",",
"replace_message",
",",
"replace_repeated",
")",
":",
"_MergeMessage",
"(",
"self",
".",
"_root",
",",
"source",
",",
"destination",
",",
"replace_message",
",",
"replace_repeated",
")"
... | Merge all fields specified by this tree from source to destination. | [
"Merge",
"all",
"fields",
"specified",
"by",
"this",
"tree",
"from",
"source",
"to",
"destination",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L615-L620 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/tools/rc.py | configure | def configure (command = None, condition = None, options = None):
"""
Configures a new resource compilation command specific to a condition,
usually a toolset selection condition. The possible options are:
* <rc-type>(rc|windres) - Indicates the type of options the command
... | python | def configure (command = None, condition = None, options = None):
"""
Configures a new resource compilation command specific to a condition,
usually a toolset selection condition. The possible options are:
* <rc-type>(rc|windres) - Indicates the type of options the command
... | [
"def",
"configure",
"(",
"command",
"=",
"None",
",",
"condition",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"rc_type",
"=",
"feature",
".",
"get_values",
"(",
"'<rc-type>'",
",",
"options",
")",
"if",
"rc_type",
":",
"assert",
"(",
"len",
"(... | Configures a new resource compilation command specific to a condition,
usually a toolset selection condition. The possible options are:
* <rc-type>(rc|windres) - Indicates the type of options the command
accepts.
Even though the arguments are all optional, only when a command... | [
"Configures",
"a",
"new",
"resource",
"compilation",
"command",
"specific",
"to",
"a",
"condition",
"usually",
"a",
"toolset",
"selection",
"condition",
".",
"The",
"possible",
"options",
"are",
":"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/tools/rc.py#L50-L75 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_NuSVR.py | convert | def convert(model, feature_names, target):
"""Convert a Nu Support Vector Regression (NuSVR) model to the protobuf spec.
Parameters
----------
model: NuSVR
A trained NuSVR encoder model.
feature_names: [str]
Name of the input columns.
target: str
Name of the output colu... | python | def convert(model, feature_names, target):
"""Convert a Nu Support Vector Regression (NuSVR) model to the protobuf spec.
Parameters
----------
model: NuSVR
A trained NuSVR encoder model.
feature_names: [str]
Name of the input columns.
target: str
Name of the output colu... | [
"def",
"convert",
"(",
"model",
",",
"feature_names",
",",
"target",
")",
":",
"if",
"not",
"(",
"_HAS_SKLEARN",
")",
":",
"raise",
"RuntimeError",
"(",
"'scikit-learn not found. scikit-learn conversion API is disabled.'",
")",
"_sklearn_util",
".",
"check_expected_type... | Convert a Nu Support Vector Regression (NuSVR) model to the protobuf spec.
Parameters
----------
model: NuSVR
A trained NuSVR encoder model.
feature_names: [str]
Name of the input columns.
target: str
Name of the output column.
Returns
-------
model_spec: An ob... | [
"Convert",
"a",
"Nu",
"Support",
"Vector",
"Regression",
"(",
"NuSVR",
")",
"model",
"to",
"the",
"protobuf",
"spec",
".",
"Parameters",
"----------",
"model",
":",
"NuSVR",
"A",
"trained",
"NuSVR",
"encoder",
"model",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_NuSVR.py#L20-L42 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/regression/linear_regression.py | create | def create(dataset, target, features=None, l2_penalty=1e-2, l1_penalty=0.0,
solver='auto', feature_rescaling=True,
convergence_threshold = _DEFAULT_SOLVER_OPTIONS['convergence_threshold'],
step_size = _DEFAULT_SOLVER_OPTIONS['step_size'],
lbfgs_memory_level = _DEFAULT_SOLVER_OPTIONS['lbfgs_memory_level'... | python | def create(dataset, target, features=None, l2_penalty=1e-2, l1_penalty=0.0,
solver='auto', feature_rescaling=True,
convergence_threshold = _DEFAULT_SOLVER_OPTIONS['convergence_threshold'],
step_size = _DEFAULT_SOLVER_OPTIONS['step_size'],
lbfgs_memory_level = _DEFAULT_SOLVER_OPTIONS['lbfgs_memory_level'... | [
"def",
"create",
"(",
"dataset",
",",
"target",
",",
"features",
"=",
"None",
",",
"l2_penalty",
"=",
"1e-2",
",",
"l1_penalty",
"=",
"0.0",
",",
"solver",
"=",
"'auto'",
",",
"feature_rescaling",
"=",
"True",
",",
"convergence_threshold",
"=",
"_DEFAULT_SOL... | Create a :class:`~turicreate.linear_regression.LinearRegression` to
predict a scalar target variable as a linear function of one or more
features. In addition to standard numeric and categorical types, features
can also be extracted automatically from list- or dictionary-type SFrame
columns.
The li... | [
"Create",
"a",
":",
"class",
":",
"~turicreate",
".",
"linear_regression",
".",
"LinearRegression",
"to",
"predict",
"a",
"scalar",
"target",
"variable",
"as",
"a",
"linear",
"function",
"of",
"one",
"or",
"more",
"features",
".",
"In",
"addition",
"to",
"st... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/regression/linear_regression.py#L28-L285 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/regression/linear_regression.py | LinearRegression.export_coreml | def export_coreml(self, filename):
"""
Export the model in Core ML format.
Parameters
----------
filename: str
A valid filename where the model can be saved.
Examples
--------
>>> model.export_coreml("MyModel.mlmodel")
"""
from ... | python | def export_coreml(self, filename):
"""
Export the model in Core ML format.
Parameters
----------
filename: str
A valid filename where the model can be saved.
Examples
--------
>>> model.export_coreml("MyModel.mlmodel")
"""
from ... | [
"def",
"export_coreml",
"(",
"self",
",",
"filename",
")",
":",
"from",
"turicreate",
".",
"extensions",
"import",
"_linear_regression_export_as_model_asset",
"from",
"turicreate",
".",
"toolkits",
"import",
"_coreml_utils",
"display_name",
"=",
"\"linear regression\"",
... | Export the model in Core ML format.
Parameters
----------
filename: str
A valid filename where the model can be saved.
Examples
--------
>>> model.export_coreml("MyModel.mlmodel") | [
"Export",
"the",
"model",
"in",
"Core",
"ML",
"format",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/regression/linear_regression.py#L427-L451 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/regression/linear_regression.py | LinearRegression.predict | def predict(self, dataset, missing_value_action='auto'):
"""
Return target value predictions for ``dataset``, using the trained
linear regression model. This method can be used to get fitted values
for the model by inputting the training dataset.
Parameters
----------
... | python | def predict(self, dataset, missing_value_action='auto'):
"""
Return target value predictions for ``dataset``, using the trained
linear regression model. This method can be used to get fitted values
for the model by inputting the training dataset.
Parameters
----------
... | [
"def",
"predict",
"(",
"self",
",",
"dataset",
",",
"missing_value_action",
"=",
"'auto'",
")",
":",
"return",
"super",
"(",
"LinearRegression",
",",
"self",
")",
".",
"predict",
"(",
"dataset",
",",
"missing_value_action",
"=",
"missing_value_action",
")"
] | Return target value predictions for ``dataset``, using the trained
linear regression model. This method can be used to get fitted values
for the model by inputting the training dataset.
Parameters
----------
dataset : SFrame | pandas.Dataframe
Dataset of new observat... | [
"Return",
"target",
"value",
"predictions",
"for",
"dataset",
"using",
"the",
"trained",
"linear",
"regression",
"model",
".",
"This",
"method",
"can",
"be",
"used",
"to",
"get",
"fitted",
"values",
"for",
"the",
"model",
"by",
"inputting",
"the",
"training",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/regression/linear_regression.py#L519-L564 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/regression/linear_regression.py | LinearRegression.evaluate | def evaluate(self, dataset, metric='auto', missing_value_action='auto'):
r"""Evaluate the model by making target value predictions and comparing
to actual values.
Two metrics are used to evaluate linear regression models. The first
is root-mean-squared error (RMSE) while the second is ... | python | def evaluate(self, dataset, metric='auto', missing_value_action='auto'):
r"""Evaluate the model by making target value predictions and comparing
to actual values.
Two metrics are used to evaluate linear regression models. The first
is root-mean-squared error (RMSE) while the second is ... | [
"def",
"evaluate",
"(",
"self",
",",
"dataset",
",",
"metric",
"=",
"'auto'",
",",
"missing_value_action",
"=",
"'auto'",
")",
":",
"_raise_error_evaluation_metric_is_valid",
"(",
"metric",
",",
"[",
"'auto'",
",",
"'rmse'",
",",
"'max_error'",
"]",
")",
"retu... | r"""Evaluate the model by making target value predictions and comparing
to actual values.
Two metrics are used to evaluate linear regression models. The first
is root-mean-squared error (RMSE) while the second is the absolute
value of the maximum error between the actual and predicted ... | [
"r",
"Evaluate",
"the",
"model",
"by",
"making",
"target",
"value",
"predictions",
"and",
"comparing",
"to",
"actual",
"values",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/regression/linear_regression.py#L567-L635 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/sound_classifier/mel_features.py | frame | def frame(data, window_length, hop_length):
"""Convert array into a sequence of successive possibly overlapping frames.
An n-dimensional array of shape (num_samples, ...) is converted into an
(n+1)-D array of shape (num_frames, window_length, ...), where each frame
starts hop_length points after the preceding ... | python | def frame(data, window_length, hop_length):
"""Convert array into a sequence of successive possibly overlapping frames.
An n-dimensional array of shape (num_samples, ...) is converted into an
(n+1)-D array of shape (num_frames, window_length, ...), where each frame
starts hop_length points after the preceding ... | [
"def",
"frame",
"(",
"data",
",",
"window_length",
",",
"hop_length",
")",
":",
"num_samples",
"=",
"data",
".",
"shape",
"[",
"0",
"]",
"num_frames",
"=",
"1",
"+",
"int",
"(",
"np",
".",
"floor",
"(",
"(",
"num_samples",
"-",
"window_length",
")",
... | Convert array into a sequence of successive possibly overlapping frames.
An n-dimensional array of shape (num_samples, ...) is converted into an
(n+1)-D array of shape (num_frames, window_length, ...), where each frame
starts hop_length points after the preceding one.
This is accomplished using stride_tricks,... | [
"Convert",
"array",
"into",
"a",
"sequence",
"of",
"successive",
"possibly",
"overlapping",
"frames",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/sound_classifier/mel_features.py#L21-L45 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/sound_classifier/mel_features.py | periodic_hann | def periodic_hann(window_length):
"""Calculate a "periodic" Hann window.
The classic Hann window is defined as a raised cosine that starts and
ends on zero, and where every value appears twice, except the middle
point for an odd-length window. Matlab calls this a "symmetric" window
and np.hanning() returns ... | python | def periodic_hann(window_length):
"""Calculate a "periodic" Hann window.
The classic Hann window is defined as a raised cosine that starts and
ends on zero, and where every value appears twice, except the middle
point for an odd-length window. Matlab calls this a "symmetric" window
and np.hanning() returns ... | [
"def",
"periodic_hann",
"(",
"window_length",
")",
":",
"return",
"0.5",
"-",
"(",
"0.5",
"*",
"np",
".",
"cos",
"(",
"2",
"*",
"np",
".",
"pi",
"/",
"window_length",
"*",
"np",
".",
"arange",
"(",
"window_length",
")",
")",
")"
] | Calculate a "periodic" Hann window.
The classic Hann window is defined as a raised cosine that starts and
ends on zero, and where every value appears twice, except the middle
point for an odd-length window. Matlab calls this a "symmetric" window
and np.hanning() returns it. However, for Fourier analysis, thi... | [
"Calculate",
"a",
"periodic",
"Hann",
"window",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/sound_classifier/mel_features.py#L48-L68 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/sound_classifier/mel_features.py | stft_magnitude | def stft_magnitude(signal, fft_length,
hop_length=None,
window_length=None):
"""Calculate the short-time Fourier transform magnitude.
Args:
signal: 1D np.array of the input time-domain signal.
fft_length: Size of the FFT to apply.
hop_length: Advance (in samples) b... | python | def stft_magnitude(signal, fft_length,
hop_length=None,
window_length=None):
"""Calculate the short-time Fourier transform magnitude.
Args:
signal: 1D np.array of the input time-domain signal.
fft_length: Size of the FFT to apply.
hop_length: Advance (in samples) b... | [
"def",
"stft_magnitude",
"(",
"signal",
",",
"fft_length",
",",
"hop_length",
"=",
"None",
",",
"window_length",
"=",
"None",
")",
":",
"frames",
"=",
"frame",
"(",
"signal",
",",
"window_length",
",",
"hop_length",
")",
"# Apply frame window to each frame. We use... | Calculate the short-time Fourier transform magnitude.
Args:
signal: 1D np.array of the input time-domain signal.
fft_length: Size of the FFT to apply.
hop_length: Advance (in samples) between each frame passed to FFT.
window_length: Length of each block of samples to pass to FFT.
Returns:
2D n... | [
"Calculate",
"the",
"short",
"-",
"time",
"Fourier",
"transform",
"magnitude",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/sound_classifier/mel_features.py#L71-L92 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/sound_classifier/mel_features.py | spectrogram_to_mel_matrix | def spectrogram_to_mel_matrix(num_mel_bins=20,
num_spectrogram_bins=129,
audio_sample_rate=8000,
lower_edge_hertz=125.0,
upper_edge_hertz=3800.0):
"""Return a matrix that can post-multiply spectrogr... | python | def spectrogram_to_mel_matrix(num_mel_bins=20,
num_spectrogram_bins=129,
audio_sample_rate=8000,
lower_edge_hertz=125.0,
upper_edge_hertz=3800.0):
"""Return a matrix that can post-multiply spectrogr... | [
"def",
"spectrogram_to_mel_matrix",
"(",
"num_mel_bins",
"=",
"20",
",",
"num_spectrogram_bins",
"=",
"129",
",",
"audio_sample_rate",
"=",
"8000",
",",
"lower_edge_hertz",
"=",
"125.0",
",",
"upper_edge_hertz",
"=",
"3800.0",
")",
":",
"nyquist_hertz",
"=",
"audi... | Return a matrix that can post-multiply spectrogram rows to make mel.
Returns a np.array matrix A that can be used to post-multiply a matrix S of
spectrogram values (STFT magnitudes) arranged as frames x bins to generate a
"mel spectrogram" M of frames x num_mel_bins. M = S A.
The classic HTK algorithm exploi... | [
"Return",
"a",
"matrix",
"that",
"can",
"post",
"-",
"multiply",
"spectrogram",
"rows",
"to",
"make",
"mel",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/sound_classifier/mel_features.py#L114-L189 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/sound_classifier/mel_features.py | log_mel_spectrogram | def log_mel_spectrogram(data,
audio_sample_rate=8000,
log_offset=0.0,
window_length_secs=0.025,
hop_length_secs=0.010,
**kwargs):
"""Convert waveform to a log magnitude mel-frequency spectrogram.
... | python | def log_mel_spectrogram(data,
audio_sample_rate=8000,
log_offset=0.0,
window_length_secs=0.025,
hop_length_secs=0.010,
**kwargs):
"""Convert waveform to a log magnitude mel-frequency spectrogram.
... | [
"def",
"log_mel_spectrogram",
"(",
"data",
",",
"audio_sample_rate",
"=",
"8000",
",",
"log_offset",
"=",
"0.0",
",",
"window_length_secs",
"=",
"0.025",
",",
"hop_length_secs",
"=",
"0.010",
",",
"*",
"*",
"kwargs",
")",
":",
"window_length_samples",
"=",
"in... | Convert waveform to a log magnitude mel-frequency spectrogram.
Args:
data: 1D np.array of waveform data.
audio_sample_rate: The sampling rate of data.
log_offset: Add this to values when taking log to avoid -Infs.
window_length_secs: Duration of each window to analyze.
hop_length_secs: Advance be... | [
"Convert",
"waveform",
"to",
"a",
"log",
"magnitude",
"mel",
"-",
"frequency",
"spectrogram",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/sound_classifier/mel_features.py#L192-L223 | train |
apple/turicreate | src/unity/python/turicreate/util/_sframe_generation.py | generate_random_sframe | def generate_random_sframe(num_rows, column_codes, random_seed = 0):
"""
Creates a random SFrame with `num_rows` rows and randomly
generated column types determined by `column_codes`. The output
SFrame is deterministic based on `random_seed`.
`column_types` is a string with each character denoti... | python | def generate_random_sframe(num_rows, column_codes, random_seed = 0):
"""
Creates a random SFrame with `num_rows` rows and randomly
generated column types determined by `column_codes`. The output
SFrame is deterministic based on `random_seed`.
`column_types` is a string with each character denoti... | [
"def",
"generate_random_sframe",
"(",
"num_rows",
",",
"column_codes",
",",
"random_seed",
"=",
"0",
")",
":",
"from",
".",
".",
"extensions",
"import",
"_generate_random_sframe",
"assert",
"isinstance",
"(",
"column_codes",
",",
"str",
")",
"assert",
"isinstance"... | Creates a random SFrame with `num_rows` rows and randomly
generated column types determined by `column_codes`. The output
SFrame is deterministic based on `random_seed`.
`column_types` is a string with each character denoting one type
of column, with the output SFrame having one column for each
... | [
"Creates",
"a",
"random",
"SFrame",
"with",
"num_rows",
"rows",
"and",
"randomly",
"generated",
"column",
"types",
"determined",
"by",
"column_codes",
".",
"The",
"output",
"SFrame",
"is",
"deterministic",
"based",
"on",
"random_seed",
".",
"column_types",
"is",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/util/_sframe_generation.py#L13-L71 | train |
apple/turicreate | src/unity/python/turicreate/util/_sframe_generation.py | generate_random_regression_sframe | def generate_random_regression_sframe(num_rows, column_codes, random_seed = 0, target_noise_level = 0.25):
"""
Creates a random SFrame with `num_rows` rows and randomly
generated column types determined by `column_codes`. The output
SFrame is deterministic based on `random_seed`. In addition, a
ta... | python | def generate_random_regression_sframe(num_rows, column_codes, random_seed = 0, target_noise_level = 0.25):
"""
Creates a random SFrame with `num_rows` rows and randomly
generated column types determined by `column_codes`. The output
SFrame is deterministic based on `random_seed`. In addition, a
ta... | [
"def",
"generate_random_regression_sframe",
"(",
"num_rows",
",",
"column_codes",
",",
"random_seed",
"=",
"0",
",",
"target_noise_level",
"=",
"0.25",
")",
":",
"from",
".",
".",
"extensions",
"import",
"_generate_random_sframe",
"assert",
"isinstance",
"(",
"colum... | Creates a random SFrame with `num_rows` rows and randomly
generated column types determined by `column_codes`. The output
SFrame is deterministic based on `random_seed`. In addition, a
target column is generated with values dependent on the randomly
generated features in a given row.
`column_ty... | [
"Creates",
"a",
"random",
"SFrame",
"with",
"num_rows",
"rows",
"and",
"randomly",
"generated",
"column",
"types",
"determined",
"by",
"column_codes",
".",
"The",
"output",
"SFrame",
"is",
"deterministic",
"based",
"on",
"random_seed",
".",
"In",
"addition",
"a"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/util/_sframe_generation.py#L73-L157 | train |
apple/turicreate | src/unity/python/turicreate/util/_sframe_generation.py | generate_random_classification_sframe | def generate_random_classification_sframe(num_rows, column_codes, num_classes,
misclassification_spread = 0.25,
num_extra_class_bins = None,
random_seed = 0):
"""
Creates a random SFrame... | python | def generate_random_classification_sframe(num_rows, column_codes, num_classes,
misclassification_spread = 0.25,
num_extra_class_bins = None,
random_seed = 0):
"""
Creates a random SFrame... | [
"def",
"generate_random_classification_sframe",
"(",
"num_rows",
",",
"column_codes",
",",
"num_classes",
",",
"misclassification_spread",
"=",
"0.25",
",",
"num_extra_class_bins",
"=",
"None",
",",
"random_seed",
"=",
"0",
")",
":",
"from",
".",
".",
"extensions",
... | Creates a random SFrame with `num_rows` rows and randomly
generated column types determined by `column_codes`. The output
SFrame is deterministic based on `random_seed`. In addition, a
target column is generated with values dependent on the randomly
generated features in a given row.
`column_ty... | [
"Creates",
"a",
"random",
"SFrame",
"with",
"num_rows",
"rows",
"and",
"randomly",
"generated",
"column",
"types",
"determined",
"by",
"column_codes",
".",
"The",
"output",
"SFrame",
"is",
"deterministic",
"based",
"on",
"random_seed",
".",
"In",
"addition",
"a"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/util/_sframe_generation.py#L159-L255 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/_infer_shapes_nn_mlmodel.py | infer_shapes | def infer_shapes(nn_spec, input_spec, input_shape_dict = None):
"""
Input:
spec : mlmodel spec
input_shape_dict: dictionary of string --> tuple
string: input name
tuple: input shape as a 5 length tuple in order (Seq, Batch, C, H, W)
If inp... | python | def infer_shapes(nn_spec, input_spec, input_shape_dict = None):
"""
Input:
spec : mlmodel spec
input_shape_dict: dictionary of string --> tuple
string: input name
tuple: input shape as a 5 length tuple in order (Seq, Batch, C, H, W)
If inp... | [
"def",
"infer_shapes",
"(",
"nn_spec",
",",
"input_spec",
",",
"input_shape_dict",
"=",
"None",
")",
":",
"shape_dict",
"=",
"{",
"}",
"if",
"input_shape_dict",
":",
"for",
"key",
",",
"value",
"in",
"input_shape_dict",
".",
"items",
"(",
")",
":",
"assert... | Input:
spec : mlmodel spec
input_shape_dict: dictionary of string --> tuple
string: input name
tuple: input shape as a 5 length tuple in order (Seq, Batch, C, H, W)
If input_shape_dict is not provided, input shapes are inferred from the input descr... | [
"Input",
":"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/_infer_shapes_nn_mlmodel.py#L402-L466 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/libsvm/_libsvm_converter.py | convert | def convert(libsvm_model, feature_names, target, input_length, probability):
"""Convert a svm model to the protobuf spec.
This currently supports:
* C-SVC
* nu-SVC
* Epsilon-SVR
* nu-SVR
Parameters
----------
model_path: libsvm_model
Libsvm representation of the mode... | python | def convert(libsvm_model, feature_names, target, input_length, probability):
"""Convert a svm model to the protobuf spec.
This currently supports:
* C-SVC
* nu-SVC
* Epsilon-SVR
* nu-SVR
Parameters
----------
model_path: libsvm_model
Libsvm representation of the mode... | [
"def",
"convert",
"(",
"libsvm_model",
",",
"feature_names",
",",
"target",
",",
"input_length",
",",
"probability",
")",
":",
"if",
"not",
"(",
"HAS_LIBSVM",
")",
":",
"raise",
"RuntimeError",
"(",
"'libsvm not found. libsvm conversion API is disabled.'",
")",
"imp... | Convert a svm model to the protobuf spec.
This currently supports:
* C-SVC
* nu-SVC
* Epsilon-SVR
* nu-SVR
Parameters
----------
model_path: libsvm_model
Libsvm representation of the model.
feature_names : [str] | str
Names of each of the features.
targ... | [
"Convert",
"a",
"svm",
"model",
"to",
"the",
"protobuf",
"spec",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/libsvm/_libsvm_converter.py#L23-L176 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py | create | def create(dataset, session_id, target, features=None, prediction_window=100,
validation_set='auto', max_iterations=10, batch_size=32, verbose=True):
"""
Create an :class:`ActivityClassifier` model.
Parameters
----------
dataset : SFrame
Input data which consists of `sessions` of... | python | def create(dataset, session_id, target, features=None, prediction_window=100,
validation_set='auto', max_iterations=10, batch_size=32, verbose=True):
"""
Create an :class:`ActivityClassifier` model.
Parameters
----------
dataset : SFrame
Input data which consists of `sessions` of... | [
"def",
"create",
"(",
"dataset",
",",
"session_id",
",",
"target",
",",
"features",
"=",
"None",
",",
"prediction_window",
"=",
"100",
",",
"validation_set",
"=",
"'auto'",
",",
"max_iterations",
"=",
"10",
",",
"batch_size",
"=",
"32",
",",
"verbose",
"="... | Create an :class:`ActivityClassifier` model.
Parameters
----------
dataset : SFrame
Input data which consists of `sessions` of data where each session is
a sequence of data. The data must be in `stacked` format, grouped by
session. Within each session, the data is assumed to be sort... | [
"Create",
"an",
":",
"class",
":",
"ActivityClassifier",
"model",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py#L33-L286 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py | _encode_target | def _encode_target(data, target, mapping=None):
""" Encode targets to integers in [0, num_classes - 1] """
if mapping is None:
mapping = {t: i for i, t in enumerate(sorted(data[target].unique()))}
data[target] = data[target].apply(lambda t: mapping[t])
return data, mapping | python | def _encode_target(data, target, mapping=None):
""" Encode targets to integers in [0, num_classes - 1] """
if mapping is None:
mapping = {t: i for i, t in enumerate(sorted(data[target].unique()))}
data[target] = data[target].apply(lambda t: mapping[t])
return data, mapping | [
"def",
"_encode_target",
"(",
"data",
",",
"target",
",",
"mapping",
"=",
"None",
")",
":",
"if",
"mapping",
"is",
"None",
":",
"mapping",
"=",
"{",
"t",
":",
"i",
"for",
"i",
",",
"t",
"in",
"enumerate",
"(",
"sorted",
"(",
"data",
"[",
"target",
... | Encode targets to integers in [0, num_classes - 1] | [
"Encode",
"targets",
"to",
"integers",
"in",
"[",
"0",
"num_classes",
"-",
"1",
"]"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py#L289-L295 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py | ActivityClassifier.export_coreml | def export_coreml(self, filename):
"""
Export the model in Core ML format.
Parameters
----------
filename: str
A valid filename where the model can be saved.
Examples
--------
>>> model.export_coreml("MyModel.mlmodel")
"""
impor... | python | def export_coreml(self, filename):
"""
Export the model in Core ML format.
Parameters
----------
filename: str
A valid filename where the model can be saved.
Examples
--------
>>> model.export_coreml("MyModel.mlmodel")
"""
impor... | [
"def",
"export_coreml",
"(",
"self",
",",
"filename",
")",
":",
"import",
"coremltools",
"as",
"_cmt",
"import",
"mxnet",
"as",
"_mx",
"from",
".",
"_mx_model_architecture",
"import",
"_net_params",
"prob_name",
"=",
"self",
".",
"target",
"+",
"'Probability'",
... | Export the model in Core ML format.
Parameters
----------
filename: str
A valid filename where the model can be saved.
Examples
--------
>>> model.export_coreml("MyModel.mlmodel") | [
"Export",
"the",
"model",
"in",
"Core",
"ML",
"format",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py#L351-L485 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py | ActivityClassifier.predict | def predict(self, dataset, output_type='class', output_frequency='per_row'):
"""
Return predictions for ``dataset``, using the trained activity classifier.
Predictions can be generated as class labels, or as a probability
vector with probabilities for each class.
The activity cl... | python | def predict(self, dataset, output_type='class', output_frequency='per_row'):
"""
Return predictions for ``dataset``, using the trained activity classifier.
Predictions can be generated as class labels, or as a probability
vector with probabilities for each class.
The activity cl... | [
"def",
"predict",
"(",
"self",
",",
"dataset",
",",
"output_type",
"=",
"'class'",
",",
"output_frequency",
"=",
"'per_row'",
")",
":",
"_tkutl",
".",
"_raise_error_if_not_sframe",
"(",
"dataset",
",",
"'dataset'",
")",
"_tkutl",
".",
"_check_categorical_option_ty... | Return predictions for ``dataset``, using the trained activity classifier.
Predictions can be generated as class labels, or as a probability
vector with probabilities for each class.
The activity classifier generates a single prediction for each
``prediction_window`` rows in ``dataset``... | [
"Return",
"predictions",
"for",
"dataset",
"using",
"the",
"trained",
"activity",
"classifier",
".",
"Predictions",
"can",
"be",
"generated",
"as",
"class",
"labels",
"or",
"as",
"a",
"probability",
"vector",
"with",
"probabilities",
"for",
"each",
"class",
"."
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py#L487-L664 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py | ActivityClassifier.evaluate | def evaluate(self, dataset, metric='auto'):
"""
Evaluate the model by making predictions of target values and comparing
these to actual values.
Parameters
----------
dataset : SFrame
Dataset of new observations. Must include columns with the same
... | python | def evaluate(self, dataset, metric='auto'):
"""
Evaluate the model by making predictions of target values and comparing
these to actual values.
Parameters
----------
dataset : SFrame
Dataset of new observations. Must include columns with the same
... | [
"def",
"evaluate",
"(",
"self",
",",
"dataset",
",",
"metric",
"=",
"'auto'",
")",
":",
"avail_metrics",
"=",
"[",
"'accuracy'",
",",
"'auc'",
",",
"'precision'",
",",
"'recall'",
",",
"'f1_score'",
",",
"'log_loss'",
",",
"'confusion_matrix'",
",",
"'roc_cu... | Evaluate the model by making predictions of target values and comparing
these to actual values.
Parameters
----------
dataset : SFrame
Dataset of new observations. Must include columns with the same
names as the session_id, target and features used for model trai... | [
"Evaluate",
"the",
"model",
"by",
"making",
"predictions",
"of",
"target",
"values",
"and",
"comparing",
"these",
"to",
"actual",
"values",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py#L666-L743 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py | ActivityClassifier.classify | def classify(self, dataset, output_frequency='per_row'):
"""
Return a classification, for each ``prediction_window`` examples in the
``dataset``, using the trained activity classification model. The output
SFrame contains predictions as both class labels as well as probabilities
... | python | def classify(self, dataset, output_frequency='per_row'):
"""
Return a classification, for each ``prediction_window`` examples in the
``dataset``, using the trained activity classification model. The output
SFrame contains predictions as both class labels as well as probabilities
... | [
"def",
"classify",
"(",
"self",
",",
"dataset",
",",
"output_frequency",
"=",
"'per_row'",
")",
":",
"_tkutl",
".",
"_check_categorical_option_type",
"(",
"'output_frequency'",
",",
"output_frequency",
",",
"[",
"'per_window'",
",",
"'per_row'",
"]",
")",
"id_targ... | Return a classification, for each ``prediction_window`` examples in the
``dataset``, using the trained activity classification model. The output
SFrame contains predictions as both class labels as well as probabilities
that the predicted value is the associated label.
Parameters
... | [
"Return",
"a",
"classification",
"for",
"each",
"prediction_window",
"examples",
"in",
"the",
"dataset",
"using",
"the",
"trained",
"activity",
"classification",
"model",
".",
"The",
"output",
"SFrame",
"contains",
"predictions",
"as",
"both",
"class",
"labels",
"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py#L745-L795 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py | ActivityClassifier.predict_topk | def predict_topk(self, dataset, output_type='probability', k=3, output_frequency='per_row'):
"""
Return top-k predictions for the ``dataset``, using the trained model.
Predictions are returned as an SFrame with three columns: `prediction_id`,
`class`, and `probability`, or `rank`, depen... | python | def predict_topk(self, dataset, output_type='probability', k=3, output_frequency='per_row'):
"""
Return top-k predictions for the ``dataset``, using the trained model.
Predictions are returned as an SFrame with three columns: `prediction_id`,
`class`, and `probability`, or `rank`, depen... | [
"def",
"predict_topk",
"(",
"self",
",",
"dataset",
",",
"output_type",
"=",
"'probability'",
",",
"k",
"=",
"3",
",",
"output_frequency",
"=",
"'per_row'",
")",
":",
"_tkutl",
".",
"_check_categorical_option_type",
"(",
"'output_type'",
",",
"output_type",
",",... | Return top-k predictions for the ``dataset``, using the trained model.
Predictions are returned as an SFrame with three columns: `prediction_id`,
`class`, and `probability`, or `rank`, depending on the ``output_type``
parameter.
Parameters
----------
dataset : SFrame
... | [
"Return",
"top",
"-",
"k",
"predictions",
"for",
"the",
"dataset",
"using",
"the",
"trained",
"model",
".",
"Predictions",
"are",
"returned",
"as",
"an",
"SFrame",
"with",
"three",
"columns",
":",
"prediction_id",
"class",
"and",
"probability",
"or",
"rank",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/activity_classifier/_activity_classifier.py#L797-L891 | train |
apple/turicreate | deps/src/boost_1_68_0/libs/metaparse/tools/benchmark/char_stat.py | count_characters | def count_characters(root, out):
"""Count the occurrances of the different characters in the files"""
if os.path.isfile(root):
with open(root, 'rb') as in_f:
for line in in_f:
for char in line:
if char not in out:
out[char] = 0
... | python | def count_characters(root, out):
"""Count the occurrances of the different characters in the files"""
if os.path.isfile(root):
with open(root, 'rb') as in_f:
for line in in_f:
for char in line:
if char not in out:
out[char] = 0
... | [
"def",
"count_characters",
"(",
"root",
",",
"out",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"root",
")",
":",
"with",
"open",
"(",
"root",
",",
"'rb'",
")",
"as",
"in_f",
":",
"for",
"line",
"in",
"in_f",
":",
"for",
"char",
"in",
... | Count the occurrances of the different characters in the files | [
"Count",
"the",
"occurrances",
"of",
"the",
"different",
"characters",
"in",
"the",
"files"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/libs/metaparse/tools/benchmark/char_stat.py#L13-L24 | train |
apple/turicreate | deps/src/boost_1_68_0/libs/metaparse/tools/benchmark/char_stat.py | main | def main():
"""The main function of the script"""
desc = 'Generate character statistics from a source tree'
parser = argparse.ArgumentParser(description=desc)
parser.add_argument(
'--src',
dest='src',
required=True,
help='The root of the source tree'
)
parser.add_... | python | def main():
"""The main function of the script"""
desc = 'Generate character statistics from a source tree'
parser = argparse.ArgumentParser(description=desc)
parser.add_argument(
'--src',
dest='src',
required=True,
help='The root of the source tree'
)
parser.add_... | [
"def",
"main",
"(",
")",
":",
"desc",
"=",
"'Generate character statistics from a source tree'",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"desc",
")",
"parser",
".",
"add_argument",
"(",
"'--src'",
",",
"dest",
"=",
"'src'",
","... | The main function of the script | [
"The",
"main",
"function",
"of",
"the",
"script"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/libs/metaparse/tools/benchmark/char_stat.py#L34-L55 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/utils.py | save_spec | def save_spec(spec, filename):
"""
Save a protobuf model specification to file.
Parameters
----------
spec: Model_pb
Protobuf representation of the model
filename: str
File path where the spec gets saved.
Examples
--------
.. sourcecode:: python
>>> corem... | python | def save_spec(spec, filename):
"""
Save a protobuf model specification to file.
Parameters
----------
spec: Model_pb
Protobuf representation of the model
filename: str
File path where the spec gets saved.
Examples
--------
.. sourcecode:: python
>>> corem... | [
"def",
"save_spec",
"(",
"spec",
",",
"filename",
")",
":",
"name",
",",
"ext",
"=",
"_os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"if",
"not",
"ext",
":",
"filename",
"=",
"\"%s.mlmodel\"",
"%",
"filename",
"else",
":",
"if",
"ext",
"!=... | Save a protobuf model specification to file.
Parameters
----------
spec: Model_pb
Protobuf representation of the model
filename: str
File path where the spec gets saved.
Examples
--------
.. sourcecode:: python
>>> coremltools.utils.save_spec(spec, 'HousePricer.m... | [
"Save",
"a",
"protobuf",
"model",
"specification",
"to",
"file",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/utils.py#L28-L59 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/utils.py | load_spec | def load_spec(filename):
"""
Load a protobuf model specification from file
Parameters
----------
filename: str
Location on disk (a valid filepath) from which the file is loaded
as a protobuf spec.
Returns
-------
model_spec: Model_pb
Protobuf representation of t... | python | def load_spec(filename):
"""
Load a protobuf model specification from file
Parameters
----------
filename: str
Location on disk (a valid filepath) from which the file is loaded
as a protobuf spec.
Returns
-------
model_spec: Model_pb
Protobuf representation of t... | [
"def",
"load_spec",
"(",
"filename",
")",
":",
"from",
".",
".",
"proto",
"import",
"Model_pb2",
"spec",
"=",
"Model_pb2",
".",
"Model",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"contents",
"=",
"f",
".",
"read",
... | Load a protobuf model specification from file
Parameters
----------
filename: str
Location on disk (a valid filepath) from which the file is loaded
as a protobuf spec.
Returns
-------
model_spec: Model_pb
Protobuf representation of the model
Examples
--------
... | [
"Load",
"a",
"protobuf",
"model",
"specification",
"from",
"file"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/utils.py#L62-L93 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/utils.py | _get_nn_layers | def _get_nn_layers(spec):
"""
Returns a list of neural network layers if the model contains any.
Parameters
----------
spec: Model_pb
A model protobuf specification.
Returns
-------
[NN layer]
list of all layers (including layers from elements of a pipeline
"""
... | python | def _get_nn_layers(spec):
"""
Returns a list of neural network layers if the model contains any.
Parameters
----------
spec: Model_pb
A model protobuf specification.
Returns
-------
[NN layer]
list of all layers (including layers from elements of a pipeline
"""
... | [
"def",
"_get_nn_layers",
"(",
"spec",
")",
":",
"layers",
"=",
"[",
"]",
"if",
"spec",
".",
"WhichOneof",
"(",
"'Type'",
")",
"==",
"'pipeline'",
":",
"layers",
"=",
"[",
"]",
"for",
"model_spec",
"in",
"spec",
".",
"pipeline",
".",
"models",
":",
"i... | Returns a list of neural network layers if the model contains any.
Parameters
----------
spec: Model_pb
A model protobuf specification.
Returns
-------
[NN layer]
list of all layers (including layers from elements of a pipeline | [
"Returns",
"a",
"list",
"of",
"neural",
"network",
"layers",
"if",
"the",
"model",
"contains",
"any",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/utils.py#L96-L137 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/utils.py | evaluate_regressor | def evaluate_regressor(model, data, target="target", verbose=False):
"""
Evaluate a CoreML regression model and compare against predictions
from the original framework (for testing correctness of conversion)
Parameters
----------
filename: [str | MLModel]
File path from which to load th... | python | def evaluate_regressor(model, data, target="target", verbose=False):
"""
Evaluate a CoreML regression model and compare against predictions
from the original framework (for testing correctness of conversion)
Parameters
----------
filename: [str | MLModel]
File path from which to load th... | [
"def",
"evaluate_regressor",
"(",
"model",
",",
"data",
",",
"target",
"=",
"\"target\"",
",",
"verbose",
"=",
"False",
")",
":",
"model",
"=",
"_get_model",
"(",
"model",
")",
"if",
"verbose",
":",
"print",
"(",
"\"\"",
")",
"print",
"(",
"\"Other Frame... | Evaluate a CoreML regression model and compare against predictions
from the original framework (for testing correctness of conversion)
Parameters
----------
filename: [str | MLModel]
File path from which to load the MLModel from (OR) a loaded version of
MLModel.
data: [str | Datafr... | [
"Evaluate",
"a",
"CoreML",
"regression",
"model",
"and",
"compare",
"against",
"predictions",
"from",
"the",
"original",
"framework",
"(",
"for",
"testing",
"correctness",
"of",
"conversion",
")"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/utils.py#L386-L448 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/utils.py | evaluate_classifier | def evaluate_classifier(model, data, target='target', verbose=False):
"""
Evaluate a CoreML classifier model and compare against predictions
from the original framework (for testing correctness of conversion). Use
this evaluation for models that don't deal with probabilities.
Parameters
-------... | python | def evaluate_classifier(model, data, target='target', verbose=False):
"""
Evaluate a CoreML classifier model and compare against predictions
from the original framework (for testing correctness of conversion). Use
this evaluation for models that don't deal with probabilities.
Parameters
-------... | [
"def",
"evaluate_classifier",
"(",
"model",
",",
"data",
",",
"target",
"=",
"'target'",
",",
"verbose",
"=",
"False",
")",
":",
"model",
"=",
"_get_model",
"(",
"model",
")",
"if",
"verbose",
":",
"print",
"(",
"\"\"",
")",
"print",
"(",
"\"Other Framew... | Evaluate a CoreML classifier model and compare against predictions
from the original framework (for testing correctness of conversion). Use
this evaluation for models that don't deal with probabilities.
Parameters
----------
filename: [str | MLModel]
File from where to load the model from (... | [
"Evaluate",
"a",
"CoreML",
"classifier",
"model",
"and",
"compare",
"against",
"predictions",
"from",
"the",
"original",
"framework",
"(",
"for",
"testing",
"correctness",
"of",
"conversion",
")",
".",
"Use",
"this",
"evaluation",
"for",
"models",
"that",
"don",... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/utils.py#L451-L509 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/utils.py | evaluate_classifier_with_probabilities | def evaluate_classifier_with_probabilities(model, data,
probabilities='probabilities',
verbose = False):
"""
Evaluate a classifier specification for testing.
Parameters
----------
filename: [str | Model]
F... | python | def evaluate_classifier_with_probabilities(model, data,
probabilities='probabilities',
verbose = False):
"""
Evaluate a classifier specification for testing.
Parameters
----------
filename: [str | Model]
F... | [
"def",
"evaluate_classifier_with_probabilities",
"(",
"model",
",",
"data",
",",
"probabilities",
"=",
"'probabilities'",
",",
"verbose",
"=",
"False",
")",
":",
"model",
"=",
"_get_model",
"(",
"model",
")",
"if",
"verbose",
":",
"print",
"(",
"\"\"",
")",
... | Evaluate a classifier specification for testing.
Parameters
----------
filename: [str | Model]
File from where to load the model from (OR) a loaded
version of the MLModel.
data: [str | Dataframe]
Test data on which to evaluate the models (dataframe,
or path to a csv fil... | [
"Evaluate",
"a",
"classifier",
"specification",
"for",
"testing",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/utils.py#L512-L571 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/utils.py | rename_feature | def rename_feature(spec, current_name, new_name, rename_inputs=True,
rename_outputs=True):
"""
Rename a feature in the specification.
Parameters
----------
spec: Model_pb
The specification containing the feature to rename.
current_name: str
Current name of th... | python | def rename_feature(spec, current_name, new_name, rename_inputs=True,
rename_outputs=True):
"""
Rename a feature in the specification.
Parameters
----------
spec: Model_pb
The specification containing the feature to rename.
current_name: str
Current name of th... | [
"def",
"rename_feature",
"(",
"spec",
",",
"current_name",
",",
"new_name",
",",
"rename_inputs",
"=",
"True",
",",
"rename_outputs",
"=",
"True",
")",
":",
"from",
"coremltools",
".",
"models",
"import",
"MLModel",
"if",
"not",
"rename_inputs",
"and",
"not",
... | Rename a feature in the specification.
Parameters
----------
spec: Model_pb
The specification containing the feature to rename.
current_name: str
Current name of the feature. If this feature doesn't exist, the rename
is a no-op.
new_name: str
New name of the featur... | [
"Rename",
"a",
"feature",
"in",
"the",
"specification",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/utils.py#L574-L674 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.