Previous Up Next

class Partition

module partition

The documentation is here.

Instances of this class are sets of Segment that part a data in several segments.

A n-partition is a partition with n segments.

A Partition is made of

In all computations on data, if not specified, the first position of the partition is 0 and the last len(data)-1.


Optional keyword fic allows construction by reading from a filename in specific format;
sets the name from a given string;
builds from a filename in specific format;
builds from a string in specific format;
builds from a Matrice, keeping at each position the descriptor number that is selected by a function. A segment is made for each run of identical descriptors numbers, and its value is the sum on its positions of the values returned by the function.

Optional keyword:

uses function f for selecting the descriptor number. Function f has two arguments, a Matrice and a position, and returns a tuple descriptor number, floating point value (default: returns the tuple best descriptor,best value (the first of the bests descriptors is returned if there are several bests)).
builds a new Partition by copying this one;
builds a random Partition on a given length with a given number of segments. Positions of the segments are uniformly distributed;

Optional keyword:

sets the minimum length of the segments. It must be lower than the length of the sequence divided by (the number of segments +1) (default: 0).
using Viterbi algorithm (see [Rab89]), computes the most likely prediction Partition of a Lexique on a Sequence;

Optional keyword:

limits to m the maximum number of segments allowed in the computed partition (default: 10000). If m equals 0, there is no limit to this number.
computes the maximum-prediction partition of a given number of segments by a Lexique on a data.


appends a Segment after the highest position of the Partition;
returns the value;
returns the name;
returns the data length;
returns the number of Segment;
returns the list of descriptors numbers;
returns the Segment of a given number;

Other methods:

returns a new Partition by clustering the Segment given their descriptors numbers. The argument is a list of numbers lists, each list being a set of clustered descriptors numbers. In the new Partition, the resulting Segment have no descriptors numbers.

Following the increasing positions order, the Segment are grouped as long as the set of the descriptors numbers of the group is included in a list of the argument; if this set is not included in such a list, a new Segment is built, and the new set is the descriptors numbers of the considered Segment;

computes the prediction on a data by a Lexique, computing one best descriptor per class, without between descriptors transitions;
on a Partition, it returns the number of positions where the descriptors numbers are the same in both Partition.

If the data-lengths are different, returns -1;


Specific format is:

outputs of Segment separated by ’ XXX ’ —> value
<0-123>1,2:-5.0:+{A(-1)CG}T XXX <124-341>3:-7.0: ---> -12.0
<0-4>0:1.25: XXX <5-3922>:0.45: XXX <3923-4000>:0.31: ---> 2.01
<0-86>:: XXX <87-332>1:: ---> 0
outputs in specific format;
outputs in specific format, without the descriptors patterns.

Graphical output

Horizontal axis represents the data, and each segment is drawn by an arc. The height of each arc is computed by a given function on the segments (here their lengths).

outputs in postscript language in file of given name;

Optional keywords:

draws only segments which numbers are in list l;
if equals 1, numbers of the descriptors are written;
the height of each arc is proportional to value of function f computed on the corresponding Segment.
R language
A drawing function of a Parti_simp in R language is available here.

Previous Up Next