This file contains hidden or 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 itertools | |
| my_dict = {'A':['D','E'],'B':['F','G','H'],'C':['I','J']} | |
| keys, values = zip(*my_dict.items()) | |
| permutations_dicts = [dict(zip(keys, v)) for v in itertools.product(*values)] | |
| # this will provide you a list of dicts with the permutations: | |
| print(permutations_dicts) | |
| #[{'A':'D', 'B':'F', 'C':'I'}, |
This file contains hidden or 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 random | |
| import time | |
| import multiprocessing as mp | |
| import itertools as it | |
| # just an example generator to prove lazy access by printing when it generates | |
| def get_counter(limit=10): | |
| for i in range(limit): | |
| for j in range(limit): | |
| print(f"YIELDED: {i},{j}") |
This file contains hidden or 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 numpy as np | |
| from sklearn.preprocessing import QuantileTransformer | |
| from sklearn.metrics._scorer import _BaseScorer | |
| class FuncScorer(_BaseScorer): | |
| def _score(self, method_caller, estimator, X, y_true, sample_weight=None): | |
| """Evaluate predicted target values for X relative to y_true. | |
OlderNewer