Module Import alias identifier Import alias identifier Import alias ClassDef bases body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Raise NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Raise NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Num Assign NameStore Num AugAssignAdd NameStore SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index Num For NameStore Call NameLoad NameLoad body AugAssignAdd NameStore SubscriptLoad NameLoad Index TupleLoad NameLoad SubscriptLoad NameLoad Index NameLoad If CompareGt NameLoad Num body AugAssignAdd NameStore SubscriptLoad NameLoad Index TupleLoad BinOpSub NameLoad Num SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index BinOpSub NameLoad Num AugAssignAdd NameStore SubscriptLoad NameLoad Index SubscriptLoad NameLoad Index BinOpSub NameLoad Num Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad Num Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameLoad NameLoad Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr ListLoad NameLoad NameLoad For NameStore Call NameLoad NameLoad body Assign SubscriptStore NameLoad ExtSlice Index NameLoad Slice BinOpAdd SubscriptLoad NameLoad ExtSlice Index NameLoad Slice SubscriptLoad NameLoad ExtSlice Index NameLoad Slice AugAssignSub SubscriptStore NameLoad ExtSlice Index NameLoad Slice NameLoad Assign NameStore Call AttributeLoad NameLoad attr ListLoad BinOpSub NameLoad Num NameLoad NameLoad For NameStore Call NameLoad BinOpSub NameLoad Num body For NameStore Call NameLoad NameLoad body For NameStore Call NameLoad NameLoad body Assign SubscriptStore NameLoad Index TupleLoad NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index TupleLoad BinOpAdd NameLoad Num NameLoad SubscriptLoad NameLoad Index TupleLoad BinOpAdd NameLoad Num NameLoad AugAssignSub SubscriptStore NameLoad Index TupleLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Return TupleLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad Assign TupleStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword Num Assign NameStore Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore ListLoad For NameStore AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore ListLoad For NameStore AttributeLoad NameLoad attr body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Num Assign NameStore Num For TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr body Assign NameStore SubscriptLoad NameLoad Index NameLoad For TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr body If CompareEq SubscriptLoad AttributeLoad NameLoad attr Index NameLoad NameLoad body AugAssignAdd NameStore Num AugAssignAdd NameStore Num Return BinOpDiv NameLoad NameLoad decorator_list decorator_list
N/A N/A numpy np N/A sequence_classification_decoder scd N/A pdb SequenceClassifier N/A N/A N/A  Implements an abstract sequence classifier. __init__ N/A N/A self observation_labels state_labels N/A N/A N/A Initialize a sequence classifier. observation_labels and
        state_labels are the sets of observations and states, respectively.
        They must be LabelDictionary objects. N/A N/A self decoder N/A N/A scd SequenceClassificationDecoder N/A N/A self observation_labels observation_labels N/A N/A self state_labels state_labels N/A N/A self trained False N/A get_num_states N/A N/A self N/A N/A N/A  Return the number of states. N/A N/A len N/A self state_labels N/A get_num_observations N/A N/A self N/A N/A N/A  Return the number of observations (e.g. word types). N/A N/A len N/A self observation_labels N/A train_supervised N/A N/A self sequence_list N/A N/A N/A  Train a classifier in a supervised setting. N/A NotImplementedError N/A compute_scores N/A N/A self sequence N/A N/A N/A  Compute emission and transition scores for the decoder. N/A NotImplementedError N/A compute_output_score N/A N/A self states initial_scores transition_scores final_scores emission_scores N/A N/A N/A length N/A N/A np size emission_scores 0 N/A score 0.0 N/A score N/A initial_scores N/A N/A states N/A 0 N/A pos N/A xrange length N/A N/A score N/A emission_scores N/A N/A pos N/A states N/A pos N/A N/A pos 0 N/A N/A score N/A transition_scores N/A N/A N/A pos 1 N/A states N/A pos N/A states N/A N/A pos 1 N/A score N/A final_scores N/A N/A states N/A N/A length 1 N/A score N/A compute_posteriors N/A N/A self initial_scores transition_scores final_scores emission_scores N/A N/A N/A Compute the state and transition posteriors:
        - The state posteriors are the probability of each state
        occurring at each position given the sequence of observations.
        - The transition posteriors are the joint probability of two states
        in consecutive positions given the sequence of observations.
        Both quantities are computed via the forward-backward algorithm. N/A length N/A N/A np size emission_scores 0 N/A num_states N/A N/A np size emission_scores 1 N/A N/A log_likelihood forward N/A N/A N/A self decoder run_forward initial_scores transition_scores final_scores emission_scores N/A N/A log_likelihood backward N/A N/A N/A self decoder run_backward initial_scores transition_scores final_scores emission_scores N/A state_posteriors N/A N/A np zeros N/A length num_states N/A pos N/A xrange length N/A N/A N/A state_posteriors N/A N/A pos N/A N/A N/A forward N/A N/A pos N/A N/A backward N/A N/A pos N/A N/A N/A state_posteriors N/A N/A pos N/A log_likelihood N/A transition_posteriors N/A N/A np zeros N/A N/A length 1 num_states num_states N/A pos N/A xrange N/A length 1 N/A N/A prev_state N/A xrange num_states N/A N/A state N/A xrange num_states N/A N/A N/A transition_posteriors N/A N/A pos state prev_state N/A N/A N/A N/A forward N/A N/A pos prev_state N/A transition_scores N/A N/A pos state prev_state N/A emission_scores N/A N/A N/A pos 1 state N/A backward N/A N/A N/A pos 1 state N/A N/A transition_posteriors N/A N/A pos state prev_state log_likelihood N/A state_posteriors N/A N/A np exp state_posteriors N/A transition_posteriors N/A N/A np exp transition_posteriors N/A N/A state_posteriors transition_posteriors log_likelihood N/A posterior_decode N/A N/A self sequence N/A N/A N/A Compute the sequence of states that are individually the most
        probable, given the observations. This is done by maximizing
        the state posteriors, which are computed with the forward-backward
        algorithm. N/A N/A initial_scores transition_scores final_scores emission_scores N/A N/A self compute_scores sequence N/A N/A state_posteriors _ _ N/A N/A self compute_posteriors initial_scores transition_scores final_scores emission_scores N/A best_states N/A N/A np argmax state_posteriors axis 1 N/A predicted_sequence N/A N/A sequence copy_sequence N/A N/A predicted_sequence y best_states N/A predicted_sequence N/A posterior_decode_corpus N/A N/A self dataset N/A N/A N/A Run posterior_decode at corpus level. N/A predictions N/A N/A sequence N/A dataset seq_list N/A N/A N/A N/A predictions append N/A N/A self posterior_decode sequence N/A predictions N/A viterbi_decode N/A N/A self sequence N/A N/A N/A Compute the most likely sequence of states given the observations,
        by running the Viterbi algorithm. N/A N/A initial_scores transition_scores final_scores emission_scores N/A N/A self compute_scores sequence N/A N/A best_states total_score N/A N/A N/A self decoder run_viterbi initial_scores transition_scores final_scores emission_scores N/A predicted_sequence N/A N/A sequence copy_sequence N/A N/A predicted_sequence y best_states N/A N/A predicted_sequence total_score N/A viterbi_decode_corpus N/A N/A self dataset N/A N/A N/A Run viterbi_decode at corpus level. N/A predictions N/A N/A sequence N/A dataset seq_list N/A N/A N/A predicted_sequence _ N/A N/A self viterbi_decode sequence N/A N/A N/A predictions append predicted_sequence N/A predictions N/A evaluate_corpus N/A N/A self dataset predictions N/A N/A N/A Evaluate classification accuracy at corpus level, comparing with
        gold standard. N/A total 0.0 N/A correct 0.0 N/A N/A i sequence N/A enumerate N/A dataset seq_list N/A N/A pred N/A predictions N/A i N/A N/A j y_hat N/A enumerate N/A pred y N/A N/A N/A N/A N/A sequence y N/A j y_hat N/A N/A correct 1 N/A total 1 N/A N/A correct total N/A N/A