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.

Construction

__init__
Optional keyword fic allows construction by reading from a filename in specific format;
s_name
sets the name from a given string;
read_nf
builds from a filename in specific format;
read_str
builds from a string in specific format;
read_Matrice
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:
func=f
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)).
build_random
builds a random Partition with a given number of segments on a given length. Positions of the Segment are uniformly distributed;
viterbi
using Viterbi algorithm (see [Rab89]), computes the best prediction Partition of a Lexique on a Sequence;

Optional keyword:
maxseg=m
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.


mpp
computes the maximum-prediction partition of a given number of segments by a Lexique on a data.

Handling

__iadd__
appends a Segment after the highest position of the Partition;
val
returns the value;
name
returns the name;
len_don
returns the data length;
__len__
returns the number of Segment;
num
returns the list of descriptors numbers;
__getitem__
returns the Segment of a given number;
Other methods:
group
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;
prediction
computes the prediction on a data by a Lexique, computing one best descriptor per class, without between descriptors transitions;
pts_comm
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;

Input-Output

Specific format is:
description
outputs of Segment separated by ' XXX ' ---> value
examples
<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
__str__
outputs in specific format;
abr
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).
draw_nf
outputs in postscript language in file of given name;

Optional keywords:
seg=l
draws only segments which numbers are in list l;
num=n
if equals 1, numbers of the descriptors are written;
func=f
the height of each arc is proportional to value of function f computed on the corresponding Segment.

Previous Up Next