How to find the accuracy vs number of features for Random Forest [on hold] The 2019 Stack Overflow Developer Survey Results Are Infinding maximum depth of random forest given the number of featuresMinimum number of trees for Random Forest classifierWhy do we pick random features in random forestFeatures selection/combination for random forestHow to find and use the top features for XGBoost?Get frequent features of scikitlearn random forestLSTM doesnt find finer dependencies than the Random Forest modelExceptionally high accuracy with Random Forest, is it possible?Random Forest, Duplicating Data increases Accuracy. Why?train_test_split function error. ValueError: Found input variables with inconsistent numbers of samples: [6, 27696]

If a poisoned arrow's piercing damage is reduced to 0, do you still get poisoned?

What is a mixture ratio of propellant?

Confusion about non-derivable continuous functions

Is three citations per paragraph excessive for undergraduate research paper?

How to manage monthly salary

Why is Grand Jury testimony secret?

I see my dog run

Is flight data recorder erased after every flight?

Should I use my personal or workplace e-mail when registering to external websites for work purpose?

What is the meaning of Triage in Cybersec world?

Landlord wants to switch my lease to a "Land contract" to "get back at the city"

Unbreakable Formation vs. Cry of the Carnarium

Dual Citizen. Exited the US on Italian passport recently

Evaluating number of iteration with a certain map with While

The difference between dialogue marks

Inflated grade on resume at previous job, might former employer tell new employer?

In microwave frequencies, do you use a circulator when you need a (near) perfect diode?

Time travel alters history but people keep saying nothing's changed

How to answer pointed "are you quitting" questioning when I don't want them to suspect

Why isn't airport relocation done gradually?

Monty Hall variation

Geography at the pixel level

What tool would a Roman-age civilization have to grind silver and other metals into dust?

Output the Arecibo Message



How to find the accuracy vs number of features for Random Forest [on hold]



The 2019 Stack Overflow Developer Survey Results Are Infinding maximum depth of random forest given the number of featuresMinimum number of trees for Random Forest classifierWhy do we pick random features in random forestFeatures selection/combination for random forestHow to find and use the top features for XGBoost?Get frequent features of scikitlearn random forestLSTM doesnt find finer dependencies than the Random Forest modelExceptionally high accuracy with Random Forest, is it possible?Random Forest, Duplicating Data increases Accuracy. Why?train_test_split function error. ValueError: Found input variables with inconsistent numbers of samples: [6, 27696]










0












$begingroup$


May I know how to modify my Python programming so that can obtain the accuracy vs number of features as refer to the attached image file -



from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
# load the data
iris = datasets.load_iris()
# get the features and labels from the data
x = iris.data
y = iris.target
# split the data into training and test data
X_train, X_test, y_train, y_test = train_test_split(x, y,test_size=0.7, random_state=0)
# standardise the data
sc = StandardScaler()
X_train_std = sc.fit_transform(X_train)
X_test_std = sc.fit_transform(X_test)
# choose algorithm and set the hyperparameters
forest = RandomForestClassifier(criterion='entropy', n_estimators=10, random_state=1)
# train the model
forest.fit(X_train_std, y_train)
# make the prediction using the model
y_pred = forest.predict(X_test_std)

A = []
C1 = [forest]
for i in range(len(C)):
forest = RandomForestClassifier(C=C1[i], random_state=0)
forest.fit(X_train_std,y_train)
y_pred = forest.predict(X_test_std)
A.append(accuracy_score(y_test,y_pred))

import matplotlib.pyplot as plt
plt.plot(C1, A)
plt.yticks(np.arange(0.90, 0.95, 0.01))
plt.xlabel('Number of features')
plt.ylabel('Accuracy')
plt.title('RansomForest')
plt.show()


The error message is -



runfile('C:/Users/HSIPL/Desktop/Homework 7 Solution draft.py', wdir='C:/Users/HSIPL/Desktop')
Traceback (most recent call last):

File "<ipython-input-10-f06d5471b604>", line 1, in <module>
runfile('C:/Users/HSIPL/Desktop/Homework 7 Solution draft.py', wdir='C:/Users/HSIPL/Desktop')

File "C:UsersHSIPLAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 668, in runfile
execfile(filename, namespace)

File "C:UsersHSIPLAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/HSIPL/Desktop/Homework 7 Solution draft.py", line 28, in <module>
forest = RandomForestClassifier(C=C1[i], random_state=0)

TypeError: __init__() got an unexpected keyword argument 'C'


Please see the attached image file -



enter image description here



Please help so that I can improve my computing skills










share|improve this question









New contributor




master is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$



put on hold as too broad by Stephen Rauch, Mark.F, Tasos, Dawny33 13 hours ago


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






















    0












    $begingroup$


    May I know how to modify my Python programming so that can obtain the accuracy vs number of features as refer to the attached image file -



    from sklearn import datasets
    from sklearn.model_selection import train_test_split
    from sklearn.preprocessing import StandardScaler
    from sklearn.ensemble import RandomForestClassifier
    from sklearn.metrics import accuracy_score
    # load the data
    iris = datasets.load_iris()
    # get the features and labels from the data
    x = iris.data
    y = iris.target
    # split the data into training and test data
    X_train, X_test, y_train, y_test = train_test_split(x, y,test_size=0.7, random_state=0)
    # standardise the data
    sc = StandardScaler()
    X_train_std = sc.fit_transform(X_train)
    X_test_std = sc.fit_transform(X_test)
    # choose algorithm and set the hyperparameters
    forest = RandomForestClassifier(criterion='entropy', n_estimators=10, random_state=1)
    # train the model
    forest.fit(X_train_std, y_train)
    # make the prediction using the model
    y_pred = forest.predict(X_test_std)

    A = []
    C1 = [forest]
    for i in range(len(C)):
    forest = RandomForestClassifier(C=C1[i], random_state=0)
    forest.fit(X_train_std,y_train)
    y_pred = forest.predict(X_test_std)
    A.append(accuracy_score(y_test,y_pred))

    import matplotlib.pyplot as plt
    plt.plot(C1, A)
    plt.yticks(np.arange(0.90, 0.95, 0.01))
    plt.xlabel('Number of features')
    plt.ylabel('Accuracy')
    plt.title('RansomForest')
    plt.show()


    The error message is -



    runfile('C:/Users/HSIPL/Desktop/Homework 7 Solution draft.py', wdir='C:/Users/HSIPL/Desktop')
    Traceback (most recent call last):

    File "<ipython-input-10-f06d5471b604>", line 1, in <module>
    runfile('C:/Users/HSIPL/Desktop/Homework 7 Solution draft.py', wdir='C:/Users/HSIPL/Desktop')

    File "C:UsersHSIPLAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 668, in runfile
    execfile(filename, namespace)

    File "C:UsersHSIPLAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 108, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

    File "C:/Users/HSIPL/Desktop/Homework 7 Solution draft.py", line 28, in <module>
    forest = RandomForestClassifier(C=C1[i], random_state=0)

    TypeError: __init__() got an unexpected keyword argument 'C'


    Please see the attached image file -



    enter image description here



    Please help so that I can improve my computing skills










    share|improve this question









    New contributor




    master is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$



    put on hold as too broad by Stephen Rauch, Mark.F, Tasos, Dawny33 13 hours ago


    Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.




















      0












      0








      0





      $begingroup$


      May I know how to modify my Python programming so that can obtain the accuracy vs number of features as refer to the attached image file -



      from sklearn import datasets
      from sklearn.model_selection import train_test_split
      from sklearn.preprocessing import StandardScaler
      from sklearn.ensemble import RandomForestClassifier
      from sklearn.metrics import accuracy_score
      # load the data
      iris = datasets.load_iris()
      # get the features and labels from the data
      x = iris.data
      y = iris.target
      # split the data into training and test data
      X_train, X_test, y_train, y_test = train_test_split(x, y,test_size=0.7, random_state=0)
      # standardise the data
      sc = StandardScaler()
      X_train_std = sc.fit_transform(X_train)
      X_test_std = sc.fit_transform(X_test)
      # choose algorithm and set the hyperparameters
      forest = RandomForestClassifier(criterion='entropy', n_estimators=10, random_state=1)
      # train the model
      forest.fit(X_train_std, y_train)
      # make the prediction using the model
      y_pred = forest.predict(X_test_std)

      A = []
      C1 = [forest]
      for i in range(len(C)):
      forest = RandomForestClassifier(C=C1[i], random_state=0)
      forest.fit(X_train_std,y_train)
      y_pred = forest.predict(X_test_std)
      A.append(accuracy_score(y_test,y_pred))

      import matplotlib.pyplot as plt
      plt.plot(C1, A)
      plt.yticks(np.arange(0.90, 0.95, 0.01))
      plt.xlabel('Number of features')
      plt.ylabel('Accuracy')
      plt.title('RansomForest')
      plt.show()


      The error message is -



      runfile('C:/Users/HSIPL/Desktop/Homework 7 Solution draft.py', wdir='C:/Users/HSIPL/Desktop')
      Traceback (most recent call last):

      File "<ipython-input-10-f06d5471b604>", line 1, in <module>
      runfile('C:/Users/HSIPL/Desktop/Homework 7 Solution draft.py', wdir='C:/Users/HSIPL/Desktop')

      File "C:UsersHSIPLAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 668, in runfile
      execfile(filename, namespace)

      File "C:UsersHSIPLAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 108, in execfile
      exec(compile(f.read(), filename, 'exec'), namespace)

      File "C:/Users/HSIPL/Desktop/Homework 7 Solution draft.py", line 28, in <module>
      forest = RandomForestClassifier(C=C1[i], random_state=0)

      TypeError: __init__() got an unexpected keyword argument 'C'


      Please see the attached image file -



      enter image description here



      Please help so that I can improve my computing skills










      share|improve this question









      New contributor




      master is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      May I know how to modify my Python programming so that can obtain the accuracy vs number of features as refer to the attached image file -



      from sklearn import datasets
      from sklearn.model_selection import train_test_split
      from sklearn.preprocessing import StandardScaler
      from sklearn.ensemble import RandomForestClassifier
      from sklearn.metrics import accuracy_score
      # load the data
      iris = datasets.load_iris()
      # get the features and labels from the data
      x = iris.data
      y = iris.target
      # split the data into training and test data
      X_train, X_test, y_train, y_test = train_test_split(x, y,test_size=0.7, random_state=0)
      # standardise the data
      sc = StandardScaler()
      X_train_std = sc.fit_transform(X_train)
      X_test_std = sc.fit_transform(X_test)
      # choose algorithm and set the hyperparameters
      forest = RandomForestClassifier(criterion='entropy', n_estimators=10, random_state=1)
      # train the model
      forest.fit(X_train_std, y_train)
      # make the prediction using the model
      y_pred = forest.predict(X_test_std)

      A = []
      C1 = [forest]
      for i in range(len(C)):
      forest = RandomForestClassifier(C=C1[i], random_state=0)
      forest.fit(X_train_std,y_train)
      y_pred = forest.predict(X_test_std)
      A.append(accuracy_score(y_test,y_pred))

      import matplotlib.pyplot as plt
      plt.plot(C1, A)
      plt.yticks(np.arange(0.90, 0.95, 0.01))
      plt.xlabel('Number of features')
      plt.ylabel('Accuracy')
      plt.title('RansomForest')
      plt.show()


      The error message is -



      runfile('C:/Users/HSIPL/Desktop/Homework 7 Solution draft.py', wdir='C:/Users/HSIPL/Desktop')
      Traceback (most recent call last):

      File "<ipython-input-10-f06d5471b604>", line 1, in <module>
      runfile('C:/Users/HSIPL/Desktop/Homework 7 Solution draft.py', wdir='C:/Users/HSIPL/Desktop')

      File "C:UsersHSIPLAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 668, in runfile
      execfile(filename, namespace)

      File "C:UsersHSIPLAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py", line 108, in execfile
      exec(compile(f.read(), filename, 'exec'), namespace)

      File "C:/Users/HSIPL/Desktop/Homework 7 Solution draft.py", line 28, in <module>
      forest = RandomForestClassifier(C=C1[i], random_state=0)

      TypeError: __init__() got an unexpected keyword argument 'C'


      Please see the attached image file -



      enter image description here



      Please help so that I can improve my computing skills







      python random-forest ai






      share|improve this question









      New contributor




      master is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      master is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 9 hours ago







      master













      New contributor




      master is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 20 hours ago









      mastermaster

      11




      11




      New contributor




      master is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      master is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      master is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      put on hold as too broad by Stephen Rauch, Mark.F, Tasos, Dawny33 13 hours ago


      Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









      put on hold as too broad by Stephen Rauch, Mark.F, Tasos, Dawny33 13 hours ago


      Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






















          1 Answer
          1






          active

          oldest

          votes


















          0












          $begingroup$

          This is your homework, other people should not do it for you. Instead you need to learn how to interpret the information you got.



          Your error message tells you that the issue is:



          TypeError: __init__() got an unexpected keyword argument 'C'


          So something is not expecting to have C as an argument. But the message also tell your which line the issue is with:



          forest = RandomForestClassifier(C=C1[i], random_state=0)


          This should hopefully identify which C gives us issues. If we check the sklearn documentation we can find which argument the classifier can input in it's init:



          RandomForestClassifier(n_estimators=’warn’, criterion=’gini’, max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=’auto’, max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, bootstrap=True, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, class_weight=None) 


          Using this information you should be able to get past this error message and be able to continue doing your homework on your own.



          Also, the you probably got this error from copy and pasting code from an assignment where you used a SVM which does use C as an input. Copy pasting can easily make things harder when you are learning since the errors you get are more random.






          share|improve this answer









          $endgroup$



















            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0












            $begingroup$

            This is your homework, other people should not do it for you. Instead you need to learn how to interpret the information you got.



            Your error message tells you that the issue is:



            TypeError: __init__() got an unexpected keyword argument 'C'


            So something is not expecting to have C as an argument. But the message also tell your which line the issue is with:



            forest = RandomForestClassifier(C=C1[i], random_state=0)


            This should hopefully identify which C gives us issues. If we check the sklearn documentation we can find which argument the classifier can input in it's init:



            RandomForestClassifier(n_estimators=’warn’, criterion=’gini’, max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=’auto’, max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, bootstrap=True, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, class_weight=None) 


            Using this information you should be able to get past this error message and be able to continue doing your homework on your own.



            Also, the you probably got this error from copy and pasting code from an assignment where you used a SVM which does use C as an input. Copy pasting can easily make things harder when you are learning since the errors you get are more random.






            share|improve this answer









            $endgroup$

















              0












              $begingroup$

              This is your homework, other people should not do it for you. Instead you need to learn how to interpret the information you got.



              Your error message tells you that the issue is:



              TypeError: __init__() got an unexpected keyword argument 'C'


              So something is not expecting to have C as an argument. But the message also tell your which line the issue is with:



              forest = RandomForestClassifier(C=C1[i], random_state=0)


              This should hopefully identify which C gives us issues. If we check the sklearn documentation we can find which argument the classifier can input in it's init:



              RandomForestClassifier(n_estimators=’warn’, criterion=’gini’, max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=’auto’, max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, bootstrap=True, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, class_weight=None) 


              Using this information you should be able to get past this error message and be able to continue doing your homework on your own.



              Also, the you probably got this error from copy and pasting code from an assignment where you used a SVM which does use C as an input. Copy pasting can easily make things harder when you are learning since the errors you get are more random.






              share|improve this answer









              $endgroup$















                0












                0








                0





                $begingroup$

                This is your homework, other people should not do it for you. Instead you need to learn how to interpret the information you got.



                Your error message tells you that the issue is:



                TypeError: __init__() got an unexpected keyword argument 'C'


                So something is not expecting to have C as an argument. But the message also tell your which line the issue is with:



                forest = RandomForestClassifier(C=C1[i], random_state=0)


                This should hopefully identify which C gives us issues. If we check the sklearn documentation we can find which argument the classifier can input in it's init:



                RandomForestClassifier(n_estimators=’warn’, criterion=’gini’, max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=’auto’, max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, bootstrap=True, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, class_weight=None) 


                Using this information you should be able to get past this error message and be able to continue doing your homework on your own.



                Also, the you probably got this error from copy and pasting code from an assignment where you used a SVM which does use C as an input. Copy pasting can easily make things harder when you are learning since the errors you get are more random.






                share|improve this answer









                $endgroup$



                This is your homework, other people should not do it for you. Instead you need to learn how to interpret the information you got.



                Your error message tells you that the issue is:



                TypeError: __init__() got an unexpected keyword argument 'C'


                So something is not expecting to have C as an argument. But the message also tell your which line the issue is with:



                forest = RandomForestClassifier(C=C1[i], random_state=0)


                This should hopefully identify which C gives us issues. If we check the sklearn documentation we can find which argument the classifier can input in it's init:



                RandomForestClassifier(n_estimators=’warn’, criterion=’gini’, max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=’auto’, max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, bootstrap=True, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, class_weight=None) 


                Using this information you should be able to get past this error message and be able to continue doing your homework on your own.



                Also, the you probably got this error from copy and pasting code from an assignment where you used a SVM which does use C as an input. Copy pasting can easily make things harder when you are learning since the errors you get are more random.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 17 hours ago









                Simon LarssonSimon Larsson

                724114




                724114













                    Popular posts from this blog

                    ValueError: Error when checking input: expected conv2d_13_input to have shape (3, 150, 150) but got array with shape (150, 150, 3)2019 Community Moderator ElectionError when checking : expected dense_1_input to have shape (None, 5) but got array with shape (200, 1)Error 'Expected 2D array, got 1D array instead:'ValueError: Error when checking input: expected lstm_41_input to have 3 dimensions, but got array with shape (40000,100)ValueError: Error when checking target: expected dense_1 to have shape (7,) but got array with shape (1,)ValueError: Error when checking target: expected dense_2 to have shape (1,) but got array with shape (0,)Keras exception: ValueError: Error when checking input: expected conv2d_1_input to have shape (150, 150, 3) but got array with shape (256, 256, 3)Steps taking too long to completewhen checking input: expected dense_1_input to have shape (13328,) but got array with shape (317,)ValueError: Error when checking target: expected dense_3 to have shape (None, 1) but got array with shape (7715, 40000)Keras exception: Error when checking input: expected dense_input to have shape (2,) but got array with shape (1,)

                    Ружовы пелікан Змест Знешні выгляд | Пашырэнне | Асаблівасці біялогіі | Літаратура | НавігацыяДагледжаная версіяправерана1 зменаДагледжаная версіяправерана1 змена/ 22697590 Сістэматыкана ВіківідахВыявына Вікісховішчы174693363011049382

                    Illegal assignment from SObject to ContactFetching String, Id from Map - Illegal Assignment Id to Field / ObjectError: Compile Error: Illegal assignment from String to BooleanError: List has no rows for assignment to SObjectError on Test Class - System.QueryException: List has no rows for assignment to SObjectRemote action problemDML requires SObject or SObject list type error“Illegal assignment from List to List”Test Class Fail: Batch Class: System.QueryException: List has no rows for assignment to SObjectMapping to a user'List has no rows for assignment to SObject' Mystery