I am creating a project based on predicting anemia disease using machine learning. I am using a dataset from kaggle, I have removed all duplicates and have cleaned data and have 534 entries after removing duplicates and null values. But after running the model and checking the accuracy, it is showing 100% accuracy for Random Forest Algorithm which I find unusual.
y = df['Result']
y.shape
df.drop("Result", axis=1, inplace=True)
x = df
x.head()
x_train,x_test,y_train,y_test = train_test_split(x,y,test_size=0.30)
random = RandomForestClassifier()
random.fit(x_train,y_train)
ran_pred = random.predict(x_test)
print(ran_pred)
accuracy_scorerf = accuracy_score(y_test, ran_pred)
print("Random Forest :", accuracy_scorerf)
cm = confusion_matrix(y_test, ran_pred)
f, ax = plt.subplots(figsize=(5,5))
sns.heatmap(cm,fmt=".0f", annot=True,linewidths=0.2, linecolor="purple", ax=ax)
plt.xlabel("Model Predicted")
plt.ylabel("Actual values")
plt.show()
Output -
[1 0 1 0 0 1 1 1 0 0 1 0 0 0 0 1 1 0 0 0 1 1 0 0 1 1 0 0 0 0 1 0 0 0 1 0 0
1 1 0 1 0 0 0 0 1 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0
0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 0 1 1 1 1 1 1 0 1 1 0 1 0 0 0 1 0 1 0 1
0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 1 0 1 0 0 1 0 0 0 0 1 1 1 0 1 0 0 1 0 1 0
0 0 1 1 0 0 0 0 0 0 1 1 0]
Random Forest : 1.0
I have checked the dataset and have a balanced dataset with 247 suffering from anemia and 287 not suffering from anemia.
Not able to get why I am getting such unusually high accuracy.