<jupyter_start><jupyter_text>Here 2 means suffering with disease and 1 means not suffering with disease. Replacing 2 with 1 and 1 with 0, for better understanding.<jupyter_code>data['Dataset'] = data['Dataset'].replace([2,1],[1,0])
data['Dataset'].head()
import seaborn as sns
sns.countplot('Dataset', data = data)
sns.countplot('Gender', data = data, hue = 'Dataset')
data = pd.get_dummies(data, columns = ['Gender'], drop_first = True)
data.head()
plt.figure(figsize = (20,20))
sns.heatmap(data.corr(), annot = True)
sns.pairplot(data, hue = 'Dataset')
data.corr()
# X = data[['Albumin_and_Globulin_Ratio', 'Albumin', 'Total_Protiens', 'Aspartate_Aminotransferase', 'Alamine_Aminotransferase', 'Alkaline_Phosphotase', 'Age']]
X = data.drop('Dataset', axis = 1)
y = data['Dataset']
X.columns
# from imblearn.combine import SMOTETomek
# smk = SMOTETomek(random_state = 42)
# X, y = smk.fit_sample(X,y)
# X.shape, y.shape
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.1, random_state = 42)
print("Train Set: ", X_train.shape, y_train.shape)
print("Test Set: ", X_test.shape, y_test.shape)
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(n_estimators=20)
model.fit(X_train, y_train)
from sklearn.metrics import confusion_matrix, accuracy_score
confusion_matrix(y_test, model.predict(X_test))
print(f"Accuracy is {round(accuracy_score(y_test, model.predict(X_test))*100,2)}")
import pickle
pickle.dump(model, open('liver.pkl', 'wb'))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14675984752223634, 'fraction_numerical': 0.017153748411689963, 'mean_word_length': 7.422459893048129, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '150761', 'license': 'MIT', 'n_tokens_mistral': 612, 'n_tokens_neox': 577, 'n_words': 127, 'path': 'Notebooks/Liver_Disease_Prediction.ipynb', 'repo_name': 'prathimacode-hub/Protectrizer', 'size': '1574'}