Equivalent of scikit-learn's GroupShuffleSplit in dask-ml?











up vote
1
down vote

favorite












I'd like to split my data into testing and training sets, but I have repeated observations of people over time, so I'd like to do the splitting in a way that none of the people have observations that appear in both the test and training data sets. To do this kind of splitting in scikit-learn, I'd do something like this, using GroupShuffleSplit:



import numpy as np
from sklearn.model_selection import GroupShuffleSplit

X = np.array([0.1, 0.2, 2.2, 2.4, 2.3, 4.55, 5.8, 0.001])
y = np.array(["a", "b", "b", "b", "c", "c", "c", "a"])
groups = np.array([1, 1, 2, 2, 3, 3, 4, 4])

gss = GroupShuffleSplit(n_splits=1, test_size=0.2, random_state=0)
train, test = next(gss.split(X, y, groups=groups))

X_train, y_train = X[train], y[train]
X_test, y_test = X[test], y[test]


How can I do this with Dask or Dask-ML?










share|improve this question


























    up vote
    1
    down vote

    favorite












    I'd like to split my data into testing and training sets, but I have repeated observations of people over time, so I'd like to do the splitting in a way that none of the people have observations that appear in both the test and training data sets. To do this kind of splitting in scikit-learn, I'd do something like this, using GroupShuffleSplit:



    import numpy as np
    from sklearn.model_selection import GroupShuffleSplit

    X = np.array([0.1, 0.2, 2.2, 2.4, 2.3, 4.55, 5.8, 0.001])
    y = np.array(["a", "b", "b", "b", "c", "c", "c", "a"])
    groups = np.array([1, 1, 2, 2, 3, 3, 4, 4])

    gss = GroupShuffleSplit(n_splits=1, test_size=0.2, random_state=0)
    train, test = next(gss.split(X, y, groups=groups))

    X_train, y_train = X[train], y[train]
    X_test, y_test = X[test], y[test]


    How can I do this with Dask or Dask-ML?










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'd like to split my data into testing and training sets, but I have repeated observations of people over time, so I'd like to do the splitting in a way that none of the people have observations that appear in both the test and training data sets. To do this kind of splitting in scikit-learn, I'd do something like this, using GroupShuffleSplit:



      import numpy as np
      from sklearn.model_selection import GroupShuffleSplit

      X = np.array([0.1, 0.2, 2.2, 2.4, 2.3, 4.55, 5.8, 0.001])
      y = np.array(["a", "b", "b", "b", "c", "c", "c", "a"])
      groups = np.array([1, 1, 2, 2, 3, 3, 4, 4])

      gss = GroupShuffleSplit(n_splits=1, test_size=0.2, random_state=0)
      train, test = next(gss.split(X, y, groups=groups))

      X_train, y_train = X[train], y[train]
      X_test, y_test = X[test], y[test]


      How can I do this with Dask or Dask-ML?










      share|improve this question













      I'd like to split my data into testing and training sets, but I have repeated observations of people over time, so I'd like to do the splitting in a way that none of the people have observations that appear in both the test and training data sets. To do this kind of splitting in scikit-learn, I'd do something like this, using GroupShuffleSplit:



      import numpy as np
      from sklearn.model_selection import GroupShuffleSplit

      X = np.array([0.1, 0.2, 2.2, 2.4, 2.3, 4.55, 5.8, 0.001])
      y = np.array(["a", "b", "b", "b", "c", "c", "c", "a"])
      groups = np.array([1, 1, 2, 2, 3, 3, 4, 4])

      gss = GroupShuffleSplit(n_splits=1, test_size=0.2, random_state=0)
      train, test = next(gss.split(X, y, groups=groups))

      X_train, y_train = X[train], y[train]
      X_test, y_test = X[test], y[test]


      How can I do this with Dask or Dask-ML?







      python scikit-learn dask panel-data dask-ml






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 18 at 2:56









      karldw

      506




      506





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357485%2fequivalent-of-scikit-learns-groupshufflesplit-in-dask-ml%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357485%2fequivalent-of-scikit-learns-groupshufflesplit-in-dask-ml%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?