experimenters Package¶
experimenters
Package¶
aggregator
Module¶
Aggregating experimenters.
-
class
vis.analyzers.experimenters.aggregator.
ColumnAggregator
(index, settings=None)[source]¶ Bases:
vis.analyzers.experimenter.Experimenter
(Arguments for the constructor are listed below).
Experiment that aggregates data from columns of a
DataFrame
, or a list ofDataFrame
objects, by summing each row. Values from columns named'all'
will not be included in the aggregated results. You may provide a'column'
setting to guide the experimenter to include only certain results.Example 1
Inputting single
DataFrame
like this:Index piece_1 piece_2 M3 12 24 m3 NaN 36 P5 3 9 Yields this
DataFrame
:Index ‘aggregator.ColumnAggregator’ M3 36 m3 36 P5 12 Example 2
Inputting two
DataFrame
objects is similar.Index piece_1 M3 12 P5 3 Index piece_2 M3 24 m3 36 P5 9 The result is the same
DataFrame
:Index ‘aggregator.ColumnAggregator’ M3 36 m3 36 P5 12 Example 3
You may also give a
DataFrame
(or a list ofDataFrame
objects) that have apandas.MultiIndex
as produced by subclasses ofIndexer
. In this case, use the'column'
setting to indicate which indexer’s results you wish to aggregate.Index ‘frequency.FrequencyExperimenter’ ‘feelings.FeelingsExperimenter’ ‘0,1’ ‘1,2’ ‘Christopher’ ‘Alex’ M3 12 24 ‘delight’ ‘exuberance’ m3 NaN 36 ‘sheer joy’ ‘nonchalance’ P5 3 9 ‘emptiness’ ‘serenity’ If
'column'
is'frequency.FrequencyExperimenter'
, yet again you will have thisDataFrame
:Index ‘aggregator.ColumnAggregator’ M3 36 m3 36 P5 12 -
default_settings
= {'column': None}¶
-
possible_settings
= ['column']¶ Parameters: 'column' (str) – The column name to use for aggregation. The default is None
, which aggregates across all columns. If you set this to'all'
, it will override the default behaviour of not including columns called'all'
.
-
run
()[source]¶ Run the
ColumnAggregator
experiment.Returns: A Series
with an index that is the combination of all indices of the provided pandas objects, and the value is the sum of all values in the pandas objects.Return type: pandas.Series
*Example:*
import music21 from vis.analyzers.indexers import noterest from vis.analyzers.experimenters import aggregator, frequency
score = music21.converter.parse(‘example.xml’) notes = noterest.NoteRestIndexer(score).run()
freqs = frequency.FrequencyExperimenter(notes).run() agg = aggregator.ColumnAggregator(freqs).run() print(agg)
-
barchart
Module¶
Aggregating experimenters.
-
class
vis.analyzers.experimenters.aggregator.
ColumnAggregator
(index, settings=None)[source] Bases:
vis.analyzers.experimenter.Experimenter
(Arguments for the constructor are listed below).
Experiment that aggregates data from columns of a
DataFrame
, or a list ofDataFrame
objects, by summing each row. Values from columns named'all'
will not be included in the aggregated results. You may provide a'column'
setting to guide the experimenter to include only certain results.Example 1
Inputting single
DataFrame
like this:Index piece_1 piece_2 M3 12 24 m3 NaN 36 P5 3 9 Yields this
DataFrame
:Index ‘aggregator.ColumnAggregator’ M3 36 m3 36 P5 12 Example 2
Inputting two
DataFrame
objects is similar.Index piece_1 M3 12 P5 3 Index piece_2 M3 24 m3 36 P5 9 The result is the same
DataFrame
:Index ‘aggregator.ColumnAggregator’ M3 36 m3 36 P5 12 Example 3
You may also give a
DataFrame
(or a list ofDataFrame
objects) that have apandas.MultiIndex
as produced by subclasses ofIndexer
. In this case, use the'column'
setting to indicate which indexer’s results you wish to aggregate.Index ‘frequency.FrequencyExperimenter’ ‘feelings.FeelingsExperimenter’ ‘0,1’ ‘1,2’ ‘Christopher’ ‘Alex’ M3 12 24 ‘delight’ ‘exuberance’ m3 NaN 36 ‘sheer joy’ ‘nonchalance’ P5 3 9 ‘emptiness’ ‘serenity’ If
'column'
is'frequency.FrequencyExperimenter'
, yet again you will have thisDataFrame
:Index ‘aggregator.ColumnAggregator’ M3 36 m3 36 P5 12 -
default_settings
= {'column': None}
-
possible_settings
= ['column'] Parameters: 'column' (str) – The column name to use for aggregation. The default is None
, which aggregates across all columns. If you set this to'all'
, it will override the default behaviour of not including columns called'all'
.
-
run
()[source] Run the
ColumnAggregator
experiment.Returns: A Series
with an index that is the combination of all indices of the provided pandas objects, and the value is the sum of all values in the pandas objects.Return type: pandas.Series
*Example:*
import music21 from vis.analyzers.indexers import noterest from vis.analyzers.experimenters import aggregator, frequency
score = music21.converter.parse(‘example.xml’) notes = noterest.NoteRestIndexer(score).run()
freqs = frequency.FrequencyExperimenter(notes).run() agg = aggregator.ColumnAggregator(freqs).run() print(agg)
-
dendrogram
Module¶
Aggregating experimenters.
-
class
vis.analyzers.experimenters.aggregator.
ColumnAggregator
(index, settings=None)[source] Bases:
vis.analyzers.experimenter.Experimenter
(Arguments for the constructor are listed below).
Experiment that aggregates data from columns of a
DataFrame
, or a list ofDataFrame
objects, by summing each row. Values from columns named'all'
will not be included in the aggregated results. You may provide a'column'
setting to guide the experimenter to include only certain results.Example 1
Inputting single
DataFrame
like this:Index piece_1 piece_2 M3 12 24 m3 NaN 36 P5 3 9 Yields this
DataFrame
:Index ‘aggregator.ColumnAggregator’ M3 36 m3 36 P5 12 Example 2
Inputting two
DataFrame
objects is similar.Index piece_1 M3 12 P5 3 Index piece_2 M3 24 m3 36 P5 9 The result is the same
DataFrame
:Index ‘aggregator.ColumnAggregator’ M3 36 m3 36 P5 12 Example 3
You may also give a
DataFrame
(or a list ofDataFrame
objects) that have apandas.MultiIndex
as produced by subclasses ofIndexer
. In this case, use the'column'
setting to indicate which indexer’s results you wish to aggregate.Index ‘frequency.FrequencyExperimenter’ ‘feelings.FeelingsExperimenter’ ‘0,1’ ‘1,2’ ‘Christopher’ ‘Alex’ M3 12 24 ‘delight’ ‘exuberance’ m3 NaN 36 ‘sheer joy’ ‘nonchalance’ P5 3 9 ‘emptiness’ ‘serenity’ If
'column'
is'frequency.FrequencyExperimenter'
, yet again you will have thisDataFrame
:Index ‘aggregator.ColumnAggregator’ M3 36 m3 36 P5 12 -
default_settings
= {'column': None}
-
possible_settings
= ['column'] Parameters: 'column' (str) – The column name to use for aggregation. The default is None
, which aggregates across all columns. If you set this to'all'
, it will override the default behaviour of not including columns called'all'
.
-
run
()[source] Run the
ColumnAggregator
experiment.Returns: A Series
with an index that is the combination of all indices of the provided pandas objects, and the value is the sum of all values in the pandas objects.Return type: pandas.Series
*Example:*
import music21 from vis.analyzers.indexers import noterest from vis.analyzers.experimenters import aggregator, frequency
score = music21.converter.parse(‘example.xml’) notes = noterest.NoteRestIndexer(score).run()
freqs = frequency.FrequencyExperimenter(notes).run() agg = aggregator.ColumnAggregator(freqs).run() print(agg)
-
frequency
Module¶
Experimenters that deal with the frequencies (number of occurrences) of events.
-
class
vis.analyzers.experimenters.frequency.
FrequencyExperimenter
(index, settings=None)[source]¶ Bases:
vis.analyzers.experimenter.Experimenter
Calculate the number of occurrences of objects in an index.
Use the
'column'
setting to choose only the results of one previous analyzer. For example, if you wanted to calculate the frequency of vertical intervals, you would specify'interval.IntervalIndexer'
. This would avoid counting, for example, the horizontal intervals if they were also present.-
default_settings
= {'column': None}¶
-
possible_settings
= ['column']¶ Parameters: 'column' (str) – The column name to use for counting frequency. The default is None
, which counts all columns. Use this to count only the frequency of one previous analyzer.
-
run
()[source]¶ Run the
FrequencyExperimenter
.Returns: The result of the experiment. Data is stored such that column labels correspond to the part (combinations) totalled in the column, and row labels correspond to a type of the kind of objects found in the given index. Note that all columns are totalled in the “all” column, and that not every part combination will have every interval; in case an interval does not appear in a part combination, the value is numpy.NaN
.Return type: list of pandas.DataFrame
*Example:*
import music21 from vis.analyzers.indexers import noterest from vis.analyzers.experimenters import frequency
score = music21.converter.parse(‘example.xml’) notes = noterest.NoteRestIndexer(score).run()
freqs = frequency.FrequencyExperimenter(notes).run() print(freqs)
-
template
Module¶
Template for writing a new experimenter. Use this class to help write a new :class`Experimenter` subclass. The TemplateExperimenter
does nothing, and should only be used by programmers.
-
class
vis.analyzers.experimenters.template.
TemplateExperimenter
(index, settings=None)[source]¶ Bases:
vis.analyzers.experimenter.Experimenter
Template for an
Experimenter
subclass.-
default_settings
= {}¶ The default values for settings named in
possible_settings
. If a setting doesn’t have a value in this constant, then it must be specified to the constructor at runtime, or the constructor should raise aRuntimeException
.
-
possible_settings
= ['fake_setting']¶ This is a list of strings that are the names of the settings used in this experimenter. Specify the types and reasons for each setting as though it were an argument list, like this:
Parameters: 'fake_setting' (boolean) – This is a fake setting.
-
run
()[source]¶ Run an experiment on a piece.
Returns: The result of the experiment. Each experiment should describe its data storage. Return type: pandas.Series
orpandas.DataFrame
-