We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns
%matplotlib inline
import os print(os.listdir())
import warnings warnings.filterwarnings('ignore') dataset = pd.read_csv("C:/Users/pavan/OneDrive/Documents/heart (1).csv") dataset.head(5) from sklearn.model_selection import train_test_split
predictors = dataset.drop("target",axis=1) target = dataset["target"]
X_train,X_test,Y_train,Y_test = train_test_split(predictors,target,test_size=0.20,random_state=0) from sklearn.metrics import accuracy_score from sklearn.ensemble import RandomForestClassifier
max_accuracy = 0
for x in range(2000): rf = RandomForestClassifier(random_state=x) rf.fit(X_train,Y_train) Y_pred_rf = rf.predict(X_test) current_accuracy = round(accuracy_score(Y_pred_rf,Y_test)*100,2) if(current_accuracy>max_accuracy): max_accuracy = current_accuracy best_x = x
rf = RandomForestClassifier(random_state=best_x) rf.fit(X_train,Y_train) Y_pred_rf = rf.predict(X_test) Y_pred_rf.shape score_rf = round(accuracy_score(Y_pred_rf,Y_test)*100,2)
print("The accuracy score achieved using Decision Tree is: "+str(score_rf)+" %")
The text was updated successfully, but these errors were encountered:
1: please format your code (paste it inside triple backticks):
\``` your_code_here() # without the backslash
2: please also include the hyperas code you used to run this.
Sorry, something went wrong.
No branches or pull requests
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
import os
print(os.listdir())
import warnings
warnings.filterwarnings('ignore')
dataset = pd.read_csv("C:/Users/pavan/OneDrive/Documents/heart (1).csv")
dataset.head(5)
from sklearn.model_selection import train_test_split
predictors = dataset.drop("target",axis=1)
target = dataset["target"]
X_train,X_test,Y_train,Y_test = train_test_split(predictors,target,test_size=0.20,random_state=0)
from sklearn.metrics import accuracy_score from sklearn.ensemble import RandomForestClassifier
max_accuracy = 0
for x in range(2000):
rf = RandomForestClassifier(random_state=x)
rf.fit(X_train,Y_train)
Y_pred_rf = rf.predict(X_test)
current_accuracy = round(accuracy_score(Y_pred_rf,Y_test)*100,2)
if(current_accuracy>max_accuracy):
max_accuracy = current_accuracy
best_x = x
rf = RandomForestClassifier(random_state=best_x)
rf.fit(X_train,Y_train)
Y_pred_rf = rf.predict(X_test)
Y_pred_rf.shape
score_rf = round(accuracy_score(Y_pred_rf,Y_test)*100,2)
print("The accuracy score achieved using Decision Tree is: "+str(score_rf)+" %")
The text was updated successfully, but these errors were encountered: