Created
September 21, 2023 02:50
-
-
Save 0xF6/6fe1e8c2a95342fbf237c684f39cea4c to your computer and use it in GitHub Desktop.
Code for getting interpolated creation date by telegram id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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