<jupyter_start><jupyter_text>Tune LDA hyperparameters with grid search<jupyter_code># Use the average resnet features to predict the labels

# number of runs for cross-validation
num_runs = 5
# number of splits for cross-validation
num_splits = 20

# Multiple cross validations on the training set

# Use linear Discriminant Analysis
model = LinearDiscriminantAnalysis()

cv = sklearn.model_selection.RepeatedStratifiedKFold(n_splits=num_splits, n_repeats=num_runs, random_state=1)

# define grid
grid = dict()
grid['solver'] = ['svd', 'lsqr', 'eigen']
# define search
search = sklearn.model_selection.GridSearchCV(model, grid, scoring='roc_auc', cv=cv, n_jobs=-1)
# perform the search
results = search.fit(X=features_train, y=labels_train)
    
# summarize
print('Mean Accuracy: %.3f' % results.best_score_)
print('Config: %s' % results.best_params_)<jupyter_output>Mean Accuracy: 0.722
Config: {'solver': 'svd'}
{'fraction_non_alphanumeric': 0.11062431544359255, 'fraction_numerical': 0.01095290251916758, 'mean_word_length': 6.553719008264463, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '37825', 'license': 'MIT', 'n_tokens_mistral': 326, 'n_tokens_neox': 307, 'n_words': 81, 'path': 'LDA.ipynb', 'repo_name': 'Peischlili/BreastCancer_Metastases_Detection', 'size': '913'}