This repository has been archived on 2023-06-18. You can view files and clone it, but cannot push or open issues or pull requests.
ima02/grid_search_table.py

30 lines
954 B
Python
Raw Normal View History

2023-05-24 16:05:44 +00:00
#!/usr/bin/env python3
import os
import pandas as pd
from train_classifiers import get_classifiers
def main():
i = 0
df = pd.DataFrame(columns=['Classifier', 'Parameter', 'Values'])
for clazz, grid in get_classifiers():
for name, values in grid.items():
df.loc[i, 'Classifier'] = type(clazz).__name__
df.loc[i, 'Parameter'] = name
df.loc[i, 'Values'] = ', '.join([str(x) for x in values])
i += 1
n1 = '5, 10, 15, ..., 100'
n2 = ', '.join([str(x) for x in range(15, 101, 15)])
n3 = ', '.join([str(x) for x in range(20, 101, 20)])
df.loc[(df.Classifier == 'MLPClassifier') & (df.Parameter == 'hidden_layer_sizes'), 'Values'] = f'$[{n1}]$, $[{n2}]^2$, $[{n3}]^3$'
for i in set(df['Classifier']):
print(i)
print(df.loc[df.Classifier == i, ['Parameter', 'Values']].to_markdown(index=False))
print()
if __name__ == '__main__':
main()