VOOZH about

URL: https://www.nuget.org/packages/ETAPredictor/

⇱ NuGet Gallery | ETAPredictor 1.0.3




ETAPredictor 1.0.3

dotnet add package ETAPredictor --version 1.0.3
 
 
NuGet\Install-Package ETAPredictor -Version 1.0.3
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ETAPredictor" Version="1.0.3" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ETAPredictor" Version="1.0.3" />
 
Directory.Packages.props
<PackageReference Include="ETAPredictor" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ETAPredictor --version 1.0.3
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ETAPredictor, 1.0.3"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ETAPredictor@1.0.3
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ETAPredictor&version=1.0.3
 
Install as a Cake Addin
#tool nuget:?package=ETAPredictor&version=1.0.3
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

ETAPredictor

Predict ETA of vehicles as they travel to stops on routes that generally repeat. Suitable for busses/shuttles on campuses, at airports, etc...

Provide the location of known stops, along with live (or historical) GPS data from vehicles, and the model will provide a table of ETAs for each stop.

The model is intended to be very lightweight in terms of compute, eschewing processing heavy AI for a simple statistical approach based on historical ETA based on current vehicle location. It knows nothing about roads or traffic and does not rely on any external data feeds. ""Roads?! Where we're going, we don't need [to know about] roads!""

It also takes into account current speeds compared to historical speeds so that things like traffic are (naively) taken into account. Data older than 5 days is automatically purged so the model only grows to a point and does not consume more and more memory over time.

Example:


var stops = new List<GPSData>() { 

	new GPSData() { Latitude = 32.432432, Longitude = -71.2344, IdentifiedAsStopName="Bus Stop 1" },

	new GPSData() { Latitude = 32.342432, Longitude = -71.5444, IdentifiedAsStopName="Bus Stop 2" },

};

var model = new ETAPRedictor.RoutesModel(stops);

//for each data point we recieve, we integrate it into the model:

model.IntegrateDataPointIntoModel(<data from GPS tracker>);

//we can request an ETA table at any time:

model.GetETATable();

//Returns:

[

{StopName: "Bus Stop 1", ETA: 5 min, Serial: "Bus 1"},

{StopName: "Bus Stop 2", ETA: 10 min, Serial: "Bus 1"},

]

Saving the model

The RoutesModel provides LoadFromJSON and SaveToJSON methods, so you can save your model as you integrate more data into it and make your predictions available upon service restart.

Save the JSON to a cloud storage blob or local filesystem.

Simulation Mode

By default, the model will use the current UTC DateTime in making predictions, assuming that the data you are feeding it is being provided in real time. For testing purposes, you may enable simulation mode:


var model = new ETAPRedictor.RoutesModel(stops, true); //second param sets simulationMode = true


//before integrating a data point, or requesting an ETATable, set the current time of your simulation


model.CurrentTime = <your simulation time>;

model.IntegrateDataPointIntoModel(<point>);



//...


model.CurrentTime = <your simulation time>;

model.GetETATable();

Known Issues

ETA table will include null times if no statistically relevant data points exist to make a prediction. As you feed more data into the model this should go away. It's best to collect data for a few days and save your model before making the predictions live.

Predictions can jump around a bit... this model makes no attempt at smoothing. It's recommended that you implement some kind of smoothing or averaging of predictions if this will be jarring to your users. You could have a countdown clock that only resets when the predictions become shorter over time, or subtly speeds up or slows down based on moving averages. I believe these choices are best left to the UI and not the backend, so I have no plans to implement smoothing. Reach out to me if you feel differently!

Planned improvements

We currently match historical data points based on location alone. Currently it operates by assuming that the most recent data points are most relevant, so if there's a slowdown over a long period of time, the system will adjust. But a short term slowdown will cause the model to be wrong both as it slows down and as it speeds up again.

If we incorporated time of day, day of week, speed and other variables into how we match our statistically relevant historical ETAs, the model should become more accurate.

However, this is meant to be a lightweight in-memory model that does not require a database or significant compute or memory, so to achieve this more sophisticated mode of operation, we will need to begin aggregating statistics within the model... collapsing similar datapoints essentially.

So my next planned steps will be to bucket historical datapoints where the ETA, speed, day and time of day, and position are similar, and then alter the calculations to use those buckets instead.

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 is compatible.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 is compatible. 
.NET Framework net46 net46 is compatible.  net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 970 12/28/2022
1.0.2 452 12/28/2022
1.0.1 460 12/27/2022
1.0.0 453 12/23/2022

Bug fixes and tweaks: thread safety, serialization, error handling, returns 0 instead of TimeSpan.MinValue when departing/arriving (near a stop).