Mimesis を用いた IoT センサー時系列データの 1 年分のモック作成
この記事は、Mimesis、Pandas、NumPy を組み合わせて、季節変動やデバイスメタデータを反映した高品質な IoT センサー時系列データの疑似生成手法を解説している。
キーポイント
リアルなデータ生成の必要性
単なるランダム値生成ではなく、時間軸、デバイスメタデータ、季節変動などの自然パターンを反映したデータが実験や分析には不可欠である。
主要ライブラリの活用戦略
Mimesis を用いた合成データ生成、Pandas による時系列構造の構築、NumPy による数値計算と季節曲線の模倣という 3 つの Python ライブラリを連携させる。
デバイスプロファイルの作成
Mimesis の Generic プロバイダーを使用して、UUID、住所、ファームウェアバージョン、IP アドレスなどを含む現実的なセンサーデバイスメタデータを事前に生成する。
季節変動のモデル化
温度データの年次パターンをシミュレートするために、正弦波関数を用いた数式が定義されています。
現実的なノイズの付与
Mimesis ライブラリを使用してランダムな環境ノイズとネットワーク遅延を追加し、完璧な波形ではなく現実的な変動を再現します。
Mimesis を用いたノイズと遅延の注入
センサーデータの生成において、Mimesis を使用して温度にランダムなハードウェアノイズ(-2.0〜2.0度)を付与し、ネットワーク接続の揺らぎを模倣する遅延値(12〜145ms)を生成している。
季節変動パターンの実装と検証
正弦波関数を用いて年間を通じた温度の季節変動曲線をベースラインとして設定し、生成されたデータが冬(1月)と夏(7月)で明確な温度差を示すことを確認した。
影響分析・編集コメントを表示
影響分析
本記事は、AI モデルのトレーニングやアルゴリズム検証において不足しがちな高品質な IoT データセットを作成するための具体的な実装手法を提供しており、開発現場での即座の実用性が高い。特に、季節変動などの複雑な時系列パターンを再現するアプローチは、より現実的なシミュレーション環境構築に寄与し、研究やプロトタイピングの効率化に直結する。
編集コメント
実務においてテスト用データを大量に用意するのは困難なケースが多いため、この手法は開発効率を劇的に改善する有用な知見です。特に季節変動の模倣部分は、単純なランダム生成では得られない洞察を得る上で重要です。

**
# Introduction
Mocking Internet of Things (IoT) sensor data that would be otherwise difficult to gather at scale can constitute a valuable approach to facilitate experimental analyses, projects, and studies. However, it requires much more than random value generation: it necessitates a chronological timeline, device metadata, and a need to reflect natural environmental fluctuations or patterns like seasonality. Mimesis** is an excellent open-source tool for fake data generation, while a pinch of math can be integrated into a code-based solution to deal with the latter: this article shows how.
Through the step-by-step guide below, I will navigate you through the process of generating a year's worth of daily temperature readings, mimicking a seasonal curve that looks like real — all together with device-level metadata, and ready to build based on open-source frameworks.
# Step-by-Step Guide
**
We will rely on three key Python libraries to create our year-round set of IoT sensor readings: mimesis for synthetic data generation, pandas for dealing with the time series' scaffolding, and NumPy** for doing some math, leading us to mimic seasonal patterns.
Bear in mind that real-world IoT time series datasets are generally tied to a concrete device. The way to emulate this, aided by Mimesis, is by using the Generic provider class and generating a realistic hardware device profile: our "fictional sensor", so to speak. This is done before creating the actual daily readings:
import pandas as pd
import numpy as np
from mimesis import Generic
from mimesis.locales import Locale
# Initializing a generic provider for English language
g = Generic(locale=Locale.EN, seed=101)
# Generating static metadata for our mock IoT device
device_profile = {
'device_id': g.cryptographic.uuid(),
'location': g.address.city(),
'firmware_version': g.development.version(),
'ip_address': g.internet.ip_v4()
}
print(f"Tracking Device: {device_profile['device_id']} located in {device_profile['location']}")Note that device_profile is a dictionary containing our fictional sensor metadata: identifier, location, firmware version, and IP address. It will look like:
Tracking Device: e88b7591-31db-4e32-98dc-b35f94c662cd located in ParagouldNow, before generating the time series, we will define an equation to emulate the seasonality pattern needed to reflect temperature readings throughout a year. As you might have guessed, trigonometric functions like sine are perfect to reflect this kind of year-round pattern that looks like a sine wave, so our equation will be based on one:
\[**
T(t) = T_{\text{base}} + A \cdot \sin\left(\frac{2\pi (t - \phi)}{365}\right) + \epsilon
\]
Here, \(T(t)\) stands for the temperature reading on day of the year \(t\), ranging from 1 to 365. The rest of the variables are components of a sine wave, and importantly, \(\epsilon\) is the random noise introduced by using Mimesis: without the latter, we would have a perfect, smooth sine wave, which wouldn't be realistic, as real-world temperature has its short-term ups and downs, of course!
Next, we iterate over the whole year, day by day, to generate the daily timeline. pandas will govern the data creation process, while mimesis.numeric will be used to inject not only the aforesaid environmental noise, but also some realistic network latency: a common aspect in IoT devices. All of these go on top of the mathematical baseline equation previously defined. NumPy's role, meanwhile, is to apply the sine function as part of the generation process.
# 1. Setting up mathematical constants for emulating daily temperature
T_base = 15.0 # Base temperature in Celsius
A = 12.0 # Fluctuates by 12 degrees up/down throughout the year
phase_shift = 80 # Shift the sine wave so the peak falls in the summer
# 2. Creating the 365-day time series starting Jan 1, 2026
dates = pd.date_range(start='2026-01-01', periods=365, freq='D')
readings = []
# 3. Looping through each day and calculating the readings
for day_index, current_date in enumerate(dates):
# Calculating the seasonal curve baseline for this specific day
seasonal_temp = T_base + A * np.sin(2 * np.pi * (day_index - phase_shift) / 365)
# Using Mimesis to inject random hardware variance/noise (e.g., -2.0 to 2.0 degrees)
sensor_noise = g.numeric.float_number(start=-2.0, end=2.0, precision=2)
# Calculating final recorded temperature
final_temp = round(seasonal_temp + sensor_noise, 2)
# Compiling the daily record, mixing static metadata with dynamic Mimesis generation
readings.append({
'timestamp': current_date,
'device_id': device_profile['device_id'],
'location': device_profile['location'],
'temperature_c': final_temp,
'latency_ms': g.numeric.integer_number(start=12, end=145) # Mocking network connection strength/latency fluctuations per day
})
# Converting to a DataFrame for analysis
df = pd.DataFrame(readings)As you can observe, we use Mimesis twice in the time series generation process for every daily instance of the time series: once for the sensor noise, and once for the latency, the latter of which mimics network connection fluctuations every day.
It's time to see what the generated IoT time series looks like and verify the seasonal pattern we tried to mimic:
print("--- January (Winter) Readings ---")
print(df[['timestamp', 'temperature_c', 'latency_ms']].head(3))
print("\n--- July (Summer) Readings ---")
print(df[['timestamp', 'temperature_c', 'latency_ms']].iloc[180:183])Output:
--- January (Winter) Readings ---
timestamp temperature_c latency_ms
0 2026-01-01 3.54 61
1 2026-01-02 4.90 103
2 2026-01-03 3.18 140
--- July (Summer) Readings ---
timestamp temperature_c latency_ms
180 2026-06-30 28.84 116
181 2026-07-01 25.81 62
182 2026-07-02 26.08 97For a more visual result, why not try this:
import matplotlib.pyplot as plt
plt.figure(figsize=(12, 6))
plt.plot(df['timestamp'], df['temperature_c'])
plt.xlabel('Date')
plt.ylabel('Temperature (°C)')
plt.title('Daily Temperature Throughout the Year')
plt.grid(True)
plt.tight_layout()
plt.show()
Well done if you made it this far!
# Final Remarks
In this article, we showed how to utilize Mimesis combined with pandas and NumPy to illustrate the generation of fake yet convincing IoT time series data. In particular, we illustrated the process of creating a year-round dataset of daily temperature readings collected from an IoT sensor, including device-related metadata, random noise to emulate realistic temperature changes, and device latency. These data can be leveraged by downstream forecasting models or even dashboard solutions: they will surely ingest it and help interpret aspects like seasonal peaks, common sensor fluctuations, and so on.
Iván Palomares Carrascosa** is a leader, writer, speaker, and adviser in AI, machine learning, deep learning & LLMs. He trains and guides others in harnessing AI in the real world.
関連記事
ソフトウェア更新により、危険な夏の暑さ中にアマゾンの配送ドライバーのエアコンが自動的に停止する事態に
複数のアマゾン配送ドライバーによると、同社の電気配送車(EDV)へのソフトウェア更新により、運転席から降りた直後に数秒でエアコンが自動的に切れる仕様に変更された。これにより、高温下での作業環境が悪化し、ドライバーから不満の声が上がっている。
新しい低技術・修理可能なトラクターへの需要が急増
カナダの企業が、ジョン・ディア社の修理独占に依存せず農家が自分で修理できる新型の低技術トラクターを製造し、数十年使用された中古機市場の急成長に応えようとしている。
Kiwibit の AI 搭載バードフィーダーが私の新しい庭の仲間
Kiwibit が、AI を活用して鳥の行動を分析・記録するスマートなバードフィーダーを発表し、家庭用ガーデン機器として市場に投入した。
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み