Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delphi modeling 1 dev #498

Merged
merged 3 commits into from
Oct 19, 2021
Merged

Delphi modeling 1 dev #498

merged 3 commits into from
Oct 19, 2021

Conversation

manujinda
Copy link
Collaborator

Initial implementation of the fully matrix exponential compatible periodic curve generation.

Manujinda Wathugala added 3 commits October 19, 2021 11:50
Implemented and debugged. Based on the Fourier decomposition.

As per my tests, it is working.
@manujinda manujinda merged commit 6e408cd into delphi_modeling_1 Oct 19, 2021
@manujinda manujinda deleted the delphi_modeling_1_dev branch October 19, 2021 21:22
manujinda added a commit that referenced this pull request Oct 19, 2021
* Allowed to ground some nodes of the cag with external functions.

The external function should provide the derivative at each time point.

* Added code to distinguish between dependent and independent nodes of the
CAG.

* Modeling root nodes separately.

This is the dumbest model. Each root node predict close to the average
of the observation series.

* A script to analyze and visualize rain data

or any time series data.

* Experimenting with using partition median and relative change between
partitions.

* Tidying up the head node modeling code

* More tidying up head node modeling code.

* more tyding up head node modeling code

* more tyding up head node modeling code

* fixed a logical bug

* Added another graph

* The head node model that was demoed for 2021 June embed.

* Updated the head node modeling code with a guard to prevent a segmentation fault happening on old test code

* Updated the code so that:

1. All the programs compile.

2. All the tests pass.

However all the executions are not correct. The head node modeling
components are not properly integrated with CauseMos.

* Integrated head node modeling component with Causemose

1. Need to do more:
   a. Cleaning
   b. Testing

* Pached an old (could be obsolete) method to fix a segmentation fault in an old test

* Accumulating log likelihoods

1. Remember the sequence of log likelihoods throughout the sampling
process including burning.

2. Complete state now includes the log likelihood sequence.

3. Plotting function now plots the log likelihoods.

* MAP Sample

1. Added code to identify and retain the MAP sample even if we encounter
during the burning period.

2. If we encounter the MAP sample within the burning period it is always
put at res - 1 position of the retained samples and we reduce the number
of samples retained during the sample resolution period by 1.

3. Finally delphi remembers the index of the MAP sample withing the
retained samples.

Note: There are some (or more) repeated code in this push and previous
ones that needs to be cleaned up when there is more time.

* Fixed a place that gave a segmentation fault due to faulty logic

* Fixed an initialization bug

* MAP Estimate (#492)

* Accumulating log likelihoods

1. Remember the sequence of log likelihoods throughout the sampling
process including burning.

2. Complete state now includes the log likelihood sequence.

3. Plotting function now plots the log likelihoods.

* MAP Sample

1. Added code to identify and retain the MAP sample even if we encounter
during the burning period.

2. If we encounter the MAP sample within the burning period it is always
put at res - 1 position of the retained samples and we reduce the number
of samples retained during the sample resolution period by 1.

3. Finally delphi remembers the index of the MAP sample withing the
retained samples.

Note: There are some (or more) repeated code in this push and previous
ones that needs to be cleaned up when there is more time.

* Fixed a place that gave a segmentation fault due to faulty logic

* Fixed an initialization bug

Co-authored-by: Manujinda Wathugala <manujinda@email.arizona.edu>

* Fixed a bug

The seasonality was not visible when Delphi was invoked through the
CauseMos interface. When a model is created, each concept’d period for
seasonality is inferred from data. However, it was not saved into the
serialized model.

When creating an experiment, an AnalysisGraph object is created by
deserializing the saved model. Since concept periods were not saved all
the concepts ended up having the default period of 1.

* Delphi modeling 1 dev (#493)

* Accumulating log likelihoods

1. Remember the sequence of log likelihoods throughout the sampling
process including burning.

2. Complete state now includes the log likelihood sequence.

3. Plotting function now plots the log likelihoods.

* MAP Sample

1. Added code to identify and retain the MAP sample even if we encounter
during the burning period.

2. If we encounter the MAP sample within the burning period it is always
put at res - 1 position of the retained samples and we reduce the number
of samples retained during the sample resolution period by 1.

3. Finally delphi remembers the index of the MAP sample withing the
retained samples.

Note: There are some (or more) repeated code in this push and previous
ones that needs to be cleaned up when there is more time.

* Fixed a place that gave a segmentation fault due to faulty logic

* Fixed an initialization bug

* Fixed a bug

The seasonality was not visible when Delphi was invoked through the
CauseMos interface. When a model is created, each concept’d period for
seasonality is inferred from data. However, it was not saved into the
serialized model.

When creating an experiment, an AnalysisGraph object is created by
deserializing the saved model. Since concept periods were not saved all
the concepts ended up having the default period of 1.

Co-authored-by: Manujinda Wathugala <manujinda@email.arizona.edu>

* Generating synthetic CAGs

Added some methods to generate a random CAG and populate it with
synthetic observations.

* Cleanup

1. Made the code more modularized

2. Removed some debug print lines

* More cleaning

1. Removed commented code

2. Moved a block of code to make some repeated code identical in two
places. I did not refactor that into a separate method since it is only
a few lines of code and those few lines alone does not create a coherent
functionality.

* Created a class to perform timing

* Fixed CMakeLists.txt

* Changed a file name

* A basic macro profiler completed.

* Added some progress messages to the timer.

* Added proper error checking for opening delphi.db

This caused a chunk of repeated code. I feel that using a separate class
to handle the delphi.db is a better approach.

* Improved the newly created delphi.db open method to accept the database
open mode.

* Improved the Delphi macro timing program to accept command line options.

* Removed inclusion of dbg.h in main source files.

* Fixed the help option in timer.

* The june embed jupytre notebook got opened and some version number got chaned

* Seasonal curve from a Fourier series

The initial implementation of generating a cyclic curve using a LDS
based on Fourier analysis.

* Commented out some unused synthetic data generating methods.

Updated the timing program a bit.

* Deleted commented code related to synthetic data generation.

* Delphi modeling 1 dev (#496)

* Accumulating log likelihoods

1. Remember the sequence of log likelihoods throughout the sampling
process including burning.

2. Complete state now includes the log likelihood sequence.

3. Plotting function now plots the log likelihoods.

* MAP Sample

1. Added code to identify and retain the MAP sample even if we encounter
during the burning period.

2. If we encounter the MAP sample within the burning period it is always
put at res - 1 position of the retained samples and we reduce the number
of samples retained during the sample resolution period by 1.

3. Finally delphi remembers the index of the MAP sample withing the
retained samples.

Note: There are some (or more) repeated code in this push and previous
ones that needs to be cleaned up when there is more time.

* Fixed a place that gave a segmentation fault due to faulty logic

* Fixed an initialization bug

* Fixed a bug

The seasonality was not visible when Delphi was invoked through the
CauseMos interface. When a model is created, each concept’d period for
seasonality is inferred from data. However, it was not saved into the
serialized model.

When creating an experiment, an AnalysisGraph object is created by
deserializing the saved model. Since concept periods were not saved all
the concepts ended up having the default period of 1.

* Generating synthetic CAGs

Added some methods to generate a random CAG and populate it with
synthetic observations.

* Cleanup

1. Made the code more modularized

2. Removed some debug print lines

* More cleaning

1. Removed commented code

2. Moved a block of code to make some repeated code identical in two
places. I did not refactor that into a separate method since it is only
a few lines of code and those few lines alone does not create a coherent
functionality.

* Created a class to perform timing

* Fixed CMakeLists.txt

* Changed a file name

* A basic macro profiler completed.

* Added some progress messages to the timer.

* Added proper error checking for opening delphi.db

This caused a chunk of repeated code. I feel that using a separate class
to handle the delphi.db is a better approach.

* Improved the newly created delphi.db open method to accept the database
open mode.

* Improved the Delphi macro timing program to accept command line options.

* Removed inclusion of dbg.h in main source files.

* Fixed the help option in timer.

* The june embed jupytre notebook got opened and some version number got chaned

* Seasonal curve from a Fourier series

The initial implementation of generating a cyclic curve using a LDS
based on Fourier analysis.

* Commented out some unused synthetic data generating methods.

Updated the timing program a bit.

* Deleted commented code related to synthetic data generation.

Co-authored-by: Manujinda Wathugala <manujinda@email.arizona.edu>

* Added a stub to export a create model json file.

This should output a create model json file that would create the
untrained model of the object the method export_create_model_json_string()
is called upon.

This method would be mostly used to output synthetic CAGs with synthetic
data into create model json files so that we could run the training
pipeline on those models in a freshly created object other than the
object that was used to generate the synthetic CAG to prevent any
ground truth parameter values leaking from the synthetic CAG generation
process into the training process.

To aid assess the goodness of training, it would be beneficial to store
the ground truth parameters of the CAG that generated the data in a
separate additional section of the create model json produced.

* Updated the debugger.py script to test synthetic CAG generation.

* Updated the seasonal_fourier.py script

1. Removed some commented code.

2. Updated transition matrix and initial state to match the math I wrote
in the WorldModelers document.

3. Tried to make the transition matrix matrix exponential compatible. It
did not work.

* Changing terminology

Changed "independent node" to "head node"

* Some refactoring

Moved the timer.cpp app that performs macro timing of Delphi into apps
folder from scripts folder.

Adding the timing_analysis.py script that plots the timing results
collected by timer.cpp app.

* Removed a duplicate copy of timer.cpp in scripts folder

* Added two scripts to perform some regression testing:

take_model_snapshot.py
Takes a snapshot of a how Delphi works at a particular point of its implementation
A snapshot taken before and a snapshot taken after a code change such as an
optimization or refactoring could be used to verify whether the accuracy of the
code got changed as a byproduct of the changes made to the code. If there is no
change at all, the before and after snaps should be identical.

take_model_snapshot.py
Compares two snapshots of how Delphi worked at two points of its implementation
A snapshot taken before and a snapshot taken after a code change such as an
optimization or refactoring could be compared to verify whether the accuracy of the
code got changed as a byproduct of the changes made to the code. If there is no
change at all, the before and after snaps should be identical and the plots produced
by this script should be a single bar at zero.

* Added mean and standard deviation of the snapshot differences to the
plot produced by snap_diff.py script

* Delphi modeling 1 dev (#498)

* Fully matrix exponential compatible periodic LDS.

Implemented and debugged. Based on the Fourier decomposition.

As per my tests, it is working.

* Deleted a lot of commented code and print statements.

* Did some more cleaning.

Co-authored-by: Manujinda Wathugala <manujinda@email.arizona.edu>

Co-authored-by: Manujinda Wathugala <manujinda@email.arizona.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant