Spavik
GuidesWork with your data

Prepare your data

Structure your dataset, choose the target and check data quality before training or forecasting.

What Spavik expects, and what it refuses.

The minimum

ConstraintValue
Rows to evaluate or train100 at least; under 200, the evaluation warns
Distinct values in the target2 at least
Feature columns30 at most on public plans, target excluded
Context rows1,000 on Free, 2,000 on paid plans; extra rows are sampled

Keep only the fields available at the prediction moment. The column limit applies to evaluation and training alike: a wider table is refused with 400 TOO_MANY_COLUMNS and nothing is created. Rows beyond the context limit are not refused: the engine learns from a random sample of them. Read the current values in limits.max_feature_columns and limits.max_context_rows of GET /v1/plans.

Below 100 rows, the evaluation's validation reports too_few_rows and no trial runs; training is refused with 422 VALIDATION_FAILED. The libraries check training row counts and target constraints locally, so a file that is too short costs neither a credit nor a round trip.

Accepted formats

Both SDKs accept CSV files, JSON files, arrays of row objects and raw CSV text. Python also accepts pandas DataFrames. REST accepts a multipart CSV file or a JSON body with a data array. Use the sample dataset to follow this example, after configuring your client.

model = spavik.train("churn.csv", target="churn")
print(model.id)

The separator is detected (comma, semicolon, tab, pipe), quotes are handled, and numbers get their type back along the way: a "12" read from a CSV becomes an integer. Only plain decimal notation becomes a number: 1.5 does, while 1,5 with a decimal comma, 007 with a leading zero, true and false stay text. Convert decimal commas before sending a file, or the column is read as text. Spaces around header names are removed.

Calling the API directly, you can send JSON in data, or a file as multipart/form-data on POST /v1/models, POST /v1/forecast and POST /v1/models/{id}/predict. The latter avoids serialising a large dataset into a JSON body.

Check before training

Use POST /v1/datasets/evaluate, or the SDK's evaluate method. The operation is free and returns structural validation, a trial and an assessment.

report = spavik.evaluate("churn.csv", target="churn")
print(report["assessment"])
print(report.get("validation"))

Choose which columns to keep

Add explain to the evaluation to rank every feature column. The response then carries trial.feature_importance, from the most useful column to the least useful one. Each importance is how much the trial score drops when the values of that column are shuffled. A value near zero means the trial did not rely on the column. Two closely related columns share their importance, so both can look weak while either one alone would matter. Start from the business meaning of each column, then use this ranking to decide what to drop.

The ranking runs one extra prediction per column, so the call takes longer on wide tables. Training does not compute it.

report = spavik.evaluate("churn.csv", target="churn", explain=True)
print(report["trial"]["feature_importance"])

Read the evaluation guide before choosing the next step. The trial splits rows randomly and does not provide time or group split controls. A high score is not proof of leakage, and an unimproved score is not proof that no signal exists. Avoid repeatedly optimizing fields against the same test score.

Prepare for the prediction moment

Define what one row represents, the observed target, when a prediction will be requested and which fields are available then. Keep matching-only identifiers outside the feature table. Exclude fields filled in after the outcome; construct joins, aggregates and lags using only information known at each historical cutoff. Do not invent missing labels. Preserve a recipe and use it for later predictions. Learn preprocessing only on training partitions, then apply it to held-out data.

Missing values

An empty cell becomes null, and the engine copes. A row whose target is empty, however, teaches nothing: if too many of your rows are in that state, the library says so rather than letting training run on almost nothing.

NaN values from a pandas DataFrame are converted to null automatically, and date columns are accepted.

Column names

The columns you send to predict must carry the same names as at training, minus the target. A mismatch gives COLUMN_MISMATCH or SCHEMA_MISMATCH. A model remembers them: feature_columns on GET /v1/models/{id}, model.features in the libraries.

If you get the target name wrong, the library suggests the closest column:

SpavikDataError: the target column 'churn_90d' is missing from the data.
                 Columns found: plan, seats, tickets_90d, churn. Did you mean 'churn'?

Size limits

The API refuses beyond these thresholds, with an explicit code:

CodeLimit
TOO_MANY_COLUMNS30 feature columns on public plans, target excluded (limits.max_feature_columns)
TOO_MANY_ROWS1,000 rows per prediction call (limits.max_predict_rows)
DATASET_TOO_LARGE50,000 rows per request, on every plan
FILE_TOO_LARGE25 MB per uploaded file, on every plan
CSV_UNREADABLEthe CSV could not be parsed

Plan values come from GET /v1/plans, and each error message states the limit reached.

For a time series

forecast additionally needs:

  • a value column (target), numeric;
  • a timestamp column (timestamp), optional but recommended;
  • a series identifier column (item_id) if your file holds several series, one per store or per product for instance.

Your series must have at least as many points as the requested horizon, and preferably several times more. Three points for a horizon of fourteen produces nothing usable, and the library refuses it before the call.

Cost is the requested horizon per call, regardless of the number of series or the length of the history. See Costs and credits.

Sort timestamps within each series and use one observed value per timestamp. Resolve duplicates and gaps according to the data's meaning; missing is not necessarily zero. Do not fabricate history or append blank future rows.

Monthly series must use month-start or month-end timestamps. Other fixed days, including dates clamped to the end of a short month, are unsupported. All series must share the same frequency and calendar anchor, evaluated in UTC. Do not silently move dates to satisfy these requirements.

Before paying, POST /v1/forecast/backtest validates and replays history. Match the intended forecast's horizon, point estimate, quantiles and column roles. For multiple series, use long format and assess history separately for each one. The required references are the naive forecast and a historical-median constant. Read the evaluation guide for MASE weighting and exclusions.

How is this guide?

Last updated on

On this page