Skip to content

Architecture

eli knaap edited this page Mar 2, 2019 · 12 revisions

spopt Architecture

Following the proposal for groundrules, we want to try and mimic the class inheritance structures found in scikit. These structures require some modifications to account for the unique properties of regionalization. This doc is a brainstorm of how those conventions will need to be modified, and will serve as a guide for constructing spopt classes


Module Structure

spopt/

base.py

region/
allocate/
route/

Terminology

scikit uses BaseEstimator and ClassMixins to for every structure in the library. We want to follow a similar convention, providing a BaseClass, and appropriate mixins for each class.

  • Rather than Estimator, we think Solver is a more appropriate and descriptive verb.
  • rather than fit() the classes will define a solve() method

Modifying scikit conventions

In scikit, the estimator classes hold model parameters, and are indifferent toward data used to fit/solve the model. For regionalizers, this same pattern is complicated to mimic for two reasons:

  1. W objects cannot be abstracted away from a dataset entirely because missing values need to be removed from W. In theory this could be done by initializing the regionalizer with the "full" W, and subsetting it according to missing values in the dataset, but that strategy would not work for, e.g. KNN weights, where dropping observations could violate the defined K
  2. the regionalizers dont really have the concept of "transform" or "assign" new observations based on the existing model
    • or do they? like grow_regions in maxp?

Structures

Classes

  • Regionalizer
  • Allocator
  • Router

Mixins

  • RegionalizeMixin
  • LabelerMixin (applies to both allocation and regionalization)

Methods

  • solve (equivalent to scikit's fit)
  • assign (equivalent to scikit's predict)