fiftyone.brain.similarity¶
Similarity interface.
Classes:
|
Similarity configuration. |
|
Class storing the results of |
-
class
fiftyone.brain.similarity.
SimilarityResults
(samples, config, embeddings)¶ Bases:
fiftyone.core.brain.BrainResults
Class storing the results of
fiftyone.brain.compute_similarity()
.- Parameters
samples – the
fiftyone.core.collections.SampleCollection
usedconfig – the
SimilarityConfig
usedembeddings – a
num_embeddings x num_dims
array of embeddings
Methods:
Returns the list of class attributes that will be serialized by
serialize()
.Clears the view set by
use_view()
, if any.copy
()Returns a deep copy of the object.
custom_attributes
([dynamic, private])Returns a customizable list of class attributes.
duplicates_view
([type_field, id_field, …])Returns a view that contains only the duplicate examples and their corresponding nearest non-duplicate examples generated by the last call to
find_duplicates()
.find_duplicates
([thresh, fraction])Queries the index to find near-duplicate examples based on the provided parameters.
find_unique
(count)Queries the index to select a subset of examples of the specified size that are maximally unique with respect to each other.
from_dict
(d, samples, config)Builds a
RunResults
from a JSON dict representation of it.from_json
(path, *args, **kwargs)Constructs a Serializable object from a JSON file.
from_str
(s, *args, **kwargs)Constructs a Serializable object from a JSON string.
Returns the fully-qualified class name string of this object.
plot_distances
([bins, log, backend])Plots a histogram of the distance between each example and its nearest neighbor.
serialize
([reflective])Serializes the object into a dictionary.
sort_by_similarity
(query_ids[, k, reverse, …])Returns a view that sorts the samples/labels in
view()
by visual similarity to the specified query.to_str
([pretty_print])Returns a string representation of this object.
Returns a view that contains only the unique examples generated by the last call to
find_duplicates()
orfind_unique()
.use_view
(sample_collection[, allow_missing])Restricts the index to the provided view, which must be a subset of the full index’s collection.
visualize_duplicates
([visualization, backend])Generates an interactive scatterplot of the results generated by the last call to
find_duplicates()
.visualize_unique
([visualization, backend])Generates an interactive scatterplot of the results generated by the last call to
find_unique()
.write_json
(path[, pretty_print])Serializes the object and writes it to disk.
Attributes:
The fully-qualified name of this
RunResults
class.The
SimilarityConfig
for the results.A list of duplicate IDs from the last call to
find_duplicates()
orfind_unique()
.The number of data points in the index.
The total number of data points in
view()
that are missing from this index.A dictionary mapping IDs to lists of
(dup_id, dist)
tuples from the last call tofind_duplicates()
.The threshold used by the last call to
find_duplicates()
orfind_unique()
.The total number of data points in the index.
A list of unique IDs from the last call to
find_duplicates()
orfind_unique()
.The
fiftyone.core.collections.SampleCollection
against which results are currently being generated.-
property
config
¶ The
SimilarityConfig
for the results.
-
property
index_size
¶ The number of data points in the index.
If
use_view()
has been called to restrict the index, this property will reflect the size of the active index.
-
property
total_index_size
¶ The total number of data points in the index.
If
use_view()
has been called to restrict the index, this value may be larger than the currentindex_size()
.
-
property
missing_size
¶ The total number of data points in
view()
that are missing from this index.This property is only applicable when
use_view()
has been called, and it will beNone
if no data points are missing.
-
property
view
¶ The
fiftyone.core.collections.SampleCollection
against which results are currently being generated.If
use_view()
has been called, this view may be a subset of the collection on which the full index was generated.
-
property
thresh
¶ The threshold used by the last call to
find_duplicates()
orfind_unique()
.
-
property
unique_ids
¶ A list of unique IDs from the last call to
find_duplicates()
orfind_unique()
.
-
property
duplicate_ids
¶ A list of duplicate IDs from the last call to
find_duplicates()
orfind_unique()
.
-
property
neighbors_map
¶ A dictionary mapping IDs to lists of
(dup_id, dist)
tuples from the last call tofind_duplicates()
.
-
use_view
(sample_collection, allow_missing=False)¶ Restricts the index to the provided view, which must be a subset of the full index’s collection.
Subsequent calls to methods on this instance will only contain results from the specified view rather than the full index.
Use
clear_view()
to reset to the full index. Or, equivalently, use the context manager interface as demonstrated below to automatically reset the view when the context exits.Example usage:
import fiftyone as fo import fiftyone.brain as fob import fiftyone.zoo as foz dataset = foz.load_zoo_dataset("quickstart") results = fob.compute_similarity(dataset) print(results.index_size) # 200 view = dataset.take(50) with results.use_view(view): print(results.index_size) # 50 results.find_unique(10) print(results.unique_ids) plot = results.visualize_unique() plot.show()
- Parameters
sample_collection – a
fiftyone.core.collections.SampleCollection
defining a subset of this index to useallow_missing (False) – whether to allow the provided collection to contain data points that this index does not contain (True) or whether to raise an error in this case (False)
- Returns
self
-
clear_view
()¶ Clears the view set by
use_view()
, if any.Subsequent operations will be performed on the full index.
-
plot_distances
(bins=100, log=False, backend='plotly', **kwargs)¶ Plots a histogram of the distance between each example and its nearest neighbor.
If :meth:`find_duplicates or
find_unique()
has been executed, the threshold used is also indicated on the plot.- Parameters
bins (100) – the number of bins to use
log (False) – whether to use a log scale y-axis
backend ("plotly") – the plotting backend to use. Supported values are
("plotly", "matplotlib")
**kwargs – keyword arguments for the backend plotting method
- Returns
a
fiftyone.core.plots.plotly.PlotlyNotebookPlot
, if you are working in a notebook context and the plotly backend is useda plotly or matplotlib figure, otherwise
- Return type
one of the following
-
sort_by_similarity
(query_ids, k=None, reverse=False, aggregation='mean', dist_field=None, _mongo=False)¶ Returns a view that sorts the samples/labels in
view()
by visual similarity to the specified query.The query IDs can be any IDs in the full index of this instance, even if the current
view()
contains a subset of the full index.- Parameters
query_ids – an ID or iterable of query IDs
k (None) – the number of matches to return. By default, all samples/labels are included
reverse (False) – whether to sort by least similarity
aggregation ("mean") – the aggregation method to use to compute composite similarities. Only applicable when
query_ids
contains multiple IDs. Supported values are("mean", "min", "max")
dist_field (None) – the name of a float field in which to store the distance of each example to the specified query. The field is created if necessary
- Returns
-
find_duplicates
(thresh=None, fraction=None)¶ Queries the index to find near-duplicate examples based on the provided parameters.
Calling this method populates the
unique_ids()
,duplicate_ids()
,neighbors_map
, andthresh
properties of this object with the results of the query.Use
duplicates_view()
andvisualize_duplicates()
to analyze the results generated by this method.- Parameters
thresh (None) – a distance threshold to use to determine duplicates. If specified, the non-duplicate set will be the (approximately) largest set such that all pairwise distances between non-duplicate examples are greater than this threshold
fraction (None) – a desired fraction of images/patches to tag as duplicates, in
[0, 1]
. In this casethresh
is automatically tuned to achieve the desired fraction of duplicates
-
find_unique
(count)¶ Queries the index to select a subset of examples of the specified size that are maximally unique with respect to each other.
Calling this method populates the
unique_ids()
,duplicate_ids()
, andthresh
properties of this object with the results of the query.Use
unique_view()
andvisualize_unique()
to analyze the results generated by this method.- Parameters
count – the desired number of unique examples
-
duplicates_view
(type_field=None, id_field=None, dist_field=None, sort_by='distance', reverse=False)¶ Returns a view that contains only the duplicate examples and their corresponding nearest non-duplicate examples generated by the last call to
find_duplicates()
.If you are analyzing patches, the returned view will be a
fiftyone.core.patches.PatchesView
.The examples are organized so that each non-duplicate is immediately followed by all duplicate(s) that are nearest to it.
- Parameters
type_field (None) – the name of a string field in which to store
"nearest"
and"duplicate"
labels. The field is created if necessaryid_field (None) – the name of a string field in which to store the ID of the nearest non-duplicate for each example in the view. The field is created if necessary
dist_field (None) – the name of a float field in which to store the distance of each example to its nearest non-duplicate example. The field is created if necessary
sort_by ("distance") –
specifies how to sort the groups of duplicate examples. The supported values are:
"distance"
: sort the groups by the distance between the non-duplicate and its (nearest, if multiple) duplicate"count"
: sort the groups by the number of duplicate examples
reverse (False) – whether to sort in descending order
- Returns
-
unique_view
()¶ Returns a view that contains only the unique examples generated by the last call to
find_duplicates()
orfind_unique()
.If you are analyzing patches, the returned view will be a
fiftyone.core.patches.PatchesView
.- Returns
-
visualize_duplicates
(visualization=None, backend='plotly', **kwargs)¶ Generates an interactive scatterplot of the results generated by the last call to
find_duplicates()
.If provided, the
visualization
argument can be any visualization computed on the same dataset (or subset of it) as long as it contains every sample/object in the view whose results you are visualizing. If novisualization
argument is provided and the embeddings have more than 3 dimensions, a 2D representation of the embeddings is computed viafiftyone.brain.compute_visualization()
.The points are colored based on the following partition:
“duplicate”: duplicate example
“nearest”: nearest neighbor of a duplicate example
“unique”: the remaining unique examples
Edges are also drawn between each duplicate and its nearest non-duplicate neighbor.
You can attach plots generated by this method to an App session via its
fiftyone.core.session.Session.plots
attribute, which will automatically sync the session’s view with the currently selected points in the plot.- Parameters
visualization (None) – a
fiftyone.brain.visualization.VisualizationResults
instance to use to visualize the resultsbackend ("plotly") – the plotting backend to use. Supported values are
("plotly", "matplotlib")
**kwargs –
keyword arguments for the backend plotting method:
”plotly” backend:
fiftyone.core.plots.plotly.scatterplot()
”matplotlib” backend:
fiftyone.core.plots.matplotlib.scatterplot()
- Returns
-
visualize_unique
(visualization=None, backend='plotly', **kwargs)¶ Generates an interactive scatterplot of the results generated by the last call to
find_unique()
.If provided, the
visualization
argument can be any visualization computed on the same dataset (or subset of it) as long as it contains every sample/object in the view whose results you are visualizing. If novisualization
argument is provided and the embeddings have more than 3 dimensions, a 2D representation of the embeddings is computed viafiftyone.brain.compute_visualization()
.The points are colored based on the following partition:
“unique”: the unique examples
“other”: the other examples
You can attach plots generated by this method to an App session via its
fiftyone.core.session.Session.plots
attribute, which will automatically sync the session’s view with the currently selected points in the plot.- Parameters
visualization (None) – a
fiftyone.brain.visualization.VisualizationResults
instance to use to visualize the resultsbackend ("plotly") – the plotting backend to use. Supported values are
("plotly", "matplotlib")
**kwargs –
keyword arguments for the backend plotting method:
”plotly” backend:
fiftyone.core.plots.plotly.scatterplot()
”matplotlib” backend:
fiftyone.core.plots.matplotlib.scatterplot()
- Returns
-
attributes
()¶ Returns the list of class attributes that will be serialized by
serialize()
.- Returns
a list of attributes
-
property
cls
¶ The fully-qualified name of this
RunResults
class.
-
copy
()¶ Returns a deep copy of the object.
- Returns
a Serializable instance
-
custom_attributes
(dynamic=False, private=False)¶ Returns a customizable list of class attributes.
By default, all attributes in vars(self) are returned, minus private attributes (those starting with “_”).
- Parameters
dynamic – whether to include dynamic properties, e.g., those defined by getter/setter methods or the @property decorator. By default, this is False
private – whether to include private properties, i.e., those starting with “_”. By default, this is False
- Returns
a list of class attributes
-
classmethod
from_dict
(d, samples, config)¶ Builds a
RunResults
from a JSON dict representation of it.- Parameters
d – a JSON dict
samples – the
fiftyone.core.collections.SampleCollection
for the runconfig – the
RunConfig
for the run
- Returns
a
RunResults
-
classmethod
from_json
(path, *args, **kwargs)¶ Constructs a Serializable object from a JSON file.
Subclasses may override this method, but, by default, this method simply reads the JSON and calls from_dict(), which subclasses must implement.
- Parameters
path – the path to the JSON file on disk
*args – optional positional arguments for self.from_dict()
**kwargs – optional keyword arguments for self.from_dict()
- Returns
an instance of the Serializable class
-
classmethod
from_str
(s, *args, **kwargs)¶ Constructs a Serializable object from a JSON string.
Subclasses may override this method, but, by default, this method simply parses the string and calls from_dict(), which subclasses must implement.
- Parameters
s – a JSON string representation of a Serializable object
*args – optional positional arguments for self.from_dict()
**kwargs – optional keyword arguments for self.from_dict()
- Returns
an instance of the Serializable class
-
classmethod
get_class_name
()¶ Returns the fully-qualified class name string of this object.
-
serialize
(reflective=False)¶ Serializes the object into a dictionary.
Serialization is applied recursively to all attributes in the object, including element-wise serialization of lists and dictionary values.
- Parameters
reflective – whether to include reflective attributes when serializing the object. By default, this is False
- Returns
a JSON dictionary representation of the object
-
to_str
(pretty_print=True, **kwargs)¶ Returns a string representation of this object.
- Parameters
pretty_print – whether to render the JSON in human readable format with newlines and indentations. By default, this is True
**kwargs – optional keyword arguments for self.serialize()
- Returns
a string representation of the object
-
write_json
(path, pretty_print=False, **kwargs)¶ Serializes the object and writes it to disk.
- Parameters
path – the output path
pretty_print – whether to render the JSON in human readable format with newlines and indentations. By default, this is False
**kwargs – optional keyword arguments for self.serialize()
-
class
fiftyone.brain.similarity.
SimilarityConfig
(embeddings_field=None, model=None, patches_field=None, metric=None, **kwargs)¶ Bases:
fiftyone.core.brain.BrainMethodConfig
Similarity configuration.
- Parameters
embeddings_field (None) – the sample field containing the embeddings, if one was provided
model (None) – the
fiftyone.core.models.Model
or class name of the model that was used to compute embeddings, if one was providedpatches_field (None) – the sample field defining the patches being analyzed, if any
metric (None) – the embedding distance metric used
Methods:
Returns the list of class attributes that will be serialized by
serialize()
.build
()Builds the
Run
instance associated with this config.builder
()Returns a ConfigBuilder instance for this class.
copy
()Returns a deep copy of the object.
custom_attributes
([dynamic, private])Returns a customizable list of class attributes.
default
()Returns the default config instance.
from_dict
(d)Constructs a
RunConfig
from a serialized JSON dict representation of it.from_json
(path, *args, **kwargs)Constructs a Serializable object from a JSON file.
from_kwargs
(**kwargs)Constructs a Config object from keyword arguments.
from_str
(s, *args, **kwargs)Constructs a Serializable object from a JSON string.
Returns the fully-qualified class name string of this object.
Loads the default config instance from file.
parse_array
(d, key[, default])Parses a raw array attribute.
parse_bool
(d, key[, default])Parses a boolean value.
parse_categorical
(d, key, choices[, default])Parses a categorical JSON field, which must take a value from among the given choices.
parse_dict
(d, key[, default])Parses a dictionary attribute.
parse_int
(d, key[, default])Parses an integer attribute.
parse_mutually_exclusive_fields
(fields)Parses a mutually exclusive dictionary of pre-parsed fields, which must contain exactly one field with a truthy value.
parse_number
(d, key[, default])Parses a number attribute.
parse_object
(d, key, cls[, default])Parses an object attribute.
parse_object_array
(d, key, cls[, default])Parses an array of objects.
parse_object_dict
(d, key, cls[, default])Parses a dictionary whose values are objects.
parse_path
(d, key[, default])Parses a path attribute.
parse_raw
(d, key[, default])Parses a raw (arbitrary) JSON field.
parse_string
(d, key[, default])Parses a string attribute.
serialize
([reflective])Serializes the object into a dictionary.
to_str
([pretty_print])Returns a string representation of this object.
validate_all_or_nothing_fields
(fields)Validates a dictionary of pre-parsed fields checking that either all or none of the fields have a truthy value.
write_json
(path[, pretty_print])Serializes the object and writes it to disk.
Attributes:
The fully-qualified name of this
RunConfig
class.The name of the method.
The
Run
class associated with this config.-
property
method
¶ The name of the method.
-
property
run_cls
¶ The
Run
class associated with this config.
-
attributes
()¶ Returns the list of class attributes that will be serialized by
serialize()
.- Returns
a list of attributes
-
build
()¶ Builds the
Run
instance associated with this config.- Returns
a
Run
instance
-
classmethod
builder
()¶ Returns a ConfigBuilder instance for this class.
-
property
cls
¶ The fully-qualified name of this
RunConfig
class.
-
copy
()¶ Returns a deep copy of the object.
- Returns
a Serializable instance
-
custom_attributes
(dynamic=False, private=False)¶ Returns a customizable list of class attributes.
By default, all attributes in vars(self) are returned, minus private attributes (those starting with “_”).
- Parameters
dynamic – whether to include dynamic properties, e.g., those defined by getter/setter methods or the @property decorator. By default, this is False
private – whether to include private properties, i.e., those starting with “_”. By default, this is False
- Returns
a list of class attributes
-
classmethod
default
()¶ Returns the default config instance.
By default, this method instantiates the class from an empty dictionary, which will only succeed if all attributes are optional. Otherwise, subclasses should override this method to provide the desired default configuration.
-
classmethod
from_dict
(d)¶ Constructs a
RunConfig
from a serialized JSON dict representation of it.- Parameters
d – a JSON dict
- Returns
a
RunConfig
-
classmethod
from_json
(path, *args, **kwargs)¶ Constructs a Serializable object from a JSON file.
Subclasses may override this method, but, by default, this method simply reads the JSON and calls from_dict(), which subclasses must implement.
- Parameters
path – the path to the JSON file on disk
*args – optional positional arguments for self.from_dict()
**kwargs – optional keyword arguments for self.from_dict()
- Returns
an instance of the Serializable class
-
classmethod
from_kwargs
(**kwargs)¶ Constructs a Config object from keyword arguments.
- Parameters
**kwargs – keyword arguments that define the fields expected by cls
- Returns
an instance of cls
-
classmethod
from_str
(s, *args, **kwargs)¶ Constructs a Serializable object from a JSON string.
Subclasses may override this method, but, by default, this method simply parses the string and calls from_dict(), which subclasses must implement.
- Parameters
s – a JSON string representation of a Serializable object
*args – optional positional arguments for self.from_dict()
**kwargs – optional keyword arguments for self.from_dict()
- Returns
an instance of the Serializable class
-
classmethod
get_class_name
()¶ Returns the fully-qualified class name string of this object.
-
classmethod
load_default
()¶ Loads the default config instance from file.
Subclasses must implement this method if they intend to support default instances.
-
static
parse_array
(d, key, default=<eta.core.config.NoDefault object>)¶ Parses a raw array attribute.
- Parameters
d – a JSON dictionary
key – the key to parse
default – a default list to return if key is not present
- Returns
a list of raw (untouched) values
- Raises
ConfigError – if the field value was the wrong type or no default value was provided and the key was not found in the dictionary
-
static
parse_bool
(d, key, default=<eta.core.config.NoDefault object>)¶ Parses a boolean value.
- Parameters
d – a JSON dictionary
key – the key to parse
default – a default bool to return if key is not present
- Returns
True/False
- Raises
ConfigError – if the field value was the wrong type or no default value was provided and the key was not found in the dictionary
-
static
parse_categorical
(d, key, choices, default=<eta.core.config.NoDefault object>)¶ Parses a categorical JSON field, which must take a value from among the given choices.
- Parameters
d – a JSON dictionary
key – the key to parse
choices – either an iterable of possible values or an enum-like class whose attributes define the possible values
default – a default value to return if key is not present
- Returns
the raw (untouched) value of the given field, which is equal to a value from choices
- Raises
ConfigError – if the key was present in the dictionary but its value was not an allowed choice, or if no default value was provided and the key was not found in the dictionary
-
static
parse_dict
(d, key, default=<eta.core.config.NoDefault object>)¶ Parses a dictionary attribute.
- Parameters
d – a JSON dictionary
key – the key to parse
default – a default dict to return if key is not present
- Returns
a dictionary
- Raises
ConfigError – if the field value was the wrong type or no default value was provided and the key was not found in the dictionary
-
static
parse_int
(d, key, default=<eta.core.config.NoDefault object>)¶ Parses an integer attribute.
- Parameters
d – a JSON dictionary
key – the key to parse
default – a default integer value to return if key is not present
- Returns
an int
- Raises
ConfigError – if the field value was the wrong type or no default value was provided and the key was not found in the dictionary
-
static
parse_mutually_exclusive_fields
(fields)¶ Parses a mutually exclusive dictionary of pre-parsed fields, which must contain exactly one field with a truthy value.
- Parameters
fields – a dictionary of pre-parsed fields
- Returns
the (field, value) that was set
- Raises
ConfigError – if zero or more than one truthy value was found
-
static
parse_number
(d, key, default=<eta.core.config.NoDefault object>)¶ Parses a number attribute.
- Parameters
d – a JSON dictionary
key – the key to parse
default – a default numeric value to return if key is not present
- Returns
a number (e.g. int, float)
- Raises
ConfigError – if the field value was the wrong type or no default value was provided and the key was not found in the dictionary
-
static
parse_object
(d, key, cls, default=<eta.core.config.NoDefault object>)¶ Parses an object attribute.
The value of d[key] can be either an instance of cls or a serialized dict from an instance of cls.
- Parameters
d – a JSON dictionary
key – the key to parse
cls – the class of d[key]
default – a default cls instance to return if key is not present
- Returns
an instance of cls
- Raises
ConfigError – if the field value was the wrong type or no default value was provided and the key was not found in the dictionary
-
static
parse_object_array
(d, key, cls, default=<eta.core.config.NoDefault object>)¶ Parses an array of objects.
The values in d[key] can be either instances of cls or serialized dicts from instances of cls.
- Parameters
d – a JSON dictionary
key – the key to parse
cls – the class of the elements of list d[key]
default – the default list to return if key is not present
- Returns
a list of cls instances
- Raises
ConfigError – if the field value was the wrong type or no default value was provided and the key was not found in the dictionary
-
static
parse_object_dict
(d, key, cls, default=<eta.core.config.NoDefault object>)¶ Parses a dictionary whose values are objects.
The values in d[key] can be either instances of cls or serialized dicts from instances of cls.
- Parameters
d – a JSON dictionary
key – the key to parse
cls – the class of the values of dictionary d[key]
default – the default dict of cls instances to return if key is not present
- Returns
a dictionary whose values are cls instances
- Raises
ConfigError – if the field value was the wrong type or no default value was provided and the key was not found in the dictionary
-
static
parse_path
(d, key, default=<eta.core.config.NoDefault object>)¶ Parses a path attribute.
The path is converted to an absolute path if necessary via
os.path.abspath(os.path.expanduser(value))
.- Parameters
d – a JSON dictionary
key – the key to parse
default – a default string to return if key is not present
- Returns
a path string
- Raises
ConfigError – if the field value was the wrong type or no default value was provided and the key was not found in the dictionary
-
static
parse_raw
(d, key, default=<eta.core.config.NoDefault object>)¶ Parses a raw (arbitrary) JSON field.
- Parameters
d – a JSON dictionary
key – the key to parse
default – a default value to return if key is not present
- Returns
the raw (untouched) value of the given field
- Raises
ConfigError – if no default value was provided and the key was not found in the dictionary
-
static
parse_string
(d, key, default=<eta.core.config.NoDefault object>)¶ Parses a string attribute.
- Parameters
d – a JSON dictionary
key – the key to parse
default – a default string to return if key is not present
- Returns
a string
- Raises
ConfigError – if the field value was the wrong type or no default value was provided and the key was not found in the dictionary
-
serialize
(reflective=False)¶ Serializes the object into a dictionary.
Serialization is applied recursively to all attributes in the object, including element-wise serialization of lists and dictionary values.
- Parameters
reflective – whether to include reflective attributes when serializing the object. By default, this is False
- Returns
a JSON dictionary representation of the object
-
to_str
(pretty_print=True, **kwargs)¶ Returns a string representation of this object.
- Parameters
pretty_print – whether to render the JSON in human readable format with newlines and indentations. By default, this is True
**kwargs – optional keyword arguments for self.serialize()
- Returns
a string representation of the object
-
static
validate_all_or_nothing_fields
(fields)¶ Validates a dictionary of pre-parsed fields checking that either all or none of the fields have a truthy value.
- Parameters
fields – a dictionary of pre-parsed fields
- Raises
ConfigError – if some values are truth and some are not
-
write_json
(path, pretty_print=False, **kwargs)¶ Serializes the object and writes it to disk.
- Parameters
path – the output path
pretty_print – whether to render the JSON in human readable format with newlines and indentations. By default, this is False
**kwargs – optional keyword arguments for self.serialize()