Module tripleblind.regression_asset

Classes

class PSIVerticalRegressionModel (uuid: UUID)

PSIVerticalRegressionModel(uuid: 'UUID', _accesspoint_filename: 'Optional[str]' = None, _filename: 'Optional[str]' = None, _hash: 'Optional[str]' = None, _name: 'Optional[str]' = None, _namespace: 'Optional[UUID]' = None, _metadata: 'Optional[dict]' = None, _activate_date: 'Optional[dt.datetime]' = None, _deactivate_date: 'Optional[dt.datetime]' = None, _desc: 'Optional[str]' = None, _organization: 'Optional[str]' = None, _organization_id: 'Optional[str]' = None, _is_discoverable: 'bool' = False, _k_grouping: 'Optional[int]' = None)

Ancestors

Static methods

def train(datasets: Union[Asset, List[Asset]], match_column: Union[str, List[str]], regression_type: tb_shared_objects.enums.RegressionType, target: str, preprocessor: Union[preprocessor.tabular.TabularPreprocessor, List[preprocessor.tabular.TabularPreprocessor], preprocessor.tabular.TabularPreprocessorBuilder, List[preprocessor.tabular.TabularPreprocessorBuilder], ForwardRef(None)] = None, learning_rate: Optional[float] = 0.1, job_name: Optional[str] = None, session: Optional[Session] = None) -> Asset

Create a PSIVerticalRegression model trained on the provided dataset(s).

Args

datasets : Union[Asset, List[Asset]]
A dataset Asset (or a list of Assets) to be used in the psi prior to the regression.
match_column : Union[str, List[str]]
Name of the column to match. If not the same in all datasets, a list of the matching column names, starting with the initiator asset and then listing a name in each dataset.
regression_type : RegressionType
Type of regression to be run. Either tb.RegressionType.LINEAR or tb.RegressionType.LOGISTIC
target : str
The name of the target column for the training
preprocessor : Union[TabularPreprocessor, List[TabularPreprocessor]], optional
The preprocessor(s) to use against the datasets. When no preprocessor is specified, the default preprocessor selects all columns.
learning_rate : float, optional
Learning rate for training.
job_name : str, optional
Reference name for this process. This name will appear in the Access Request, Process History, and Audit Reports.
session : Session, optional
A connection session. If not specified, the default session is used.

Raises

TripleblindTrainingError
Model training failed

Returns

Regression Asset
The trained model, or None if training fails.

Inherited members

class Regression (uuid: UUID)

An abstract Regression class for representing a regression model.

Ancestors

Subclasses

Static methods

def cast(asset: Asset) -> Regression

Convert a generic Asset into a Regression

This should only be used on an asset known to be a Regression asset, no validation occurs during the cast.

Args

asset : Asset
A generic Asset

Returns

Regression
A Regression asset object
def find(search: Union[str, re.Pattern, ForwardRef(None)], namespace: Optional[uuid.UUID] = None, owned: Optional[bool] = False, owned_by: Optional[int] = None, session: Optional[Session] = None, exact_match: Optional[bool] = True) -> Optional[Regression]

Search the Router index for an asset matching the given search

Args

search : str or re.Pattern, optional
The search pattern applied to asset names. A simple string will be used as a substring search if exact_match is False, otherwise it will only return exact matches.
namespace : UUID, optional
The UUID of the user to which this asset belongs. None indicates any user, NAMESPACE_DEFAULT_USER indicates the current API user.
owned : bool, optional
Only return owned assets (either personally or by the current user's organization)
owned_by : int, optional
Only return owned assets owned by the given organization ID
session : Session, optional
A connection session. If not specified, the default session is used.
exact_match : bool, optional
When the 'search' is a string, setting this to True will perform an exact match. Ignored for regex patterns, defaults to True.

Raises

TripleblindAssetError
Thrown when multiple assets are found which match the search.

Returns

Regression
A single Regression asset, or None if no match found

Inherited members

class RegressionModel (uuid: UUID)

RegressionModel(uuid: 'UUID', _accesspoint_filename: 'Optional[str]' = None, _filename: 'Optional[str]' = None, _hash: 'Optional[str]' = None, _name: 'Optional[str]' = None, _namespace: 'Optional[UUID]' = None, _metadata: 'Optional[dict]' = None, _activate_date: 'Optional[dt.datetime]' = None, _deactivate_date: 'Optional[dt.datetime]' = None, _desc: 'Optional[str]' = None, _organization: 'Optional[str]' = None, _organization_id: 'Optional[str]' = None, _is_discoverable: 'bool' = False, _k_grouping: 'Optional[int]' = None)

Ancestors

Static methods

def train(datasets: Union[Asset, List[Asset]], regression_type: tb_shared_objects.enums.RegressionType, target: str, model_params: Optional[dict] = None, preprocessor: Union[preprocessor.tabular.TabularPreprocessor, List[preprocessor.tabular.TabularPreprocessor], preprocessor.tabular.TabularPreprocessorBuilder, List[preprocessor.tabular.TabularPreprocessorBuilder], ForwardRef(None)] = None, job_name: Optional[str] = None, test_size: Optional[float] = 0.0, data_scale_factor: Optional[int] = 1, weight_scale_factor: Optional[int] = 1, minimum_data_value: Optional[int] = 1, minimum_weight_value: Optional[int] = 1, session: Optional[Session] = None) -> Asset

Create a Regression model trained on the provided horizontal dataset(s).

Args

datasets : Union[Asset, List[Asset]]
A dataset Asset (or a list of Assets) used to train the regression.
regression_type : RegressionType
Type of regression to be run. One of: tb.RegressionType.LINEAR, LOGISTIC, LASSO, RIDGE
target : str
The name of the target column for the training
model_params : dict, optional

Model parameters specific to regression_type used. Available regression algorithms with usable params:

LinearRegression - https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html

LogisticRegression - https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html

Lasso - https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Lasso.html

Ridge - https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html

preprocessor : Union[TabularPreprocessor, List[TabularPreprocessor]], optional
The preprocessor(s) to use against the datasets. When no preprocessor is specified, the default preprocessor selects all columns.
job_name : str, optional
Reference name for this process. This name will appear in the Access Request, Process History, and Audit Reports.
test_size : float, optional
test size used for training
data_scale_factor : int, optional
data scale factor used for training
weight_scale_factor : int, optional
weight scale factor used for training
minimum_data_value : int, optional
minimum data value used for training
minimum_weight_value : int, optional
minimum weight value used for training
session : Session, optional
A connection session. If not specified, the default session is used.

Raises

TripleblindTrainingError
Model training failed

Returns

Regression Asset
The trained model.

Inherited members