Project Architecture


Open the diagram in a new tab to see the full details.

UML Class Diagram


skinparam BackgroundColor transparent
skinparam Shadowing false

' Diagram setup
hide empty members
left to right direction
set namespaceSeparator none

skinparam linetype polyline
skinparam linetype ortho

package foreshadow.utils {
    class check_df << (M,lemonchiffon) >>
package foreshadow.logging {
    class ForeshadowLogger
package foreshadow.intents {
    abstract class BaseIntent {
        list engineering_pipeline
        list preprocessing_pipeline

    class DropIntent
    class NumericalIntent
    class CategoricalIntent
    class TextIntent

    BaseIntent <|-- DropIntent
    BaseIntent <|-- NumericalIntent
    BaseIntent <|-- CategoricalIntent
    BaseIntent <|-- TextIntent

    note "Config for intentless transformations (cleaner) are placed in\nBaseIntent's specification" as N1

    package foreshadow.transformers.core {
        abstract class SmartTransformer {
            bool fixed_fit

        class ParallelProcessor
        class SigCopy
        class DropFeature

        class wrap_transformer << (M,lemonchiffon) >>
        wrap_transformer o-- SigCopy

    package {
        SmartTransformer <|-- Cleaner
        SmartTransformer <|-- Engineerer
        SmartTransformer <|-- Scaler
        SmartTransformer <|-- Imputer
        SmartTransformer <|-- CategoricalEncoder
        SmartTransformer <|-- TextEncoder
        SmartTransformer <|-- Reducer

    package foreshadow.transformers.internal {
        class FancyImpute
        class UncommonRemover
        class BoxCox

        FancyImpute o-- Imputer
        CategoricalEncoder o-- UncommonRemover
        Scaler o-- BoxCox

        class DaysSince
        class NumericalFeatuerizer
        class CategoricalFeatuerizer

        Engineerer o-- DaysSince
        Engineerer o-- NumericalFeaturizer
        Engineerer o-- CategoricalEncoder

        class ToString
        class SplitDate
        class FinancialCleaner

        Cleaner o-- ToString
        Cleaner o-- SplitDate
        Cleaner o-- FinancialCleaner

        class Boruta
        class Hypothesis

        Reducer o-- Boruta
        Reducer o-- Hypothesis

    package foreshadow.transformers.external {
        note "All sklearn transformers are mirrored\nand pandas wrapped here." as N3

    ' <|-r- foreshadow.transformers.internal

package foreshadow.config {
    class ConfigManager {
        json framework_config
        json user_config
        json local_config

package foreshadow.tuners {
    class TunerWrapper {
        BaseEstimator tuner_type
package foreshadow.core {
    abstract class BaseFeatureMapper {

    class Foreshadow
    class DataPreparer {
        bool is_y_var
    class FeatureCleaner
    class IntentResolver
    class FeatureEngineerer
    class FeaturePreprocessor
    class FeatureReducer

    class ColumnInfoSharer

    class SerializerMixin << (X,peru) >>

    Foreshadow "0..2" o-- DataPreparer
    Foreshadow "0..1" o-- sklearn.RandomizedSearchCV

    DataPreparer o-- FeatureCleaner
    DataPreparer o-- IntentResolver
    DataPreparer "0..1" o-- FeatureEngineerer
    DataPreparer o-- FeaturePreprocessor
    DataPreparer "0..1" o-- FeatureReducer

    SerializerMixin <|-- DataPreparer
    SerializerMixin <|-- FeatureCleaner
    SerializerMixin <|-- IntentResolver
    SerializerMixin <|-- FeatureEngineerer
    SerializerMixin <|-- FeaturePreprocessor
    SerializerMixin <|-- FeatureReducer

    BaseFeatureMapper <|-- DataPreparer
    BaseFeatureMapper <|-- FeatureCleaner
    BaseFeatureMapper <|-- IntentResolver
    BaseFeatureMapper <|-- FeatureEngineerer
    BaseFeatureMapper <|-- FeaturePreprocessor
    BaseFeatureMapper <|-- FeatureReducer    
package foreshadow.estimators {
    class MetaEstimator
    class AutoEstimator

    MetaEstimator "0..1" o-- AutoEstimator
    MetaEstimator o-- DataPreparer

    Foreshadow "0..1" o-- MetaEstimator
package sklearn.base {
    class TransformerMixin << (X,peru) >>
    class BaseEstimator


UML Sequence Diagrams

Main Sequence Diagram


skinparam Shadowing false

participant User

User -> Foreshadow: ~__init__()

note over Foreshadow, DataPreparer
    Foreshadow and DataPreparer
    are wrappers for an sklearn
    Pipeline. Fit and transform
    calls originate from sklearn
    logic and not the objects
end note

note over Foreshadow
    shadow.steps = Pipeline([
        ('t', DataPreparer()),
        ('m', LogisticRegression()),
end note

note over DataPreparer
    ci = ColumnInfoSharer()
    dp.steps = Pipeline([
        ('c', FeatureCleaner(share=ci)),
        ('i', IntentResolver(share=ci)),
        ('e', FeatureEngineerer(share=ci)),
        ('p', FeaturePreprocessor(share=ci)),
        ('r', FeatureReducer(share=ci)),
end note

User -> Foreshadow: fit(X, y)
Foreshadow -> DataPreparer: fit(X, y)

DataPreparer -> ColumnInfoSharer: ~__init__()

DataPreparer -> FeatureCleaner: fit_transform(X, y)
FeatureCleaner -> ColumnInfoSharer: set_info(column, 'tags', values)
FeatureCleaner --> DataPreparer: X

DataPreparer -> IntentResolver: fit_transform(X, y)
IntentResolver -> ColumnInfoSharer: set_info(column, 'intent', value)
IntentResolver --> DataPreparer: X

DataPreparer -> FeatureEngineerer: fit_transform(X, y)
FeatureEngineerer -> ColumnInfoSharer: get_info(column, 'tags')
return col_tag_list
FeatureEngineerer --> DataPreparer: X

DataPreparer -> FeaturePreprocessor: fit_transform(X, y)
FeaturePreprocessor -> ColumnInfoSharer: get_info(column, 'intent')
return col_intent
FeaturePreprocessor --> DataPreparer: X

DataPreparer -> FeatureReducer: fit_transform(X, y)
FeatureReducer -> ColumnInfoSharer: get_info(column, 'intent')
return col_intent
FeatureReducer --> DataPreparer: X

Foreshadow -> LogisticRegression: fit(X, y)

LogisticRegression -> Foreshadow: self


Hyperparameter Optimization Sequence Diagram


skinparam BackgroundColor transparent
skinparam Shadowing false

participant User

User -> Foreshadow: ~__init__()

note over Foreshadow
    pipeline = Pipeline([
        ('dp', DataPreparer()),
        ('lr', LogisticRegression()),
end note

Foreshadow -> TunerWrapper: ~__init__(pipeline, RandomizedSearchCV)

User -> Foreshadow: fit(X, y)
Foreshadow -> TunerWrapper: fit(X, y)
TunerWrapper -> RandomizedSearchCV ++: fit_pipelines(X, y)
return best_pipeline
TunerWrapper -> RandomizedSearchCV ++: fit_params(X, y)
return best_pipeline_params

TunerWrapper --> Foreshadow: self
Foreshadow --> User: self