This is where I usually draw the line at the "everything is a service" world view. It is much better to provide this as a library than as a service, particularly algorithms that run across large data sets.
However, the exception I see to this is a service that applies the algorithm across a large dataset that is owned by the service. An example of this is geocoding, where you probably don't want to store the addresses of everyone in the world in your database, but it is easy to reach out to a range of providers to get latitude longitude for your address.