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 #499

Merged
merged 53 commits into from
Oct 19, 2021
Merged

Delphi modeling 1 #499

merged 53 commits into from
Oct 19, 2021

Conversation

manujinda
Copy link
Collaborator

Initial head node seasonal model implementation.

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

Delphi macro timing.

Regression testing.

Synthetic CAG and data generation.

Other code improvements.

Manujinda Wathugala and others added 30 commits May 10, 2021 15:04
The external function should provide the derivative at each time point.
This is the dumbest model. Each root node predict close to the average
of the observation series.
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.
1. Need to do more:
   a. Cleaning
   b. Testing
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.
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.
* 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>
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.
* 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>
Added some methods to generate a random CAG and populate it with
synthetic observations.
1. Made the code more modularized

2. Removed some debug print lines
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.
Manujinda Wathugala and others added 23 commits August 30, 2021 11:25
This caused a chunk of repeated code. I feel that using a separate class
to handle the delphi.db is a better approach.
The initial implementation of generating a cyclic curve using a LDS
based on Fourier analysis.
* 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>
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.
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.
Changed "independent node" to "head node"
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.
…delphi_modeling_1

Had to resolve some conflicts.
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.
…delphi_modeling_1

Added mean and standard deviation of the snapshot differences to the
plot produced by snap_diff.py script
* 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>
@manujinda manujinda merged commit 5ba83de into master Oct 19, 2021
@manujinda manujinda deleted the delphi_modeling_1 branch October 19, 2021 21:52
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