<jupyter_start><jupyter_text>Data Preprocessing<jupyter_code># transform boolean value [Tes, No] to binary value [0, 1]
from sklearn.preprocessing import LabelEncoder
encoder = LabelEncoder()
y = encoder.fit_transform(y)
# categorize
X = pd.get_dummies(X)
X.head()
# standarise the dataset
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X = scaler.fit_transform(X)
X
# split dataset to train and test
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(X, y, test_size = 0.3, random_state = 19)
# evaluate the model (using custom loss func)
from sklearn import metrics
def evaluate(clf):
    y_pred = clf.predict(x_test)
    print('Score of {} are: Accuracy = {}'.format(type(clf).__name__, metrics.accuracy_score(y_test, y_pred)))
# model 1 (SVM)
from sklearn.svm import SVC
svm_svc = SVC(kernel = 'rbf')
svm_svc.fit(x_train,y_train)
evaluate(svm_svc)
# model 2 (KNN)
from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier(5)
knn.fit(x_train, y_train)
    evaluate(knn)
# model 3
from sklearn.ensemble import RandomForestClassifier
random_forest = RandomForestClassifier()
random_forest.fit(x_train, y_train)
evaluate(random_forest)
from sklearn.tree import DecisionTreeClassifier
desicion_tree = DecisionTreeClassifier()
desicion_tree.fit(x_train, y_train)
evaluate(desicion_tree)
from sklearn.naive_bayes import GaussianNB
bn_gaussian = GaussianNB()
bn_gaussian.fit(x_train, y_train)
evaluate(bn_gaussian)<jupyter_output>Score: 0.6931471805599453<jupyter_text>Testing Part<jupyter_code># load test dataset file
test_dataset = pd.read_csv("dataset/Test_v2.csv")
test_dataset.head()
# get IDs & countries for output result
uniqueids = test_dataset.uniqueid
countries = test_dataset.country
# drop unique id column
test_dataset = test_dataset.drop(['uniqueid'], axis = 1)
test_dataset = pd.get_dummies(test_dataset)
test_dataset.head()
# standarise the test dataset
test_dataset = scaler.fit_transform(test_dataset)
prediction = bn_gaussian.predict(test_dataset)
# result columns ()
new_unique_id = uniqueids + " x " + countries
result_columns_list = list(zip(new_unique_id, prediction))
result = pd.DataFrame(result_columns_list, columns = ['unique_id', 'bank_account'])
result.describe()
# export result
result.to_csv('SubmissionFile.csv', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10008375209380234, 'fraction_numerical': 0.012144053601340033, 'mean_word_length': 7.382456140350877, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '583696', 'license': 'Apache-2.0', 'n_tokens_mistral': 860, 'n_tokens_neox': 819, 'n_words': 188, 'path': 'financial_inclusion_in_africa/.ipynb_checkpoints/Financial Inclusion in Africa-checkpoint.ipynb', 'repo_name': 'HouariZegai/MachineLearningProjects', 'size': '2388'}