Enacting Recommendation

The Enacting Recommendation feature allows you to put Sanatio's recommendation into practice by creating a new model with the recommended changes.

A comparison markdown report is generated which indicates the improvements in the performance of the model before and after enacting the recommendations and stores the new model in the object's model attribute.

How to access the feature?

from sanatio.validations.sanatio_enact import enact

enact_object = enact(...parameters...)

Parameters required for initialization

Enact types

The different enact types implements recommendation as per the different routines validation type we have in Sanatio.

The different types of enact that are available in Sanatio with respective function are

  • Logistic enact

    • logistic_enact()

  • Linear enact

    • linear_enact()

  • Tree classification enact

    • tree_classification_enact()

How to enact recommendation?

from sanatio.validations.sanatio_enact import enact

enact_object = enact(...parameters...)
enact_object.logistic_enact()

Example

from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
import pandas as pd
from sklearn.linear_model import LogisticRegression

data = load_breast_cancer()
X,y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)

lr =LogisticRegression()
lr.fit(X_train,y_train)
prediction = lr.predict(X_test)
one_class = lr.predict_proba(X_test)[:,1]
two_class = lr.predict_proba(X_test)
from sanatio.validations.sanatio_enact import enact

enact_obj = enact(X_train= pd.DataFrame(X_train,columns=data.feature_names),
                  y_train = y_train,
                  X_test = pd.DataFrame(X_test,columns=data.feature_names),
                  y_test = y_test,
                  model = lr, pearson_threshold = 0.9, vif_factor = 500
                 )
enact_obj.logistic_enact()

Last updated