danubePrediction

Once a rules-set is defined you can start using the danube.ai prediction service which is provided via the danubePrediction method by the DanubeClient class. danubePrediction will send a request with your dataset to danube.ai and returns the evaluation results including a new scoring for columns and rows and a list of derived percentage matches per row.

Method

Below, the method's header is shown, as it is provided by DanubeClient.

/*
 * Performs a danube.ai prediction for the specified data and settings.
 *
 * @param rulesId: The id of a set of rules.
 * @param data: A stringified Json-Array, holding all data elements (rows) as objects.
 * @param searchData: A stringified Json-Object with the same structure as a data element.
 * @param initialColumnScores: An array of initial column names and scores (see interface below).
 * @param strategy: Defines the way data attributes are treated by the algorithm. The following options are available:
 *                  - "exclusive": Rare data attributes tend to obtain more weight.
 *                  - "fair": Overly rare or overly frequent data attributes lose weight.
 *                  - "mixed": Mixes "exclusive" and "fair" strategy (see mixFactor).
 *                  - "inverse": Inverse behavior of "fair" strategy.
 * @param mixFactor: The factor to mix "exclusive" and "fair" strategies (Float between 0 and 1; only for "mixed" strategy.):
 *                   0 (= exclusive) ----------x---------- 1 (= fair)
 * @param impact: Determines how strongly the initial column values are changed. n=1 means one run of the algorithm with small changes to the initial values. Higher values of n mean iterative runs of the algorithm with stronger changes.
 * 
 * @returns a set of new column- and row-scores as well as matches (see interface below).
 */
public async danubePrediction(
  rulesId: string,
  data: string,
  searchData: string,
  initialColumnScores: COLUMN_SCORE[],
  strategy: 'exclusive' | 'fair' | 'mixed' | 'inverse',
  mixFactor: number,
  impact: number,
): Promise<DANUBE_PREDICTION_RESULT | null> {
  ...
}

/*
 * A ColumnScore maps a column (property) to a score.
 *
 * @field property: The name of a property.
 * @field type: The property's score.
 */
interface COLUMN_SCORE {
  property: string;
  score: number;
}

/*
 * The result of a 'danubePrediction' call.
 *
 * @field newColumnScores: An array of new column scores.
 * @field rowScores: An array of row scores (same ordering as the 'data' elements in the request), each determined by danube.ai. The row scores define the sorting (highest score = best row).
 * @field rowMatches: An array of row matches (same ordering as the 'data' elements in the request), each being an array of percentage values, describing how well a property value matches the best data value in this column.
 */
interface DANUBE_PREDICTION_RESULT {
  newColumnScores: COLUMN_SCORE[],
  rowScores: number[],
  rowMatches: number[][],
}

You can see an example on how to encode your data as a json array here.