{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7506","repository_url":"https://api.github.com/repos/scikit-learn/scikit-learn","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7506/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7506/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7506/events","html_url":"https://github.com/scikit-learn/scikit-learn/pull/7506","id":179651034,"number":7506,"title":"Learning curve: Add an option to randomly choose indices for different training sizes","user":{"login":"NarineK","id":12010601,"avatar_url":"https://avatars.githubusercontent.com/u/12010601?v=3","gravatar_id":"","url":"https://api.github.com/users/NarineK","html_url":"https://github.com/NarineK","followers_url":"https://api.github.com/users/NarineK/followers","following_url":"https://api.github.com/users/NarineK/following{/other_user}","gists_url":"https://api.github.com/users/NarineK/gists{/gist_id}","starred_url":"https://api.github.com/users/NarineK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NarineK/subscriptions","organizations_url":"https://api.github.com/users/NarineK/orgs","repos_url":"https://api.github.com/users/NarineK/repos","events_url":"https://api.github.com/users/NarineK/events{/privacy}","received_events_url":"https://api.github.com/users/NarineK/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2016-09-28T00:27:05Z","updated_at":"2016-10-09T13:27:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/7506","html_url":"https://github.com/scikit-learn/scikit-learn/pull/7506","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/7506.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/7506.patch"},"body":"Currently, training sizes are chosen sequentially from 0 to n_train_samples:\r\n`train[:n_train_samples]`\r\n\r\nIf training data is sorted by the target variable, for small sizes of training data it will choose only one label and this will always lead to failures during model fitting.\r\nFor example:\r\n\r\n\r\n```\r\nX = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]], np.int32)\r\ny = np.array(['a', 'a', 'a', 'a', 'b', 'b', 'b']) \r\nimport numpy as np\r\nfrom sklearn.learning_curve import learning_curve\r\nfrom sklearn.svm import SVC\r\n\r\n```\r\nThe following always fails with: ValueError: The number of classes has to be greater than one; got 1\r\n`\r\ntrain_sizes, train_scores, valid_scores = learning_curve(SVC(kernel='linear'), X, y, train_sizes=[0.7, 1.0], cv=3)`\r\n\r\nThe following runs successfully for most tries:\r\n\r\n`train_sizes, train_scores, valid_scores = learning_curve(SVC(kernel='linear'), X, y, train_sizes=[0.7, 1.0], cv=3, shuffle=True)\r\n`\r\n\r\nIf we would have an option to shuffle the indices of training data before choosing ’n_train_samples’, that will increase our chances of not fitting data with the same label into the learner and have more label variety.\r\n\r\nIn the following pull request I did a small modification and added an option to shuffle and choose randomly the indices. We could do the same also for incremental learning.\r\n\r\nLet me know what you think.\r\n\r\nThanks!\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/scikit-learn/scikit-learn/7506)\n<!-- Reviewable:end -->\n"},"comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments/252486385","html_url":"https://github.com/scikit-learn/scikit-learn/pull/7506#issuecomment-252486385","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7506","id":252486385,"user":{"login":"jnothman","id":78827,"avatar_url":"https://avatars.githubusercontent.com/u/78827?v=3","gravatar_id":"","url":"https://api.github.com/users/jnothman","html_url":"https://github.com/jnothman","followers_url":"https://api.github.com/users/jnothman/followers","following_url":"https://api.github.com/users/jnothman/following{/other_user}","gists_url":"https://api.github.com/users/jnothman/gists{/gist_id}","starred_url":"https://api.github.com/users/jnothman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnothman/subscriptions","organizations_url":"https://api.github.com/users/jnothman/orgs","repos_url":"https://api.github.com/users/jnothman/repos","events_url":"https://api.github.com/users/jnothman/events{/privacy}","received_events_url":"https://api.github.com/users/jnothman/received_events","type":"User","site_admin":false},"created_at":"2016-10-09T13:27:57Z","updated_at":"2016-10-09T13:27:57Z","body":"the overall patch is now nothing...?"}}
{"actor":{"display_login":"jnothman"}}