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]
$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 -
Please help so that I can improve my computing skills
python random-forest ai
New contributor
$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.
add a comment |
$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 -
Please help so that I can improve my computing skills
python random-forest ai
New contributor
$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.
add a comment |
$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 -
Please help so that I can improve my computing skills
python random-forest ai
New contributor
$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 -
Please help so that I can improve my computing skills
python random-forest ai
python random-forest ai
New contributor
New contributor
edited 9 hours ago
master
New contributor
asked 20 hours ago
mastermaster
11
11
New contributor
New contributor
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.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$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.
$endgroup$
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$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.
$endgroup$
add a comment |
$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.
$endgroup$
add a comment |
$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.
$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.
answered 17 hours ago
Simon LarssonSimon Larsson
724114
724114
add a comment |
add a comment |