{"id":16226828,"url":"https://github.com/c0bra/dtpredict","last_synced_at":"2025-04-08T04:06:01.052Z","repository":{"id":613319,"uuid":"251400","full_name":"c0bra/dtpredict","owner":"c0bra","description":"DateTime::Event::Predict - Predict dates in perl","archived":false,"fork":false,"pushed_at":"2012-03-12T16:16:29.000Z","size":544,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-14T03:14:45.013Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/c0bra.png","metadata":{"files":{"readme":"README","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-07-15T00:30:28.000Z","updated_at":"2014-09-08T20:20:43.000Z","dependencies_parsed_at":"2022-07-05T03:31:03.133Z","dependency_job_id":null,"html_url":"https://github.com/c0bra/dtpredict","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c0bra%2Fdtpredict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c0bra%2Fdtpredict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c0bra%2Fdtpredict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c0bra%2Fdtpredict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c0bra","download_url":"https://codeload.github.com/c0bra/dtpredict/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773731,"owners_count":20993634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T12:50:35.444Z","updated_at":"2025-04-08T04:06:01.030Z","avatar_url":"https://github.com/c0bra.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n    DateTime::Event::Predict - Predict new dates from a set of dates\n\nSYNOPSIS\n    Given a set of dates this module will predict the next date or dates to\n    follow.\n\n      use DateTime::Event::Predict;\n\n      my $dtp = DateTime::Event::Predict-\u003enew(\n          profile =\u003e {\n              buckets =\u003e ['day_of_week'],\n          },\n      );\n\n      # Add today's date: 2009-12-17\n      my $date = new DateTime-\u003etoday();\n      $dtp-\u003eadd_date($date);\n\n      # Add the previous 14 days\n      for  (1 .. 14) {\n          my $new_date = $date-\u003eclone-\u003eadd(\n              days =\u003e ($_ * -1),\n          );\n\n          $dtp-\u003eadd_date($new_date);\n      }\n\n      # Predict the next date\n      my $predicted_date = $dtp-\u003epredict;\n\n      print $predicted_date-\u003eymd;\n\n      # 2009-12-18\n\n    Here we create a new \"DateTime\" object with today's date (it being\n    December 17th, 2009 currently). We then use add_date to add it onto the\n    list of dates that \"DateTime::Event::Predict\" (DTP) will use to make the\n    prediction.\n\n    Then we take the 14 previous days (December 16-2) and them on to same\n    list one by one. This gives us a good set to make a prediction out of.\n\n    Finally we call predict which returns a \"DateTime\" object representing\n    the date that DTP has calculated will come next.\n\nHOW IT WORKS\n    Predicting the future is not easy, as anyone except, perhaps,\n    Nostradamus will tell you. Events can occur with perplexing randomness\n    and discerning any pattern in the noise is nigh unpossible.\n\n    However, if you have a set of data to work with that you know for\n    certain contains some sort of regularity, and you have enough\n    information to discover that regularity, then making predictions from\n    that set can be possible. The main issue with our example above is the\n    tuning we did with this sort of information.\n\n    When you configure your instance of DTP, you will have to tell what\n    sorts of date-parts to keep track of so that it has a good way of making\n    a prediction. Date-parts can be things like \"day of the week\", \"day of\n    the year\", \"is a weekend day\", \"week on month\", \"month of year\",\n    differences between dates counted by \"week\", or \"month\", etc. Dtpredict\n    will collect these identifiers from all the provided dates into\n    \"buckets\" for processing later on.\n\nEXAMPLES\n    Predicting Easter\n    Predicting\n\nMETHODS\n  new\n    Constructor\n\n            my $dtp = DateTime::Event::Predict-\u003enew();\n\n  dates\n    Arguments: none | \\@dates\n\n    Return value: \\@dates\n\n    Called with no argument this method will return an arrayref to the list\n    of the dates currently in the instance.\n\n    Called with an arrayref to a list of DateTime objects (\"\\@dates\") this\n    method will set the dates for this instance to \"\\@dates\".\n\n  add_date\n    Arguments: $date\n\n    Return value:\n\n    Adds a date on to the list of dates in the instance, where $date is a\n    DateTime object.\n\n  profile\n    Arguments: $profile\n\n    Set the profile for which date-parts will be\n\n      # Pass in preset profile by name\n      $dtp-\u003eprofile( profile =\u003e 'default' );\n      $dtp-\u003eprofile( profile =\u003e 'holiday' );\n\n      # Create a new profile\n      my $profile = new DateTime::Event::Predict::Profile(\n          buckets =\u003e [qw/ minute hour day_of_week day_of_month /],\n      );\n\n      $dtp-\u003eprofile( profile =\u003e $profile );\n\n   Provided profiles\n    The following profiles are provided for use by-name:\n\n  predict\n    Arguments: %options\n\n    Return Value: $next_date | @next_dates\n\n    Predict the next date(s) from the dates supplied.\n\n      my $predicted_date = $dtp-\u003epredict();\n\n    If list context \"predict\" returns a list of all the predictions, sorted\n    by their probability:\n\n      my @predicted_dates = $dtp-\u003epredict();\n\n    The number of prediction can be limited with the \"max_predictions\"\n    option.\n\n    Possible options\n\n      $dtp-\u003epredict(\n          max_predictions =\u003e 4, # Once 4 predictions are found, return back\n          callbacks =\u003e [\n              sub { return ($_-\u003esecond % 4) ? 0 : 1 } # Only predict dates with second values that are divisible by four.\n          ],\n      );\n\n    max_predictions\n        Maximum number of predictions to find.\n\n    callbacks\n        Arrayref of subroutine callbacks. If any of them return a false\n        value the date will not be returned as a prediction.\n\n  train\n    Train this instance of DTP\n\nTODO\n    *   It would be be cool if you could pass your own buckets in with a\n        certain type, so you could, say, look for recurrence based on\n        intervals of 6 seconds, or 18 days, whatever.\n\n    *   We need to be able to handle recording more than one interval per\n        diff. If the dates are all offset from each other by 1 day 6 hours\n        (May 1, 3:00; May 2, 6:00), we can't be predicting a new date that's\n        exactly 1 day after the most recent one. ^ The best way to do this\n        is probably to record intervals as epoch seconds, so everything is\n        taken into account. Maybe record epoch seconds in addition to whole\n        regular intervals like days \u0026 hours.\n\nAUTHOR\n    Brian Hann, \"\u003cbrian.hann at gmail.com\u003e\"\n\nBUGS\n    Please report any bugs or feature requests to\n    \"bug-datetime-event-predict at rt.cpan.org\", or through the web\n    interface at\n    \u003chttp://rt.cpan.org/NoAuth/ReportBug.html?Queue=DateTime-Event-Predict\u003e.\n    I will be notified, and then you'll automatically be notified of\n    progress on your bug as I make changes.\n\nSUPPORT\n    You can find documentation for this module with the perldoc command.\n\n        perldoc DateTime::Event::Predict\n\n    You can also look for information at:\n\n    *   RT: CPAN's request tracker\n\n        \u003chttp://rt.cpan.org/NoAuth/Bugs.html?Dist=DateTime-Event-Predict\u003e\n\n    *   AnnoCPAN: Annotated CPAN documentation\n\n        \u003chttp://annocpan.org/dist/DateTime-Event-Predict\u003e\n\n    *   CPAN Ratings\n\n        \u003chttp://cpanratings.perl.org/d/DateTime-Event-Predict\u003e\n\n    *   Search CPAN\n\n        \u003chttp://search.cpan.org/dist/DateTime-Event-Predict/\u003e\n\nCOPYRIGHT \u0026 LICENSE\n    Copyright 2009 Brian Hann, all rights reserved.\n\n    This program is free software; you can redistribute it and/or modify it\n    under the same terms as Perl itself.\n\nSEE ALSO\n    DateTime, DateTime::Event::Predict::Profile\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc0bra%2Fdtpredict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc0bra%2Fdtpredict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc0bra%2Fdtpredict/lists"}