AutoML
Use PDI + H2O AutoML in Colab to prototype a credit-card fraud model.

Run through the following steps to determine the best ML model for the dataset:
H2O
So, what does the data scientist do at this point?
Typically, they will want to get a feel for the data by examining simple summary statistics and visualizations, followed by applying quick techniques for assessing the relationship between individual attributes (fields) and the target of interest which, in this example, is the reported_as_fraud_historic field.
Following that, if there are attributes that look promising, quick tests with common supervised classification algorithms will be next on the list. This comprises the initial stages of experimental data mining – that is, the process of determining which predictive techniques are going to give the best result for a given problem.
Create the H2O dataset
Run the transformation: autoML.ktr
Preview the results:
data/H2O.csv

Connect a runtime
Connect to a hosted runtime.

Upload the notebook
In Colab, select File > Upload notebook.
Upload:
~/Workshop--Data-Integration/Labs/Module 7 - Use Cases/Machine Learning/AutoML/data/credit_card_fraud.ipynb

Upload the dataset
When the notebook prompts for a file upload, upload H2O.csv. Create it by running autoML.ktr in PDI.
AutoML Script
These are the code sections for the Jupyter file: credit_card_fraud.ipynb:
Install the h2o libraries:
Import libraries:
Upload data:

Load data:
Distribution check:
Convert to H2O frame:
Run Models (Top 5)
Configuration explained:
max_models=5: keeps runtime short.max_runtime_secs=900: hard stop at 15 minutes.balance_classes=True: important for imbalanced fraud data.nfolds=5: cross-validation for more stable metrics.sort_metric='AUC': simple default ranking metric.
Model Leaderboard:
Get Best Model:
Confusion Matrix:
Feature Importance:
Save Model:
Summary Report:
Python Executor
The Python Executor step lets you run Python code as part of a Pentaho Data Integration (PDI) transformation.
This step is designed to help developers and data scientists focus on Python-based analytics and algorithms while using PDI for common ETL work such as connecting to sources, joining, and filtering.
You can run Python with either:
Row-by-row processing: PDI maps each incoming row to Python variables and runs the script once per row.
All-rows processing: PDI transfers the full dataset at once (for example, into a pandas DataFrame) and runs the script.
This step supports the CPython runtime only.
For further details:
Click the Input tab.
Map PDI fields into Python variables.
Use All rows for DataFrames. It processes the full dataset at once.
Select All rows to process all data at once (for example, when passing a list of dicts).
Available variables
Use the plus sign button to add a Python variable to the input mapping for the script used in the transformation. You can remove the Python variable by clicking the X icon.
Variable name
Enter the name of the Python variable. The list of available variables will update automatically.
Step
Specify the name of the input step to map from. It can be any step in the parent transformation with an outgoing hop connected to the Python Executor step.
Data structure
Specify the data structure from which you want to pull the fields for mapping. You can select one of the following:
· Pandas data frame: the tabular data structure for Python/Pandas.
· NumPy array: the table of values, all the same type, which is indexed by a tuple of positive integers.
· Python List of Dictionaries: each row in the PDI stream becomes a Python dictionary. All the dictionaries are put into a Python list.
In Mapping, configure these fields:
Data structure field
The value of the Python data structure field to which you want to map the PDI field.
Data structure type
The value of the data structure type assigned to the data structure field to which you want to map the PDI field.
PDI field
The name of the PDI field which contains the vector data stored in the mapped Python variable.
PDI data type
The value of the data type assigned to the PDI field, such as a date, a number, or a timestamp.
Gradient Boosting Machine
Gradient Boosting Machine (GBM) is an ensemble learning algorithm that builds a series of weak decision trees sequentially, where each new tree focuses on correcting the errors made by the previous ones. The final prediction is a weighted combination of all these trees, resulting in a highly accurate model.
In fraud detection, GBM is particularly effective because it handles the inherent class imbalance (fraud being rare compared to legitimate transactions) and can capture complex, non-linear patterns in transaction data - such as unusual spending amounts, atypical merchant categories, or irregular timing - that simple rule-based systems would miss.
It also provides feature importance rankings, allowing analysts to understand which variables (e.g., transaction velocity, geolocation mismatches, or device fingerprints) are the strongest indicators of fraudulent behavior, making the model both powerful and interpretable for investigation teams.

Install GBM
Execute the following script to install GBM.

Verify.
Last updated
Was this helpful?





