Start forecasting

Use your historic attendance data to generate AI-driven forecasts for people, teams, and locations, helping predict future space needs.

Prerequisites

  • Completed Add historic attendance (including session finish if you batched)

  • Node.js v18+ and npm v9+

  • A valid gospace API key in your .env file

  • At least one populated location with historic occupancy data

Note: Any fields ending with _inc include adjustments for minimum targets, people intentions (bookings), and contingencies.


1) Trigger a forecast run

If your project is configured for automatic rebuilds, you can skip this step. Otherwise, trigger forecasting explicitly.

Create start-forecast.ts:

import "dotenv/config";
import GospaceAI from "@gospace-ai/api";

async function main() {
  const gospace = new GospaceAI(process.env.GOSPACE_API_KEY!);

  // Kick off a forecast rebuild for a location and optional date range
  const res = await gospace.system.startForecast({
    location_id: "68499cf4af8729934aae208a",
    // Optional time window. If omitted, backend will choose sensible defaults.
    // starts_at: "2025-06-20T00:00:00Z",
    // ends_at: "2025-07-31T23:59:59Z",
    // Optional control flags
    // force_rebuild: true
  });

  console.log(JSON.stringify(res.data, null, 2));
  // Expect a job or task identifier you can poll
}

main().catch((err) => {
  console.error("Start forecast failed:", err);
  process.exit(1);
});

2) (Optional) Poll job status

If startForecast returns a job, poll until it’s complete.


3) Fetch forecasts

A) People forecast (per person, optionally scoped to team)

Create get-people-forecast.ts:

B) Team forecast (aggregated by team)

Create get-team-forecast.ts:

C) Location forecast (location‑level totals)

Create get-location-forecast.ts:


4) Turn forecasts into capacity requirements

Daily desk and room requirements (using *_inc)

Aggregating per‑team to size team neighborhoods

Checking person‑level confidence

Use people forecasts to validate outliers (e.g., unexpected spikes for specific individuals or teams) before making seating or room allocation changes.


Tips

  • Use _inc fields to plan for the real world (targets, bookings, contingencies).

  • Choose consistent day boundaries (starts_at/ends_at) that match your business day/timezone.

  • Use pagination (skip, limit) to iterate long horizons.

  • Rebuild forecasts after significant new history or policy changes (e.g., new minimum targets).

Last updated

Was this helpful?