Skip to content

Instantly share code, notes, and snippets.

@0xF6
Created September 21, 2023 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xF6/6fe1e8c2a95342fbf237c684f39cea4c to your computer and use it in GitHub Desktop.
Save 0xF6/6fe1e8c2a95342fbf237c684f39cea4c to your computer and use it in GitHub Desktop.
Code for getting interpolated creation date by telegram id
using Python.Runtime;
PythonEngine.Initialize();
using var _ = Py.GIL();
var np = Py.Import("numpy");
var polyfit = np.polyfit;
var poly1d = np.poly1d;
// define knows creation date for interpolation
var dic = new Dictionary<long, DateTimeOffset>()
{
{ tgId, DateTime.Parse("creationDatePoint") },
// ...
};
var beta = dic.ToDictionary(
x => (double)x.Key,
x => (double)x.Value.ToUnixTimeSeconds());
var interpolator = poly1d(polyfit(beta.Keys.ToArray(), beta.Values.ToArray(), dic.Count));
var telegramCreationDate = DateTimeOffset.FromUnixTimeSeconds((long)Math.Floor((double)interpolator(requestedTelegramId)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment