Module Import alias ImportFrom alias Import alias identifier ImportFrom alias ImportFrom alias ImportFrom alias ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults Num Num Num Num Num NameLoad NameLoad NameLoad Num Num NameLoad Str NameLoad body If CompareNotEq NameLoad Num body Expr Call AttributeLoad NameLoad attr Str If CompareNotIn NameLoad ListLoad Str Str Str body Raise Call NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad AttributeLoad NameLoad attr keyword NameLoad Assign NameStore BinOpSub NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Assign NameStore BinOpMult NameLoad AttributeLoad NameLoad attr Assign NameStore BinOpMult BinOpMult AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr Assign NameStore BinOpAdd BinOpMult Num Call AttributeLoad NameLoad attr BinOpPow AttributeLoad NameLoad attr Num NameLoad Assign NameStore BinOpSub AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpAdd BinOpSub Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr NameLoad BinOpMult NameLoad AttributeLoad NameLoad attr Assign NameStore BinOpAdd NameLoad NameLoad Return TupleLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Num Assign NameStore Call NameLoad Call NameLoad NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameLoad For NameStore Call NameLoad AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad AttributeLoad NameLoad attr keyword NameLoad Assign NameStore BinOpSub NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Assign NameStore BinOpMult NameLoad AttributeLoad NameLoad attr Assign NameStore BinOpSub AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpAdd BinOpSub BinOpMult BinOpDiv Num BinOpMult AttributeLoad NameLoad attr NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr NameLoad NameLoad If AttributeLoad NameLoad attr body Assign NameStore Num Assign NameStore BinOpDiv NameLoad BinOpAdd BinOpDiv Call AttributeLoad NameLoad attr BinOpPow NameLoad Num BinOpMult AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call NameLoad Num Call NameLoad Num NameLoad orelse Assign NameStore BinOpDiv Num BinOpAdd NameLoad Num Assign NameStore BinOpAdd BinOpMult Num Call AttributeLoad NameLoad attr BinOpPow AttributeLoad NameLoad attr Num BinOpMult NameLoad BinOpMult NameLoad AttributeLoad NameLoad attr Assign NameStore BinOpMult BinOpMult NameLoad NameLoad AttributeLoad NameLoad attr Assign NameStore BinOpAdd NameLoad NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpSub Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num If CompareGt AttributeLoad NameLoad attr Num body Print BinOpMod Str TupleLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign AttributeStore NameLoad attr BinOpAdd BinOpMult BinOpSub Num NameLoad AttributeLoad NameLoad attr BinOpMult NameLoad NameLoad Assign NameStore BinOpAdd BinOpMult BinOpSub Num NameLoad NameLoad BinOpMult NameLoad NameLoad If CompareIsNot AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad If CompareLt NameLoad AttributeLoad NameLoad attr body Return decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Num Assign NameStore Num Assign NameStore Call NameLoad AttributeLoad NameLoad attr For NameStore Call NameLoad AttributeLoad NameLoad attr body If CompareGt AttributeLoad NameLoad attr Num body Print BinOpMod Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareEq AttributeLoad NameLoad attr Str body Expr Call AttributeLoad NameLoad attr NameLoad orelse If CompareEq AttributeLoad NameLoad attr Str body Assign NameStore Call AttributeLoad NameLoad attr keyword Num keyword NameLoad keyword NameLoad For NameStore Call NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad Index NameLoad Assign TupleStore NameStore NameStore TupleLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad Assign TupleStore NameStore NameStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Assign NameStore BinOpMult NameLoad AttributeLoad NameLoad attr Assign NameStore BinOpDiv NameLoad NameLoad If AttributeLoad NameLoad attr body Assign NameStore Num Assign NameStore BinOpSub SubscriptLoad NameLoad Index NameLoad NameLoad Assign NameStore BinOpDiv BinOpSub Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad BinOpMult BinOpMult AttributeLoad NameLoad attr NameLoad BinOpSub SubscriptLoad NameLoad Index NameLoad NameLoad BinOpAdd Call AttributeLoad NameLoad attr BinOpPow NameLoad Num NameLoad Assign NameStore Call NameLoad Num Call NameLoad Num NameLoad orelse Assign NameStore BinOpDiv BinOpMult Num NameLoad BinOpAdd NameLoad BinOpMult Num NameLoad AugAssignSub NameStore SubscriptLoad NameLoad Index NameLoad Assign SubscriptStore NameLoad Index NameLoad BinOpAdd BinOpMult BinOpSub Num NameLoad SubscriptLoad NameLoad Index NameLoad BinOpMult NameLoad NameLoad AugAssignAdd NameStore SubscriptLoad NameLoad Index NameLoad AugAssignSub NameStore SubscriptLoad NameLoad Index NameLoad Assign SubscriptStore NameLoad Index NameLoad BinOpAdd BinOpMult BinOpSub Num NameLoad SubscriptLoad NameLoad Index NameLoad BinOpMult NameLoad NameLoad AugAssignAdd NameStore SubscriptLoad NameLoad Index NameLoad If AttributeLoad NameLoad attr body Assign NameStore BinOpDiv Num BinOpAdd NameLoad Num Assign AttributeStore NameLoad attr BinOpAdd BinOpMult BinOpSub Num NameLoad AttributeLoad NameLoad attr BinOpMult NameLoad NameLoad Assign AttributeStore NameLoad attr BinOpAdd BinOpMult BinOpSub Num NameLoad AttributeLoad NameLoad attr BinOpMult NameLoad NameLoad orelse Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad AugAssignAdd NameStore Num If BoolOpAnd CompareNotEq AttributeLoad NameLoad attr Num CompareEq BinOpMod NameLoad AttributeLoad NameLoad attr Num body Assign TupleStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpSub Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num If CompareGt AttributeLoad NameLoad attr Num body Print BinOpMod Str TupleLoad NameLoad NameLoad NameLoad If CompareIsNot AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad If CompareLt NameLoad AttributeLoad NameLoad attr body Return decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Assign TupleStore AttributeStore NameLoad attr AttributeStore NameLoad attr TupleLoad ListLoad ListLoad Assign AttributeStore NameLoad attr ListLoad Call NameLoad Assign AttributeStore NameLoad attr Call NameLoad NameLoad Str Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr Assign AttributeStore NameLoad attr Call NameLoad NameLoad Str Num TryExcept body If AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad NameLoad handlers ExceptHandler type NameLoad body Pass If AttributeLoad NameLoad attr body Print Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpSub Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr SubscriptLoad AttributeLoad NameLoad attr Index Num If CompareIsNot AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Str Return NameLoad decorator_list decorator_list
N/A N/A warnings time time N/A numpy np sklearn.utils check_random_state pystruct.learners.ssvm BaseSSVM pystruct.utils find_constraint FrankWolfeSSVM N/A BaseSSVM N/A N/A Structured SVM solver using Block-coordinate Frank-Wolfe.

    This implementation is somewhat experimental. Use with care.

    References
    ----------
    * Lacoste-Julien, Jaggi, Schmidt, Pletscher:
        Block-Coordinate Frank-Wolfe Optimization for Structural SVMs,xi
        JMLR 2013

    With batch_mode=False, this implements the online (block-coordinate)
    version of the algorithm (BCFW)
    BCFW is an attractive alternative to subgradient methods, as no
    learning rate is needed and a duality gap guarantee is given.

    Parameters
    ----------
    model : StructuredModel
        Object containing the model structure. Has to implement
        `loss`, `inference` and `loss_augmented_inference`.

    max_iter : int, default=1000
        Maximum number of passes over dataset to find constraints.

    C : float, default=1
        Regularization parameter. Corresponds to 1 / (lambda * n_samples).

    verbose : int
        Verbosity.

    n_jobs : int, default=1
        Number of parallel processes. Currently only n_jobs=1 is supported.

    show_loss_every : int, default=0
        How often the training set loss should be computed.
        Zero corresponds to never.

    tol : float, default=1e-3
        Convergence tolerance on the duality gap.

    logger : logger object, default=None
        Pystruct logger for storing the model or extracting additional
        information.

    batch_mode : boolean, default=False
        Whether to use batch updates. Will slow down learning enormously.

    line_search : boolean, default=True
        Whether to compute the optimum step size in each step.
        The line-search is done in closed form and cheap.
        There is usually no reason to turn this off.

    check_dual_every : int, default=10
        How often the stopping criterion should be checked. Computing
        the stopping criterion is as costly as doing one pass over the dataset,
        so check_dual_every=1 will make learning twice as slow.

    do_averaging : bool, default=True
        Whether to use weight averaging as described in the reference paper.
        Currently this is only supported in the block-coordinate version.

    random_state : int, RandomState instance or None, optional (default=None)
        If int, random_state is the seed used by the random number generator;
        If RandomState instance, random_state is the random number generator;
        If None, the random number generator is the RandomState instance used
        by `np.random`.


    Attributes
    ----------
    w : nd-array, shape=(model.size_joint_feature,)
        The learned weights of the SVM.

    ``loss_curve_`` : list of float
        List of loss values if show_loss_every > 0.

    ``objective_curve_`` : list of float
       Cutting plane objective after each pass through the dataset.

    ``primal_objective_curve_`` : list of float
        Primal objective after each pass through the dataset.

    ``timestamps_`` : list of int
       Total training time stored before each iteration.
     __init__ N/A N/A self model max_iter C verbose n_jobs show_loss_every logger batch_mode line_search check_dual_every tol do_averaging sample_method random_state N/A 1000 1.0 0 1 0 None False True 10 0.001 True perm None N/A N/A N/A n_jobs 1 N/A N/A N/A N/A warnings warn FrankWolfeSSVM does not support multiprocessing yet. Ignoring n_jobs != 1. N/A N/A sample_method N/A perm rnd seq N/A N/A N/A ValueError sample_method can only be perm, rnd, or seq N/A N/A N/A BaseSSVM __init__ self model max_iter C verbose verbose n_jobs n_jobs show_loss_every show_loss_every logger logger N/A N/A self tol tol N/A N/A self batch_mode batch_mode N/A N/A self line_search line_search N/A N/A self check_dual_every check_dual_every N/A N/A self do_averaging do_averaging N/A N/A self sample_method sample_method N/A N/A self random_state random_state N/A _calc_dual_gap N/A N/A self X Y N/A N/A N/A n_samples N/A len X N/A joint_feature_gt N/A N/A N/A self model batch_joint_feature X Y Y N/A Y_hat N/A N/A N/A self model batch_loss_augmented_inference X Y N/A self w relaxed True N/A djoint_feature N/A joint_feature_gt N/A N/A N/A self model batch_joint_feature X Y_hat N/A ls N/A N/A np sum N/A N/A N/A self model batch_loss Y Y_hat N/A ws N/A djoint_feature N/A self C N/A l_rescaled N/A N/A N/A self l n_samples N/A self C N/A dual_val N/A N/A -0.5 N/A N/A np sum N/A N/A self w 2 l_rescaled N/A w_diff N/A N/A self w ws N/A dual_gap N/A N/A N/A N/A N/A w_diff T dot N/A self w l_rescaled N/A ls N/A self C N/A primal_val N/A dual_val dual_gap N/A N/A dual_val dual_gap primal_val N/A _frank_wolfe_batch N/A N/A self X Y N/A N/A N/A Batch Frank-Wolfe learning.

        This is basically included for reference / comparision only,
        as the block-coordinate version is much faster.

        Compare Algorithm 2 in the reference paper.
         N/A l 0.0 N/A n_samples N/A float N/A len X N/A joint_feature_gt N/A N/A N/A self model batch_joint_feature X Y Y N/A iteration N/A range N/A self max_iter N/A N/A Y_hat N/A N/A N/A self model batch_loss_augmented_inference X Y N/A self w relaxed True N/A djoint_feature N/A joint_feature_gt N/A N/A N/A self model batch_joint_feature X Y_hat N/A ls N/A N/A np mean N/A N/A N/A self model batch_loss Y Y_hat N/A ws N/A djoint_feature N/A self C N/A w_diff N/A N/A self w ws N/A dual_gap N/A N/A N/A N/A 1.0 N/A N/A self C n_samples N/A N/A N/A w_diff T dot N/A self w l ls N/A N/A self line_search N/A N/A eps 1e-15 N/A gamma N/A dual_gap N/A N/A N/A N/A np sum N/A w_diff 2 N/A N/A self C n_samples eps N/A gamma N/A max 0.0 N/A min 1.0 gamma N/A N/A gamma N/A 2.0 N/A iteration 2.0 N/A dual_val N/A N/A -0.5 N/A N/A np sum N/A N/A self w 2 N/A l N/A n_samples N/A self C N/A dual_gap_display N/A N/A dual_gap n_samples N/A self C N/A primal_val N/A dual_val dual_gap_display N/A N/A N/A N/A self primal_objective_curve_ append primal_val N/A N/A N/A N/A self objective_curve_ append dual_val N/A N/A N/A N/A self timestamps_ append N/A N/A time N/A N/A self timestamps_ N/A 0 N/A N/A N/A self verbose 0 N/A N/A N/A iteration %d, dual: %f, dual_gap: %f, primal: %f, gamma: %f N/A iteration dual_val dual_gap_display primal_val gamma N/A N/A self w N/A N/A N/A 1.0 gamma N/A self w N/A gamma ws N/A l N/A N/A N/A 1.0 gamma l N/A gamma ls N/A N/A N/A self logger None N/A N/A N/A N/A self logger self iteration N/A N/A dual_gap N/A self tol N/A N/A N/A _frank_wolfe_bc N/A N/A self X Y N/A N/A N/A Block-Coordinate Frank-Wolfe learning.

        Compare Algorithm 3 in the reference paper.
         N/A n_samples N/A len X N/A w N/A N/A N/A self w copy N/A w_mat N/A N/A np zeros N/A n_samples N/A N/A self model size_joint_feature N/A l_mat N/A N/A np zeros n_samples N/A l 0.0 N/A k 0 N/A rng N/A check_random_state N/A self random_state N/A iteration N/A range N/A self max_iter N/A N/A N/A N/A self verbose 0 N/A N/A N/A Iteration %d iteration N/A perm N/A N/A np arange n_samples N/A N/A N/A self sample_method perm N/A N/A N/A N/A rng shuffle perm N/A N/A N/A N/A self sample_method rnd N/A N/A perm N/A N/A rng randint low 0 high n_samples size n_samples N/A j N/A range n_samples N/A N/A i N/A perm N/A j N/A N/A x y N/A N/A X N/A i N/A Y N/A i N/A N/A y_hat delta_joint_feature slack loss N/A find_constraint N/A self model x y w N/A ws N/A delta_joint_feature N/A self C N/A ls N/A loss n_samples N/A N/A self line_search N/A N/A eps 1e-15 N/A w_diff N/A N/A w_mat N/A i ws N/A gamma N/A N/A N/A N/A N/A w_diff T dot w N/A N/A N/A self C n_samples N/A N/A l_mat N/A i ls N/A N/A N/A np sum N/A w_diff 2 eps N/A gamma N/A max 0.0 N/A min 1.0 gamma N/A N/A gamma N/A N/A 2.0 n_samples N/A k N/A 2.0 n_samples N/A w N/A w_mat N/A i N/A N/A w_mat N/A i N/A N/A N/A 1.0 gamma N/A w_mat N/A i N/A gamma ws N/A w N/A w_mat N/A i N/A l N/A l_mat N/A i N/A N/A l_mat N/A i N/A N/A N/A 1.0 gamma N/A l_mat N/A i N/A gamma ls N/A l N/A l_mat N/A i N/A N/A self do_averaging N/A N/A rho N/A 2.0 N/A k 2.0 N/A N/A self w N/A N/A N/A 1.0 rho N/A self w N/A rho w N/A N/A self l N/A N/A N/A 1.0 rho N/A self l N/A rho l N/A N/A N/A self w w N/A N/A self l l N/A k 1 N/A N/A N/A N/A self check_dual_every 0 N/A N/A iteration N/A self check_dual_every 0 N/A N/A N/A dual_val dual_gap primal_val N/A N/A self _calc_dual_gap X Y N/A N/A N/A N/A self primal_objective_curve_ append primal_val N/A N/A N/A N/A self objective_curve_ append dual_val N/A N/A N/A N/A self timestamps_ append N/A N/A time N/A N/A self timestamps_ N/A 0 N/A N/A N/A self verbose 0 N/A N/A N/A dual: %f, dual_gap: %f, primal: %f N/A dual_val dual_gap primal_val N/A N/A N/A self logger None N/A N/A N/A N/A self logger self iteration N/A N/A dual_gap N/A self tol N/A N/A N/A fit N/A N/A self X Y constraints initialize N/A None True N/A N/A Learn parameters using (block-coordinate) Frank-Wolfe learning.

        Parameters
        ----------
        X : iterable
            Traing instances. Contains the structured input objects.
            No requirement on the particular form of entries of X is made.

        Y : iterable
            Training labels. Contains the strctured labels for inputs in X.
            Needs to have the same length as X.

        contraints : ignored

        initialize : boolean, default=True
            Whether to initialize the model for the data.
            Leave this true except if you really know what you are doing.
         N/A initialize N/A N/A N/A N/A N/A self model initialize X Y N/A N/A N/A self objective_curve_ N/A self primal_objective_curve_ N/A N/A N/A N/A N/A self timestamps_ N/A N/A time N/A N/A self w N/A getattr self w N/A N/A np zeros N/A N/A self model size_joint_feature N/A N/A self l N/A getattr self l 0 N/A N/A N/A N/A self batch_mode N/A N/A N/A N/A self _frank_wolfe_batch X Y N/A N/A N/A N/A self _frank_wolfe_bc X Y N/A N/A N/A KeyboardInterrupt N/A N/A N/A N/A self verbose N/A N/A Calculating final objective. N/A N/A N/A N/A self timestamps_ append N/A N/A time N/A N/A self timestamps_ N/A 0 N/A N/A N/A N/A self primal_objective_curve_ append N/A N/A self _objective X Y N/A N/A N/A N/A self objective_curve_ append N/A N/A self objective_curve_ N/A -1 N/A N/A N/A self logger None N/A N/A N/A N/A self logger self final N/A self N/A N/A