{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/55293739","id":55293739,"diff_hunk":"@@ -637,6 +637,121 @@ def split(self, X, y, labels=None):\n         \"\"\"\n         return super(StratifiedKFold, self).split(X, y, labels)\n \n+class HomogeneousTimeSeriesCV(_BaseKFold):\n+    \"\"\"Homogeneous Time Series cross-validator\n+\n+    Provides train/test indices to split time series data in train/test sets.\n+\n+    This cross-validation object is a variation of KFold.\n+    In iteration k, it returns first k folds as train set and k+1 fold as\n+    test set.\n+\n+    Read more in the :ref:`User Guide <cross_validation>`.\n+\n+    Parameters\n+    ----------\n+    n_folds : int, default=3\n+        Number of folds. Must be at least 2.\n+\n+    Examples\n+    --------\n+    >>> from sklearn.model_selection import HomogeneousTimeSeriesCV\n+    >>> X = np.array([[1, 2], [3, 4], [1, 2], [3, 4]])\n+    >>> y = np.array([1, 2, 3, 4])\n+    >>> htscv = HomogeneousTimeSeriesCV(n_folds=4)\n+    >>> htscv.get_n_splits(X)\n+    3\n+    >>> print(htscv)  # doctest: +NORMALIZE_WHITESPACE\n+    HomogeneousTimeSeriesCV(n_folds=2)\n+    >>> for train_index, test_index in htscv.split(X):\n+    ...    print(\"TRAIN:\", train_index, \"TEST:\", test_index)\n+    ...    X_train, X_test = X[train_index], X[test_index]\n+    ...    y_train, y_test = y[train_index], y[test_index]\n+    TRAIN: [0] TEST: [1]\n+    TRAIN: [0 1] TEST: [2]\n+    TRAIN: [0 1 2] TEST: [3]\n+\n+    Notes\n+    -----\n+    The first ``n_samples % n_folds`` folds have size","path":"sklearn/model_selection/_split.py","position":40,"original_position":40,"commit_id":"78c3dcdbc5dc580c656bd9bfa10c5c82b7493948","original_commit_id":"78c3dcdbc5dc580c656bd9bfa10c5c82b7493948","user":{"login":"yenchenlin1994","id":7057863,"avatar_url":"https://avatars.githubusercontent.com/u/7057863?v=3","gravatar_id":"","url":"https://api.github.com/users/yenchenlin1994","html_url":"https://github.com/yenchenlin1994","followers_url":"https://api.github.com/users/yenchenlin1994/followers","following_url":"https://api.github.com/users/yenchenlin1994/following{/other_user}","gists_url":"https://api.github.com/users/yenchenlin1994/gists{/gist_id}","starred_url":"https://api.github.com/users/yenchenlin1994/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yenchenlin1994/subscriptions","organizations_url":"https://api.github.com/users/yenchenlin1994/orgs","repos_url":"https://api.github.com/users/yenchenlin1994/repos","events_url":"https://api.github.com/users/yenchenlin1994/events{/privacy}","received_events_url":"https://api.github.com/users/yenchenlin1994/received_events","type":"User","site_admin":false},"body":"Sorry maybe I'm too dumb.\r\n\r\n> the number of samples in each fold are \"incremented\" by n_samples // n_folds + 1\r\n\r\nWhy is \"incremented\" used here?\r\nI think the number of samples in the first `n_samples % n_folds` folds is exactly `n_samples // n_folds + 1`,\r\nwhich is \"incremented\" by 1 compared to other folds?","created_at":"2016-03-07T23:41:55Z","updated_at":"2016-03-07T23:41:55Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/6351#discussion_r55293739","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/6351","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/55293739"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/6351#discussion_r55293739"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/6351"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/6351","id":59259602,"html_url":"https://github.com/scikit-learn/scikit-learn/pull/6351","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/6351.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/6351.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6351","number":6351,"state":"open","locked":false,"title":"[WIP] Add TimeSeriesCV and HomogeneousTimeSeriesCV","user":{"login":"yenchenlin1994","id":7057863,"avatar_url":"https://avatars.githubusercontent.com/u/7057863?v=3","gravatar_id":"","url":"https://api.github.com/users/yenchenlin1994","html_url":"https://github.com/yenchenlin1994","followers_url":"https://api.github.com/users/yenchenlin1994/followers","following_url":"https://api.github.com/users/yenchenlin1994/following{/other_user}","gists_url":"https://api.github.com/users/yenchenlin1994/gists{/gist_id}","starred_url":"https://api.github.com/users/yenchenlin1994/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yenchenlin1994/subscriptions","organizations_url":"https://api.github.com/users/yenchenlin1994/orgs","repos_url":"https://api.github.com/users/yenchenlin1994/repos","events_url":"https://api.github.com/users/yenchenlin1994/events{/privacy}","received_events_url":"https://api.github.com/users/yenchenlin1994/received_events","type":"User","site_admin":false},"body":"This PR is an implementation of time series cross validation.\r\nBased on #6322 , there are basically two cases:\r\n\r\n1. Homogeneous time series\r\n2. Heterogeneous time series\r\n\r\nFor brevity,\r\nI'll use HomoTSCV to represent homogeneous time series and HeteroTSCV to represent heterogeneous time series in the following checklist.\r\n\r\n**Check List:**\r\n\r\n- [x] HomoTSCV implementation\r\n- [x] Test HomoTSCV\r\n- [ ] HeteroTSCV implementation\r\n- [ ] Test HeteroTSCV\r\n- [ ] Documentation\r\n\r\n**Reference:**\r\n[Using k-fold cross-validation for time-series model selection](http://stats.stackexchange.com/questions/14099/using-k-fold-cross-validation-for-time-series-model-selection)","created_at":"2016-02-13T05:43:05Z","updated_at":"2016-03-07T23:41:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c6918b021d5c980cffe27035aa76e74988ef9466","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/6351/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/6351/comments","review_comment_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6351/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/78c3dcdbc5dc580c656bd9bfa10c5c82b7493948","head":{"label":"yenchenlin1994:add-homogeneous-time-series-cv","ref":"add-homogeneous-time-series-cv","sha":"78c3dcdbc5dc580c656bd9bfa10c5c82b7493948","user":{"login":"yenchenlin1994","id":7057863,"avatar_url":"https://avatars.githubusercontent.com/u/7057863?v=3","gravatar_id":"","url":"https://api.github.com/users/yenchenlin1994","html_url":"https://github.com/yenchenlin1994","followers_url":"https://api.github.com/users/yenchenlin1994/followers","following_url":"https://api.github.com/users/yenchenlin1994/following{/other_user}","gists_url":"https://api.github.com/users/yenchenlin1994/gists{/gist_id}","starred_url":"https://api.github.com/users/yenchenlin1994/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yenchenlin1994/subscriptions","organizations_url":"https://api.github.com/users/yenchenlin1994/orgs","repos_url":"https://api.github.com/users/yenchenlin1994/repos","events_url":"https://api.github.com/users/yenchenlin1994/events{/privacy}","received_events_url":"https://api.github.com/users/yenchenlin1994/received_events","type":"User","site_admin":false},"repo":{"id":50281797,"name":"scikit-learn","full_name":"yenchenlin1994/scikit-learn","owner":{"login":"yenchenlin1994","id":7057863,"avatar_url":"https://avatars.githubusercontent.com/u/7057863?v=3","gravatar_id":"","url":"https://api.github.com/users/yenchenlin1994","html_url":"https://github.com/yenchenlin1994","followers_url":"https://api.github.com/users/yenchenlin1994/followers","following_url":"https://api.github.com/users/yenchenlin1994/following{/other_user}","gists_url":"https://api.github.com/users/yenchenlin1994/gists{/gist_id}","starred_url":"https://api.github.com/users/yenchenlin1994/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yenchenlin1994/subscriptions","organizations_url":"https://api.github.com/users/yenchenlin1994/orgs","repos_url":"https://api.github.com/users/yenchenlin1994/repos","events_url":"https://api.github.com/users/yenchenlin1994/events{/privacy}","received_events_url":"https://api.github.com/users/yenchenlin1994/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yenchenlin1994/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/yenchenlin1994/scikit-learn","forks_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/forks","keys_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/teams","hooks_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/events","assignees_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/tags","blobs_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/subscription","commits_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/merges","archive_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/downloads","issues_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/releases{/id}","deployments_url":"https://api.github.com/repos/yenchenlin1994/scikit-learn/deployments","created_at":"2016-01-24T10:01:07Z","updated_at":"2016-01-24T10:01:14Z","pushed_at":"2016-02-27T14:40:16Z","git_url":"git://github.com/yenchenlin1994/scikit-learn.git","ssh_url":"git@github.com:yenchenlin1994/scikit-learn.git","clone_url":"https://github.com/yenchenlin1994/scikit-learn.git","svn_url":"https://github.com/yenchenlin1994/scikit-learn","homepage":"http://scikit-learn.org","size":66679,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scikit-learn:master","ref":"master","sha":"e98a11b971c4b62189d8994677ed68c794f42215","user":{"login":"scikit-learn","id":365630,"avatar_url":"https://avatars.githubusercontent.com/u/365630?v=3","gravatar_id":"","url":"https://api.github.com/users/scikit-learn","html_url":"https://github.com/scikit-learn","followers_url":"https://api.github.com/users/scikit-learn/followers","following_url":"https://api.github.com/users/scikit-learn/following{/other_user}","gists_url":"https://api.github.com/users/scikit-learn/gists{/gist_id}","starred_url":"https://api.github.com/users/scikit-learn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scikit-learn/subscriptions","organizations_url":"https://api.github.com/users/scikit-learn/orgs","repos_url":"https://api.github.com/users/scikit-learn/repos","events_url":"https://api.github.com/users/scikit-learn/events{/privacy}","received_events_url":"https://api.github.com/users/scikit-learn/received_events","type":"Organization","site_admin":false},"repo":{"id":843222,"name":"scikit-learn","full_name":"scikit-learn/scikit-learn","owner":{"login":"scikit-learn","id":365630,"avatar_url":"https://avatars.githubusercontent.com/u/365630?v=3","gravatar_id":"","url":"https://api.github.com/users/scikit-learn","html_url":"https://github.com/scikit-learn","followers_url":"https://api.github.com/users/scikit-learn/followers","following_url":"https://api.github.com/users/scikit-learn/following{/other_user}","gists_url":"https://api.github.com/users/scikit-learn/gists{/gist_id}","starred_url":"https://api.github.com/users/scikit-learn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scikit-learn/subscriptions","organizations_url":"https://api.github.com/users/scikit-learn/orgs","repos_url":"https://api.github.com/users/scikit-learn/repos","events_url":"https://api.github.com/users/scikit-learn/events{/privacy}","received_events_url":"https://api.github.com/users/scikit-learn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scikit-learn/scikit-learn","description":"scikit-learn: machine learning in Python","fork":false,"url":"https://api.github.com/repos/scikit-learn/scikit-learn","forks_url":"https://api.github.com/repos/scikit-learn/scikit-learn/forks","keys_url":"https://api.github.com/repos/scikit-learn/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scikit-learn/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scikit-learn/scikit-learn/teams","hooks_url":"https://api.github.com/repos/scikit-learn/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/events","assignees_url":"https://api.github.com/repos/scikit-learn/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/scikit-learn/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/scikit-learn/scikit-learn/tags","blobs_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/scikit-learn/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/scikit-learn/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/scikit-learn/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/scikit-learn/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/scikit-learn/scikit-learn/subscription","commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/scikit-learn/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/scikit-learn/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scikit-learn/scikit-learn/merges","archive_url":"https://api.github.com/repos/scikit-learn/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scikit-learn/scikit-learn/downloads","issues_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/scikit-learn/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/scikit-learn/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/scikit-learn/scikit-learn/releases{/id}","deployments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/deployments","created_at":"2010-08-17T09:43:38Z","updated_at":"2016-03-07T21:53:41Z","pushed_at":"2016-03-07T23:30:35Z","git_url":"git://github.com/scikit-learn/scikit-learn.git","ssh_url":"git@github.com:scikit-learn/scikit-learn.git","clone_url":"https://github.com/scikit-learn/scikit-learn.git","svn_url":"https://github.com/scikit-learn/scikit-learn","homepage":"http://scikit-learn.org","size":101358,"stargazers_count":10070,"watchers_count":10070,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5890,"mirror_url":null,"open_issues_count":1109,"forks":5890,"open_issues":1109,"watchers":10070,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/6351"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/6351"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6351"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6351/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/6351/comments"},"review_comment":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/6351/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/78c3dcdbc5dc580c656bd9bfa10c5c82b7493948"}}}}