Skip to content

Add tabular preprocessing - #1094

Open
ahzero7d1 wants to merge 6 commits into
mainfrom
tabular-preprocessing
Open

ahzero7d1 wants to merge 6 commits into
mainfrom
tabular-preprocessing

Conversation

@ahzero7d1

@ahzero7d1 ahzero7d1 commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

Initial implementation of tabular data preprocessing

Closes #1062, fixes #1063

Changes

  • Add validation on the web app side to reject datasets containing: nan values, empty strings
  • Implement standardization for numerical features
  • Store standardization metadata as part of model serialization

TODO

  • Add one-hot-encoding for non-numerical features

@ahzero7d1 ahzero7d1 changed the title Tabular preprocessing Add tabular preprocessing Mar 31, 2026
@JulienVig
JulienVig self-requested a review September 11, 2026 15:21

@JulienVig JulienVig left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing things required before merging (for me to handle):

  • Use metadata statistics during model validation
  • Current titanic sample csv is rejected by webapp because of missing data
  • Standardization is done locally. This can lead to different weight scales between clients. Should the standardization statistics be averaged by the server?
  • Unit tests for new tabular preprocessing functions
  • Validate CSV right away when connecting it
  • update docs/examples/custom_task.ts

for (const col of columns){
const values = rows.map((row)=> {
const rawValue = extractColumn(row, col);
return convertToNumber(rawValue !== "" ? rawValue : "0");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: prompt users to choose missing data imputation method

}

// If the column is numerical column, apply standardization
const value = convertToNumber(raw !== "" ? raw : "0");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default missing data imputation

tabularStandardization: stats,
};

const preprocessed = processing.preprocess(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.preprocessOnce is ignored here

let preprocessed = processing.preprocess(this.#task, dataset);
if (validationSplit === 0){
if (this.#task.dataType === "tabular"){
const rows = await arrayFromAsync(dataset as Dataset<DataFormat.Raw["tabular"]>);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we read throught the whole dataset. Therefore this.preprocessOnce is ignored=false for tabular dataset. This is fine but we might as well take advantage of this and keep the dataset cached rather than discard it and read it again during training

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extractToNumbers is not used anymore

// TODO totally unsafe casting
rawModel as tf.io.ModelArtifacts,
// metadata for tabular task standardization
rawMetadata as ModelMetadata,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement more checks before casting. msgpack potentially returns null instead of undefined when the field is missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tabular data NaN processing tabular data preprocessing improvements

2 participants