shapiromatron / bmds Goto Github PK
View Code? Open in Web Editor NEWA Python API to EPA's BMDS software
License: MIT License
A Python API to EPA's BMDS software
License: MIT License
The allowable range for the BDM cutoff-value on benchmarkdose.com only works for increasing dose-response data because of the code
if not domain[0] < self.adversity_value < domain[1]:
raise ValueError(
'Adversity value not in allowable domain: {} ({} - {})'
.format(self.adversity_value, domain[0], domain[1]))
in base.py. Instead
if not min(domain) < self.adversity_value < max(domain):
raise ValueError(
'Adversity value not in allowable domain: {} ({} - {})'
.format(self.adversity_value, min(domain), max(domain))
might work?
Thanks.
https://github.com/shapiromatron/bmds/blob/main/bmds/bmds3/sessions.py
(or subclass parent if exists) so that a session can generate a word report.to_dict
method. Much of the code for the various tables are already available here, https://github.com/shapiromatron/bmds-server/pull/62/files; hopefully we can remove most of the content from the bmds-server and move hereMuch of the reporting code currently is an MVP; feel free to revise, tune, and restructure (and built common helper methods if the same patterns are repeated).
Successfully installed on Ubuntu 18.10:-
Successfully installed bmds-0.10.0 python-docx-0.8.7 simple-settings-0.13.0
This is what I get on loading the library:-
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bmds
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/bmds/__init__.py", line 6, in <module>
from .session import * # noqa
File "/usr/local/lib/python2.7/dist-packages/bmds/session.py", line 126
async def execute_models(self):
^
SyntaxError: invalid syntax
Any ideas?
When running the code from the README documentation with pydantic version > 2, an error occurs.
Traceback (most recent call last):
File "/Users/eric/3bms/test.py", line 4, in
dataset = bmds.DichotomousDataset(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/eric/3bms/.venv/lib/python3.11/site-packages/bmds/datasets/dichotomous.py", line 44, in init
self.metadata = DatasetMetadata.parse_obj(metadata)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/eric/3bms/.venv/lib/python3.11/site-packages/typing_extensions.py", line 2360, in wrapper
return arg(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/Users/eric/3bms/.venv/lib/python3.11/site-packages/pydantic/main.py", line 1010, in parse_obj
return cls.model_validate(obj)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/eric/3bms/.venv/lib/python3.11/site-packages/pydantic/main.py", line 503, in model_validate
return cls.pydantic_validator.validate_python(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for DatasetMetadata
Update the code so the models can also be executed on windows. At this point, do not include the dynamic link libraries, consistent with how the code is currently handled for the non-windows environment.
Add additional word report options at the session and batch level:
The options should be as follows:
dataset_format_long: bool=True
- should data be written in long format? #58verbose_model_outputs:bool = False
- if True, all output models are written (the current case). If False (the new default), only write outputs for the frequentist selected model, if one exists. For bayesian, if this is False, then individual model outputs will not be reportedbmd_cdf_table: bool=False
- should the cdf table be printed for each model? If true, show the CDF table (percentile and BMD), otherwise do not print table (default)Model recommendation logic and rules already existing for bmds2, but it's likely that the current implementation is tuned specifically to the outputs from bmds2 which are structured differently than bmds3.
Investigate what needs to be done to update the bmds.logic
package so that it works for both bmds2 and bmds3. If it makes sense, it would be fine to move the existing logic into bmds.bmds2.logic
, and start fresh with bmds.bmds3.logic
. Do what is most efficient based on developer time; bmds2 code will likely be used very little in the future so future maintenance of bmds3 code is more important than compatibility with bmds2.
The decision logic can be modified by a user when setting up a session; the default logic can be found in the "payload" variable in this notebook: https://github.com/shapiromatron/bmds-server/blob/main/scripts/bmds-online-33-api.ipynb
Acceptance criteria: A set of unit tests can be written for executing new bmds3 modeling and recommendation logic can be applied. The tests should demonstrate both using default recommendation logic (aka, nothing is specified), as well as custom logic (for example, disabling a test or changing comparison values, etc). For now, we can focus exclusively on dichotomous models when testing.
Related work:
Our goal here is to build all models for saving the rules using Pydantic so we can serialize and deserialize the logic provided by the user.
Based on recent user feedback on the existing word reports:
write_models
methodIn addition to showing docx tables for individual model outputs, show a complete text-output report for each model.
To do this, update the bmds/bmds3/types/dichotomous:DichotomousResult
object and add a new text()
method which constructs a full text report from the data in the tbl()
method for the parent object and child objects.
Consistent with 143, update word report to print individual datasets using a group by for the dataset.
To develop/test:
from pathlib import Path
import bmds
cids = bmds.ContinuousIndividualDataset(
doses=[
0, 0, 0, 0, 0, 0, 0, 0,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
1, 1, 1, 1, 1, 1,
10, 10, 10, 10, 10, 10,
100, 100, 100, 100, 100, 100,
300, 300, 300, 300, 300, 300,
500, 500, 500, 500, 500, 500,
],
responses=[
8.1079, 9.3063, 9.7431, 9.781, 10.052, 10.613, 10.751, 11.057,
9.1556, 9.6821, 9.8256, 10.2095, 10.2222, 12.0382,
9.5661, 9.7059, 9.9905, 10.2716, 10.471, 11.0602,
8.8514, 10.0107, 10.0854, 10.5683, 11.1394, 11.4875,
9.5427, 9.7211, 9.8267, 10.0231, 10.1833, 10.8685,
10.368, 10.5176, 11.3168, 12.002, 12.1186, 12.6368,
9.9572, 10.1347, 10.7743, 11.0571, 11.1564, 12.0368
]
)
session = bmds.session.Bmds330(dataset=cids)
session.add_model(bmds.constants.M_Power)
session.execute_and_recommend()
docx = session.to_docx()
docx.save(Path("~/Desktop/bmds3-batch.docx").expanduser())
After completion of shapiromatron/bmds-server#94, update the word report to build the same individual model output tables in the word report.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.