MCPcopy Create free account
hub / github.com/FlyingFeather/DEA-SQL / get_random_samples

Function get_random_samples

fewshot/auto_selection.py:15–29  ·  view source on GitHub ↗

Randomly samples from train set :param train: the train set :param n_samples: the num of samples :return: a list of samples

(train: Dict, n_samples=1)

Source from the content-addressed store, hash-verified

13
14
15def get_random_samples(train: Dict, n_samples=1) -> List[Dict]:
16 """
17 Randomly samples from train set
18
19 :param train: the train set
20 :param n_samples: the num of samples
21 :return: a list of samples
22 """
23 if n_samples > len(train):
24 raise ValueError("n_samples should be less than or equal to len(train)")
25
26 # random n sample
27 samples = random.sample(list(train.values()), n_samples)
28
29 return samples
30
31
32def get_similar_text_embed_by_knn(train: Dict, text: str, model='transformer', n_samples=1) -> List[Dict]:

Callers 1

get_shots_by_modeFunction · 0.85

Calls 1

sampleMethod · 0.45

Tested by

no test coverage detected