core.data package¶
Submodules¶
core.data.dataset module¶
-
class
core.data.dataset.
Dataset
[source]¶ Bases:
object
Core data set format. The standard data structure for occupancy and sensor data.
Note
All attributes are copies of the original values, therefore the changes will only be seen if user use methods to update values of
self
.- Variables
- Parameter
None
- Return type
-
add_room
(data, occupancy=None, room_name=None, header=True)[source]¶ Add a new room to
self
.self.data
can automatically expand.- Parameters
data (numpy.ndarray) – sensor data from the new room
occupancy (None or numpy.ndarray) – occupancy data from the new room. If
None
then fill withnumpy.nan
room_name (None or str) – the name of the new room. If
None
then assign a unique indexheader (bool) – Indicate whether the new room have a header on the first row
- Returns
None
-
change_feature_mapping
(feature_mapping)[source]¶ Replace the feature_mapping within
self
.- Parameters
feature_mapping (dict) – new feature mapping rule with bidirectional dict
- Returns
None
-
change_occupancy
(occupancy)[source]¶ Replace the data of
self.occupancy
.- Parameters
occupancy (numpy.ndarray) – new occupancy data have same number of rows with original occupancy data
- Returns
None
-
change_room_mapping
(room)[source]¶ Replace the room_mapping within
self
.- Parameters
room (dict) – new room mapping rule with bidirectional dict
- Returns
None
-
change_values
(data)[source]¶ Replace the sensor data of
self.data
.- Parameters
data (numpy.ndarray) – new sensor data have same shape with original sensor data
- Returns
None
-
copy
()[source]¶ Make a copy of
self
.- Parameter
None
- Return type
- Returns
A same copy of
self
, with different addresses for all values
-
property
data
¶ - Return type
- Returns
a copy of the sensor data in numpy.ndarray
-
property
feature_mapping
¶ - Return type
- Returns
a bidirectional dictionary map feature names with corresponding column index
-
property
occupancy
¶ - Return type
- Returns
a copy of the occupancy data in numpy.ndarray
-
pop_room
(room_name)[source]¶ Remove a room from
self
.- Parameters
room_name (str) – name of the room need to be removed
- Return type
- Returns
removed Dataset
-
property
room_mapping
¶ - Return type
- Returns
a bidirectional dictionary map room names with corresponding row index tuple (start, end)
-
select_feature
(features, error=True)[source]¶ Select one or multiple features from the
self.data
, remove rest features.
core.data.import_data module¶
-
core.data.import_data.
import_data
(file_name, time_column_index=None, mode='csv', header=True, room_name=None, tz=0)[source]¶ Load raw data from the disk.
- Parameters
file_name (str) – the name of the raw data file
time_column_index (int) – the column index for the timestamp in given raw data file
mode (str) – the format for raw data. Currently only support
csv
header (bool) – indicate whether the raw data contains a header on the first row. If
False
, then assign unique index for each columnroom_name (str or None) – the name of the room. If
None
, then assign unique number for the roomtz (int) – the time zone offset that need to fix in the raw data file
- Return type
- Returns
The structured data set with one raw input data
core.data.io module¶
-
core.data.io.
read_dataset
(file_name)[source]¶ Load a core.data.dataset.Dataset object from local disk binary file
- Parameters
file_name (str) – name of the binary file
- Return type
- Returns
Dataset object that load from a binary file
-
core.data.io.
save_dataset
(dataset, file_name)[source]¶ Save a core.data.dataset.Dataset object to local disk as a binary file
- Parameters
dataset (core.data.dataset.Dataset) – Dataset object that want to save to local disk as a binary file
file_name (str) – name of the binary file
- Returns
None
core.data.load_sample module¶
-
core.data.load_sample.
load_sample
(sample_name)[source]¶ Load one or more core.data.dataset.Dataset object from the sample folder
- Parameters
sample_name (str or list(str)) – name(s) of the binary file in binary_dataset
- Return type
core.data.dataset.Dataset or dict(str, core.data.dataset.Dataset)
- Returns
Dataset object(s) that load from a binary file. If a list of name is provided, then a dictionary with their name as key and corresponding Dataset is returned