Error: ValueError('%r cannot be used to seed a numpy.random.RandomState') The 2019 Stack Overflow Developer Survey Results Are Insk-learn - ValueError: array is too big.XGBClassifier error! ValueError: feature_names mismatch:Need a Work-around for OneHotEncoder Issue in SKLearn PreprocessingTensorflow regression predicting 1 for all inputsValueError while using linear regressionPerformance Evaluation Metrics used in Training, Validation and TestingHow do we standardize arrays with NaN?cannot use sklearn.naive_bayes MultinomialNB to predict from one attributeNested cross-validation generalization error for multiple modelsHi..Can anyone help me resolve the error with following piece of code below?

How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?

Multiply Two Integer Polynomials

How to check whether the reindex working or not in Magento?

"as much details as you can remember"

Aging parents with no investments

How come people say “Would of”?

How to notate time signature switching consistently every measure

Command for nulifying spaces

What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?

Output the Arecibo Message

If a sorcerer casts the Banishment spell on a PC while in Avernus, does the PC return to their home plane?

What does Linus Torvalds mean when he says that Git "never ever" tracks a file?

Can a flute soloist sit?

Ubuntu Server install with full GUI

Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?

Old scifi movie from the 50s or 60s with men in solid red uniforms who interrogate a spy from the past

What to expect from an e-bike service?

What information about me do stores get via my credit card?

Is there a better way to do an empty check in Java?

Can one be advised by a professor who is very far away?

Why doesn't mkfifo with a mode of 1755 grant read permissions and sticky bit to the user?

The phrase "to the numbers born"?

Balance problems for leveling up mid-fight?

Reference request: Oldest number theory books with (unsolved) exercises?



Error: ValueError('%r cannot be used to seed a numpy.random.RandomState')



The 2019 Stack Overflow Developer Survey Results Are Insk-learn - ValueError: array is too big.XGBClassifier error! ValueError: feature_names mismatch:Need a Work-around for OneHotEncoder Issue in SKLearn PreprocessingTensorflow regression predicting 1 for all inputsValueError while using linear regressionPerformance Evaluation Metrics used in Training, Validation and TestingHow do we standardize arrays with NaN?cannot use sklearn.naive_bayes MultinomialNB to predict from one attributeNested cross-validation generalization error for multiple modelsHi..Can anyone help me resolve the error with following piece of code below?










0












$begingroup$


I am getting this error message while trying to fit a model for the isolationForest algorithm.



raise ValueError('%r cannot be used to seed a numpy.random.RandomState'


Below is my code:



 import numpy as np
import matplotlib.pyplot as plt
from sklearn.ensemble import IsolationForest
import pandas as pd

np.random.RandomState(1234)
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
df = pd.read_csv('E://Market_dat.csv',names=['EVENT_DT', 'MARKET_NAME', 'Duration', 'TOTAL_COUNTS'],skiprows=1,index_col=0)
for column in df.columns:
if df[column].dtype == type(object):
le = LabelEncoder()
df[column] = le.fit_transform(df[column])
np.random.get_state()

X_train, X_test = train_test_split(df, test_size=0.3)
print(X_test)
print(X_train)
X_outliers = rng.uniform(low=-4, high=4, size=(20, 2))
clf = IsolationForest(behaviour='new', max_samples=100,
random_state=df, contamination='auto')
clf.fit(X_train)


Can anyone give any insight as to why I might be getting this error?










share|improve this question











$endgroup$
















    0












    $begingroup$


    I am getting this error message while trying to fit a model for the isolationForest algorithm.



    raise ValueError('%r cannot be used to seed a numpy.random.RandomState'


    Below is my code:



     import numpy as np
    import matplotlib.pyplot as plt
    from sklearn.ensemble import IsolationForest
    import pandas as pd

    np.random.RandomState(1234)
    from sklearn.model_selection import train_test_split
    from sklearn.preprocessing import LabelEncoder
    df = pd.read_csv('E://Market_dat.csv',names=['EVENT_DT', 'MARKET_NAME', 'Duration', 'TOTAL_COUNTS'],skiprows=1,index_col=0)
    for column in df.columns:
    if df[column].dtype == type(object):
    le = LabelEncoder()
    df[column] = le.fit_transform(df[column])
    np.random.get_state()

    X_train, X_test = train_test_split(df, test_size=0.3)
    print(X_test)
    print(X_train)
    X_outliers = rng.uniform(low=-4, high=4, size=(20, 2))
    clf = IsolationForest(behaviour='new', max_samples=100,
    random_state=df, contamination='auto')
    clf.fit(X_train)


    Can anyone give any insight as to why I might be getting this error?










    share|improve this question











    $endgroup$














      0












      0








      0





      $begingroup$


      I am getting this error message while trying to fit a model for the isolationForest algorithm.



      raise ValueError('%r cannot be used to seed a numpy.random.RandomState'


      Below is my code:



       import numpy as np
      import matplotlib.pyplot as plt
      from sklearn.ensemble import IsolationForest
      import pandas as pd

      np.random.RandomState(1234)
      from sklearn.model_selection import train_test_split
      from sklearn.preprocessing import LabelEncoder
      df = pd.read_csv('E://Market_dat.csv',names=['EVENT_DT', 'MARKET_NAME', 'Duration', 'TOTAL_COUNTS'],skiprows=1,index_col=0)
      for column in df.columns:
      if df[column].dtype == type(object):
      le = LabelEncoder()
      df[column] = le.fit_transform(df[column])
      np.random.get_state()

      X_train, X_test = train_test_split(df, test_size=0.3)
      print(X_test)
      print(X_train)
      X_outliers = rng.uniform(low=-4, high=4, size=(20, 2))
      clf = IsolationForest(behaviour='new', max_samples=100,
      random_state=df, contamination='auto')
      clf.fit(X_train)


      Can anyone give any insight as to why I might be getting this error?










      share|improve this question











      $endgroup$




      I am getting this error message while trying to fit a model for the isolationForest algorithm.



      raise ValueError('%r cannot be used to seed a numpy.random.RandomState'


      Below is my code:



       import numpy as np
      import matplotlib.pyplot as plt
      from sklearn.ensemble import IsolationForest
      import pandas as pd

      np.random.RandomState(1234)
      from sklearn.model_selection import train_test_split
      from sklearn.preprocessing import LabelEncoder
      df = pd.read_csv('E://Market_dat.csv',names=['EVENT_DT', 'MARKET_NAME', 'Duration', 'TOTAL_COUNTS'],skiprows=1,index_col=0)
      for column in df.columns:
      if df[column].dtype == type(object):
      le = LabelEncoder()
      df[column] = le.fit_transform(df[column])
      np.random.get_state()

      X_train, X_test = train_test_split(df, test_size=0.3)
      print(X_test)
      print(X_train)
      X_outliers = rng.uniform(low=-4, high=4, size=(20, 2))
      clf = IsolationForest(behaviour='new', max_samples=100,
      random_state=df, contamination='auto')
      clf.fit(X_train)


      Can anyone give any insight as to why I might be getting this error?







      machine-learning scikit-learn machine-learning-model






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 30 at 2:47









      Ethan

      701625




      701625










      asked Mar 29 at 21:07









      RahulRahul

      1




      1




















          1 Answer
          1






          active

          oldest

          votes


















          0












          $begingroup$

          Because you are creating a IsolationForest instance with random_state getting initialised to pandas.DataFrame. The code docs for random_state explain it as




          random_state : int, RandomState instance or None, optional (default=None). If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.







          share|improve this answer









          $endgroup$












          • $begingroup$
            so how can i correct it
            $endgroup$
            – Rahul
            Apr 1 at 14:01










          • $begingroup$
            Pass an integer value
            $endgroup$
            – Kiritee Gak
            Apr 1 at 14:02











          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "557"
          ;
          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2fdatascience.stackexchange.com%2fquestions%2f48236%2ferror-valueerrorr-cannot-be-used-to-seed-a-numpy-random-randomstate%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0












          $begingroup$

          Because you are creating a IsolationForest instance with random_state getting initialised to pandas.DataFrame. The code docs for random_state explain it as




          random_state : int, RandomState instance or None, optional (default=None). If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.







          share|improve this answer









          $endgroup$












          • $begingroup$
            so how can i correct it
            $endgroup$
            – Rahul
            Apr 1 at 14:01










          • $begingroup$
            Pass an integer value
            $endgroup$
            – Kiritee Gak
            Apr 1 at 14:02















          0












          $begingroup$

          Because you are creating a IsolationForest instance with random_state getting initialised to pandas.DataFrame. The code docs for random_state explain it as




          random_state : int, RandomState instance or None, optional (default=None). If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.







          share|improve this answer









          $endgroup$












          • $begingroup$
            so how can i correct it
            $endgroup$
            – Rahul
            Apr 1 at 14:01










          • $begingroup$
            Pass an integer value
            $endgroup$
            – Kiritee Gak
            Apr 1 at 14:02













          0












          0








          0





          $begingroup$

          Because you are creating a IsolationForest instance with random_state getting initialised to pandas.DataFrame. The code docs for random_state explain it as




          random_state : int, RandomState instance or None, optional (default=None). If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.







          share|improve this answer









          $endgroup$



          Because you are creating a IsolationForest instance with random_state getting initialised to pandas.DataFrame. The code docs for random_state explain it as




          random_state : int, RandomState instance or None, optional (default=None). If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 30 at 6:47









          Kiritee GakKiritee Gak

          1,3591521




          1,3591521











          • $begingroup$
            so how can i correct it
            $endgroup$
            – Rahul
            Apr 1 at 14:01










          • $begingroup$
            Pass an integer value
            $endgroup$
            – Kiritee Gak
            Apr 1 at 14:02
















          • $begingroup$
            so how can i correct it
            $endgroup$
            – Rahul
            Apr 1 at 14:01










          • $begingroup$
            Pass an integer value
            $endgroup$
            – Kiritee Gak
            Apr 1 at 14:02















          $begingroup$
          so how can i correct it
          $endgroup$
          – Rahul
          Apr 1 at 14:01




          $begingroup$
          so how can i correct it
          $endgroup$
          – Rahul
          Apr 1 at 14:01












          $begingroup$
          Pass an integer value
          $endgroup$
          – Kiritee Gak
          Apr 1 at 14:02




          $begingroup$
          Pass an integer value
          $endgroup$
          – Kiritee Gak
          Apr 1 at 14:02

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Data Science Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f48236%2ferror-valueerrorr-cannot-be-used-to-seed-a-numpy-random-randomstate%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

          Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

          Tähtien Talli Jäsenet | Lähteet | NavigointivalikkoSuomen Hippos – Tähtien Talli

          Do these cracks on my tires look bad? The Next CEO of Stack OverflowDry rot tire should I replace?Having to replace tiresFishtailed so easily? Bad tires? ABS?Filling the tires with something other than air, to avoid puncture hassles?Used Michelin tires safe to install?Do these tyre cracks necessitate replacement?Rumbling noise: tires or mechanicalIs it possible to fix noisy feathered tires?Are bad winter tires still better than summer tires in winter?Torque converter failure - Related to replacing only 2 tires?Why use snow tires on all 4 wheels on 2-wheel-drive cars?