Package: zephyr-ml
A project from Data to AI Lab at MIT.ZephyrA machine learning library for assisting in the generation of machine learning problems for wind farms operations data by analyzing past occurrences of events.Important Links:computer:WebsiteCheck out the Sintel Website for more information about the project.:book:DocumentationQuickstarts, User and Development Guides, and API Reference.:star:TutorialsCheckout our notebooks:octocat:RepositoryThe link to the Github Repository of this library.:scroll:LicenseThe repository is published under the MIT License.:keyboard:Development StatusThis software is in its Pre-Alpha stage.CommunityJoin our Slack Workspace for announcements and discussions.Homepage:https://github.com/signals-dev/zephyrOverviewTheZephyrlibrary is a framework designed to assist in the
generation of machine learning problems for wind farms operations data by analyzing past
occurrences of events.The main features ofZephyrare:EntitySet creation: tools designed to represent wind farm data and the relationship
between different tables. We have functions to create EntitySets for datasets with PI data
and datasets using SCADA data.Labeling Functions: a collection of functions, as well as tools to create custom versions
of them, ready to be used to analyze past operations data in the search for occurrences of
specific types of events in the past.Prediction Engineering: a flexible framework designed to apply labeling functions on
wind turbine operations data in a number of different ways to create labels for custom
Machine Learning problems.Feature Engineering: a guide to using Featuretools to apply automated feature engineerinig
to wind farm data.InstallRequirementsZephyrhas been developed and runs on Python 3.6 and 3.7.Also, although it is not strictly required, the usage of avirtualenvis highly recommended in order to avoid interfering
with other software installed in the system where you are trying to runZephyr.Download and InstallZephyrcan be installed locally usingpipwith
the following command:pipinstallzephyr-mlIf you want to install from source or contribute to the project please read theContributing Guide.QuickstartIn this short tutorial we will guide you through a series of steps that will help you
getting started withZephyr.1. Loading the dataThe first step we will be to use preprocessed data to create an EntitySet. Depending on the
type of data, we will either thezephyr_ml.create_pidata_entitysetorzephyr_ml.create_scada_entitysetfunctions.NOTE: if you cloned theZephyrrepository, you will find some demo data inside thenotebooks/datafolder which has been preprocessed to fit thecreate_entitysetdata
requirements.importosimportpandasaspdfromzephyr_mlimportcreate_scada_entitysetdata_path='notebooks/data'data={'turbines':pd.read_csv(os.path.join(data_path,'turbines.csv')),'alarms':pd.read_csv(os.path.join(data_path,'alarms.csv')),'work_orders':pd.read_csv(os.path.join(data_path,'work_orders.csv')),'stoppages':pd.read_csv(os.path.join(data_path,'stoppages.csv')),'notifications':pd.read_csv(os.path.join(data_path,'notifications.csv')),'scada':pd.read_csv(os.path.join(data_path,'scada.csv'))}scada_es=create_scada_entityset(data)This will load the turbine, alarms, stoppages, work order, notifications, and SCADA data, and return it
as an EntitySet.Entityset: SCADA data
  DataFrames:
    turbines [Rows: 1, Columns: 10]
    alarms [Rows: 2, Columns: 9]
    work_orders [Rows: 2, Columns: 20]
    stoppages [Rows: 2, Columns: 16]
    notifications [Rows: 2, Columns: 15]
    scada [Rows: 2, Columns: 5]
  Relationships:
    alarms.COD_ELEMENT -> turbines.COD_ELEMENT
    stoppages.COD_ELEMENT -> turbines.COD_ELEMENT
    work_orders.COD_ELEMENT -> turbines.COD_ELEMENT
    scada.COD_ELEMENT -> turbines.COD_ELEMENT
    notifications.COD_ORDER -> work_orders.COD_ORDER2. Selecting a Labeling FunctionThe second step will be to choose an adequateLabeling Function.We can see the list of available labeling functions using thezephyr_ml.labeling.get_labeling_functionsfunction.fromzephyr_mlimportlabelinglabeling.get_labeling_functions()This will return us a dictionary with the name and a short description of each available
function.{'brake_pad_presence': 'Calculates the total power loss over the data slice.',
 'converter_replacement_presence': 'Calculates the converter replacement presence.',
 'total_power_loss': 'Calculates the total power loss over the data slice.'}In this case, we will choose thetotal_power_lossfunction, which calculates the total
amount of power lost over a slice of time.3. Generate Target TimesOnce we have loaded the data and the Labeling Function, we are ready to start using
thezephyr_ml.generate_labelsfunction to generate a Target Times table.fromzephyr_mlimportDataLabelerdata_labeler=DataLabeler(labeling.labeling_functions.total_power_loss)target_times,metadata=data_labeler.generate_label_times(scada_es)This will return us acompose.LabelTimescontaining the three columns required to start
working on a Machine Learning problem: the turbine ID (COD_ELEMENT), the cutoff time (time) and the label.COD_ELEMENT       time    label
0            0 2022-01-01  45801.04. Feature EngineeringUsing EntitySets and LabelTimes allows us to easily use Featuretools for automatic feature generation.importfeaturetoolsasftfeature_matrix,features=ft.dfs(entityset=scada_es,target_dataframe_name='turbines',cutoff_time_in_index=True,cutoff_time=target_times,max_features=20)Then we get a list of features and the computedfeature_matrix.TURBINE_PI_ID TURBINE_LOCAL_ID TURBINE_SAP_COD DES_CORE_ELEMENT      SITE DES_CORE_PLANT  ... MODE(alarms.COD_STATUS) MODE(alarms.DES_NAME)  MODE(alarms.DES_TITLE)  NUM_UNIQUE(alarms.COD_ALARM)  NUM_UNIQUE(alarms.COD_ALARM_INT)    label
COD_ELEMENT time                                                                                                 ...                                                                                                                                               
0           2022-01-01          TA00               A0          LOC000              T00  LOCATION            LOC  ...                  Alarm1                Alarm1  Description of alarm 1                             1                                 1  45801.0

[1 rows x 21 columns]5. ModelingOnce we have the feature matrix, we can train a model using the Zephyr interface where you can train, infer, and evaluate a pipeline.
First, we need to prepare our dataset for training by creatingXandyvariables and one-hot encoding features.y=list(feature_matrix.pop('label'))X=pd.get_dummies(feature_matrix).valuesIn this example, we will use an 'xgb' regression pipeline to predict total power loss.fromzephyr_mlimportZephyrpipeline_name='xgb_regressor'zephyr=Zephyr(pipeline_name)To train the pipeline, we simply use thefitfunction.zephyr.fit(X,y)After it finished training,  we can make prediciton usingpredicty_pred=zephyr.predict(X)We can also usezephyr.evaluateto obtain the performance of the pipeline.What's Next?If you want to continue learning aboutZephyrand all its
features please have a look at the tutorials found inside thenotebooks folder.History0.0.2 - 2023-05-09SigPro integration for processing signalsIntegrating SigPro -Issue #7by @frances-h @sarahmishAdd options to xgb pipeline -Issue #5by @sarahmish0.0.1 - 2023-03-02New modeling module using Zephyr classExpand GH action tests -Issue #4by @sarahmishAdd XGB Pipeline -Issue #1by @sarahmish0.0.0 - 2022-11-17First full releasePrediction Engineering Framework by @frances-hEntitySet creation by @frances-hDataLabeler and initial labeling functions by @frances-h