Generating data#
You can also ask bob to generate data for you, e.g. for testing an algorithm.
import os
from bia_bob import bob
bob.initialize(endpoint='https://chat-ai.academiccloud.de/v1', model='openai-gpt-oss-120b', api_key=os.environ.get('KISSKI_API_KEY'))
This notebook may contain text, code and images generated by artificial intelligence.
Used model: openai-gpt-oss-120b, vision model: None, endpoint: https://chat-ai.academiccloud.de/v1, bia-bob version: 0.34.3.. Do not enter sensitive or private information and verify generated contents according to good scientific practice. Read more: https://github.com/haesleinhuepf/bia-bob#disclaimer
%bob write code that generates a "measurements.csv" file with three columns "label_ud", "Area", and "perimeter" with normal distributed values.
The script creates a CSV file measurements.csv containing three columns:
label_ud – a unique integer ID for each record.
Area – values drawn from a normal distribution (mean = 500, σ = 100) and forced to be positive.
perimeter – values drawn from a normal distribution (mean = 200, σ = 30) and forced to be positive.
import numpy as np
# 1. Parameters
n_rows = 200 # number of measurements
area_mean, area_std = 500, 100 # mean & std for Area
peri_mean, peri_std = 200, 30 # mean & std for Perimeter
# 2. Generate data
label_ud = np.arange(1, n_rows + 1)
# Sample from normal distributions and ensure positive values
area = np.random.normal(area_mean, area_std, n_rows)
perimeter = np.random.normal(peri_mean, peri_std, n_rows)
# Replace non‑positive values (simple absolute‑value approach)
area = np.abs(area)
perimeter = np.abs(perimeter)
# 3. Build DataFrame
df = pd.DataFrame({
"label_ud": label_ud,
"Area": area,
"perimeter": perimeter
})
# 4. Save to CSV
csv_path = "measurements.csv"
df.to_csv(csv_path, index=False)
print(f"{csv_path} created with {len(df)} rows.")
Exercise#
Ask bob to write code to generate some data, e.g. a timelapse video as 3D numpy array where bright blobs are visible on dark background.
Consider visualizing the resulting data using stackview.animate.