This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.metrics import confusion_matrix | |
def print_cm(cm, labels): | |
"""pretty print for confusion matrixes""" | |
# using str in len because of some label | |
# may using integer as label | |
columnwidth = max([len(str(x)) for x in labels]) | |
# Print header | |
print(" " * columnwidth, end="\t") | |
for label in labels: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from pandas.api.types import is_numeric_dtype | |
np.random.seed(42) | |
age = np.random.randint(20,100,50) | |
name = ['name'+str(i) for i in range(50)] | |
address = ['address'+str(i) for i in range(50)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_column_name(value): | |
return value[value.rfind('_')+1:] | |
def check_categorical_column(columns): | |
dict_column_name = {} | |
for column in columns: | |
name = column[:column.rfind('_')] | |
dict_column_name.setdefault(name,[]).append(column) | |
return dict_column_name |