| calculate_counts |
Ran ran on a synthesized input |
cogstack/foresight/foresight/utils/stream_utils.py code served (permissive licence) · get_code("ac14695298be58fc") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned defaultdict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
from collections import defaultdict
# Construct test data for calculate_counts function
docs = {
'doc_1': {
'entities': {
'ent_0': {
'cui': 'C0001',
'meta_anns': {
'status': {'value': 'active'},
'confidence': {'value': 0.9}
}
},
'ent_1': {
'cui': 'C0002',
'meta_anns': {
'status': {'value': 'active'},
'confidence': {'value': 0.8}
}
}
}
},
'doc_2': {
'entities': [
{
'cui': 'C0001',
'meta_anns': {
'status': {'value': 'active'},
'confidence': {'value': 0.85}
}
},
{
'cui': 'C0003',
'meta_anns': {
'status': {'value': 'inactive'},
'confidence': {'value': 0.7}
}
}
]
}
}
doc2pt = {
'doc_1': 'patient_1',
'doc_2': 'patient_2'
}
pt2cui2cnt = None
meta_requirements = {
'status': 'active'
}
ARGS = {
'docs': docs,
'doc2pt': doc2pt,
'pt2cui2cnt': pt2cui2cnt,
'meta_requirements': meta_requirements
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type defaultdict — a defaultdict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a defaultdict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| docs2stream |
Ran ran on a synthesized input |
cogstack/foresight/foresight/utils/stream_utils.py code served (permissive licence) · get_code("35e52a8c531602c4") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned defaultdict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import numpy as np
from collections import defaultdict
# Build minimal valid arguments for docs2stream
# Create docs structure (output of medcat multiprocessing)
docs = {
'doc1': {
'entities': {
'ent1': {
'cui': 'C0001',
'meta_anns': {
'Presence': {'value': True},
'Status': {'value': 'present'},
'historical_flag': {'value': False}
},
'document_timestamp': 100,
'tuis': ['T047']
},
'ent2': {
'cui': 'C0002',
'meta_anns': {
'Presence': {'value': True},
'Status': {'value': 'present'},
'historical_flag': {'value': True}
},
'document_timestamp': 200,
'tuis': ['T048']
}
}
},
'doc2': {
'entities': {
'ent3': {
'cui': 'C0003',
'meta_anns': {
'Presence': {'value': True},
'Status': {'value': 'present'},
'historical_flag': {'value': False}
},
'document_timestamp': 150,
'tuis': []
}
}
}
}
# Mapping from doc_id to patient_id
doc2pt = {
'doc1': 'patient_A',
'doc2': 'patient_B'
}
# Mapping from patient to cui to count
pt2cui2cnt = {
'patient_A': {
'C0001': 5,
'C0002': 3
},
'patient_B': {
'C0003': 2
}
}
# Mapping from doc_id to timestamp
doc2time = {
'doc1': 1000,
'doc2': 2000
}
# Meta requirements filter
meta_requirements = {
'Presence': True
}
# Entity type column name
entity_type_column = 'tuis'
# Historical meta field name and value
historical_meta = 'historical_flag'
historical_meta_value = True
# CUIs to skip
skip_cuis = None
# Whether to require timestamp
require_time = True
# Old pt2stream (None means create new)
old_pt2stream = None
ARGS = {
'docs': docs,
'doc2pt': doc2pt,
'pt2cui2cnt': pt2cui2cnt,
'doc2time': doc2time,
'meta_requirements': meta_requirements,
'entity_type_column': entity_type_column,
'historical_meta': historical_meta,
'historical_meta_value': historical_meta_value,
'old_pt2stream': old_pt2stream,
'skip_cuis': skip_cuis,
'require_time': require_time
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type defaultdict — a defaultdict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a defaultdict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| filter_by_type |
Ran ran on a synthesized input |
cogstack/foresight/foresight/datasets/filters.py code served (permissive licence) · get_code("ac9a04968e7acc5d") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Dataset. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
from datasets import Dataset
# Create a minimal dataset with the structure expected by filter_by_type
# The function expects a 'stream' column containing lists of dicts with 'token_type' keys
data = {
'stream': [
[
{'token_type': 'KEEP_ME', 'data': 'value1'},
{'token_type': 'REMOVE_ME', 'data': 'value2'},
{'token_type': 'KEEP_ME', 'data': 'value3'},
],
[
{'token_type': 'REMOVE_ME', 'data': 'value4'},
{'token_type': 'KEEP_ME', 'data': 'value5'},
]
]
}
dataset = Dataset.from_dict(data)
types_to_keep = ['KEEP_ME']
num_proc = 1
ARGS = {
'dataset': dataset,
'types_to_keep': types_to_keep,
'num_proc': num_proc
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- datasets — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Dataset — a Dataset output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Dataset output the recorded ndim 1 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| get_all_splits |
Ran ran on a synthesized input |
cogstack/foresight/foresight/datasets/utils.py code served (permissive licence) · get_code("f7578191b70a44ca") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import datasets
from datasets import Dataset
import numpy as np
torch.manual_seed(0)
# Create sample data
data = {
'text': ['hello world', 'foo bar', 'baz qux'],
'label': [0, 1, 0]
}
# Create a datasets.DatasetDict with train, test, and valid splits
dataset_dict = datasets.DatasetDict({
'train': Dataset.from_dict({'text': ['hello world', 'foo bar'], 'label': [0, 1]}),
'test': Dataset.from_dict({'text': ['baz qux'], 'label': [0]}),
'valid': Dataset.from_dict({'text': ['test'], 'label': [1]})
})
ARGS = {
'dataset': dataset_dict
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- datasets, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type list — a list output has no array shape of its own; none is stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| get_children_map |
Ran ran on a synthesized input |
cogstack/foresight/foresight/utils/cdb_utils.py code served (permissive licence) · get_code("2c5b98657b286418") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
# Construct arguments for get_children_map
# The function takes:
# - cuis: a collection of concept unique identifiers
# - pt2ch: a dict mapping parent concepts to lists of child concepts
# - depth: an integer for recursion depth
# Create a simple hierarchy
# CUI "A" has children ["B", "C"]
# CUI "B" has children ["D"]
# CUI "C" has children ["E"]
# CUI "D" has no children
# CUI "E" has no children
pt2ch = {
"A": ["B", "C"],
"B": ["D"],
"C": ["E"],
"D": [],
"E": []
}
cuis = ["A", "B", "C", "D", "E"]
ARGS = {
"cuis": cuis,
"pt2ch": pt2ch,
"depth": 3
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| get_duration_separator |
Ran ran on a synthesized input |
cogstack/foresight/foresight/datasets/utils.py code served (permissive licence) · get_code("15764b4be0c5f12f") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import numpy as np
ARGS = {
"separator": "d}",
"start_time": 100.0,
"current_time": 200.0,
"bucket_size_seconds": 30.0,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| get_entities_for_doc |
Ran ran on a synthesized input |
cogstack/foresight/foresight/utils/stream_utils.py code served (permissive licence) · get_code("3249e2235dcbb16b") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict_values. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
# The function expects:
# - docs: a dictionary where keys are doc_ids and values are dicts with 'entities' key
# - doc_id: an identifier to look up in the docs dictionary
#
# The function accesses docs[doc_id]['entities'] and checks if it's a dict,
# calling .values() on it if so, otherwise treating it as an iterable.
# Create a sample docs structure mimicking medcat multiprocessing output
docs = {
"doc_1": {
"entities": {
"ent_0": {"text": "disease", "start": 0, "end": 7},
"ent_1": {"text": "symptom", "start": 10, "end": 17}
}
},
"doc_2": {
"entities": [
{"text": "drug", "start": 5, "end": 9},
{"text": "dose", "start": 15, "end": 19}
]
}
}
doc_id = "doc_1"
ARGS = {
"docs": docs,
"doc_id": doc_id
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type dict_values — a dict_values output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict_values output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| get_parents_map |
Ran ran on a synthesized input |
cogstack/foresight/foresight/utils/cdb_utils.py code served (permissive licence) · get_code("996a28aa4ca8328e") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import numpy as np
# Build a small parent-to-children mapping
# Structure: {parent_concept: {child_concept1, child_concept2, ...}, ...}
pt2ch = {
"C0001": {"C0002", "C0003"},
"C0002": {"C0004"},
"C0005": {"C0006", "C0007"},
}
# List of CUIs (concepts) to get parents for
cuis = ["C0002", "C0004", "C0006"]
# depth parameter
depth = 3
ARGS = {
"cuis": cuis,
"pt2ch": pt2ch,
"ch2pt": None,
"depth": depth,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| make_example |
Ran ran on a synthesized input |
cogstack/foresight/foresight/datasets/utils.py code served (permissive licence) · get_code("7ef0f00604eab68d") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import numpy as np
torch.manual_seed(0)
# Construct ent_example with context_representation
ent_example = {
'context_representation': [0.1, 0.2, 0.3, 0.4]
}
# Construct ARGS dict with all parameters
ARGS = {
'token': 'hello',
'ent_example': ent_example,
'token_type': 'noun',
'cnt': 1000,
'time': 1234567890,
'cntx': [0.5, 0.6, 0.7, 0.8]
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| metrics_data2df |
Ran ran on a synthesized input |
cogstack/foresight/foresight/metrics/next_concept_prediction.py code served (permissive licence) · get_code("6b31e0ea8a1bb7e8") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned DataFrame. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import pandas as pd
ARGS = {
'metrics_data': {
'positives': {
'all': {
'cui_001': 45,
'cui_002': 32,
'cui_003': 18,
}
},
'negatives': {
'all': {
'cui_001': 5,
'cui_002': 8,
'cui_003': 2,
}
},
'fn_positives': {
'all': {
'cui_001': 3,
'cui_002': 2,
'cui_003': 1,
}
},
'fn_negatives': {
'all': {
'cui_001': 10,
'cui_002': 15,
'cui_003': 5,
}
},
},
'tkn2name': {
'cui_001': 'disease_alpha',
'cui_002': 'disease_beta',
'cui_003': 'disease_gamma',
},
'main': 'positives',
'temporality': 'all',
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- pandas — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| precision_on_one |
Ran ran on a synthesized input |
cogstack/foresight/foresight/metrics/next_concept_prediction.py code served (permissive licence) · get_code("bcd0c6ffe7251ad8") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
# Construct predictions - can be either a list or ndarray
# The function uses np.argsort on axis 1 (for list) or axis 2 (for ndarray)
# For list case: list of 2D arrays, each [seq_len, num_classes]
predictions = [
np.random.rand(5, 8), # sequence of 5 positions, 8 possible classes
np.random.rand(6, 8) # sequence of 6 positions, 8 possible classes
]
# label_ids - list of arrays, each containing concept ids for a sequence
label_ids = [
np.array([1, 2, 3, 2, 1]), # 5 labels
np.array([2, 3, 1, 4, 2, 3]) # 6 labels
]
# concept_id - a single concept to evaluate
concept_id = 2
# old_data - optional dict with tp, fp, fn counts
old_data = None
# topk - number of top predictions to consider
topk = 1
# start - starting position in sequences
start = 0
# time_range - time window for predictions
time_range = 10
# time_data - timing information for each sequence
time_data = [
np.array([0, 1, 5, 8, 12]), # 5 time values
np.array([0, 2, 4, 7, 10, 15]) # 6 time values
]
# min_time_left - minimum time remaining requirement
min_time_left = 3
# shifted_labels - whether labels are shifted
shifted_labels = False
ARGS = {
'predictions': predictions,
'label_ids': label_ids,
'concept_id': concept_id,
'old_data': old_data,
'topk': topk,
'start': start,
'time_range': time_range,
'time_data': time_data,
'min_time_left': min_time_left,
'shifted_labels': shifted_labels
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| reverse_pt2ch |
Ran ran on a synthesized input |
cogstack/foresight/foresight/utils/cdb_utils.py code served (permissive licence) · get_code("e0f388f78415fc22") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import numpy as np
# Analyze the function: reverse_pt2ch takes a dict where:
# - Keys are "pt" (point/part) values
# - Values are iterables of "ch" (character/chunk) values
# - It builds an inverse mapping: ch -> set of pts
# Create a simple pt2ch dictionary structure
pt2ch = {
"part_1": ["char_a", "char_b", "char_c"],
"part_2": ["char_b", "char_d"],
"part_3": ["char_a", "char_d", "char_e"]
}
ARGS = {
"pt2ch": pt2ch
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|