A small Solver
Project description
Fast Iterative Multi Fitter framework
This package was written with the intention to speed up the process of fitting models to data. The mathematical model is expressed as a set of lambda functions which can have circular references to itself and other components. Pandas dataframes are used as an internal format and for mapping data to the lambdafunctions. A set of convenience functions is supplied to ease loading data, loading coefficients, plotting errors and more.
Below an example lambdadict and lambdamap are shown.
- In Lambdamap $ is used to assign coefficients, these will be modified with the fitting methods
- Constants are indicated with a * and are not modified.
lambdaMap = {"Qtr": ["Tobj","Tenv","$U"],
"Qsol":["Psol"],
"Qel":["Pe"],
"dTobj":["Qtr","Qsol","Qel","dt","$C"],
"Tobj":["Tobj","dTobj"]}
lambdaDict = {"Qtr": lambda Tobj, Tenv, U: (Tenv-Tobj)*0.001/ U,
"Qsol": lambda Psol: Psol*0.001,
"Qel": lambda Pe: Pe*0.001,
"dTobj": lambda Qtr, Qsol, Qel, dt, C: (Qtr+Qsol+Qel)*dt/C,
"Tobj": lambda Tobj, dTobj: Tobj + dTobj}
Instantiate the class
- prototype:
fmf = MultiFitter(lambdaMap=None,lambdaDict=None,verbose=0)
Load Data
- Profilegenerator is included and generates some dummy data
SimThis - load data with
fmf.loadData(SimThis,initPredictors=True) - loadData expects a pandas dataframe with column names as defined in lambdaMap
Possibly provide some constraints and run the model on the data
- A dictionary with "name":[min,max]" values can be supplied to limit the search space
SMap = {"U":[0.01,25.0],"C":[10,2000]}error = fmf.BulkError([25.0,300],"Tobj")errors = fmf.BulkEvolver("Tobj",constraints=SMap)errorsscipy = fmf.scipyOptimize("Tobj",constraints=SMap)
The BulkError method will return the accumulated error for the provided coefficients, where Tobj is the target predictor, for error calculation. The BulkEvolver method will return an array of arrays sorted from best to worst: [[error,c0,c1,c2,cn]] where c0,c1,cn are the coefficients in order. Errorsscipy will return the result of nelder-mead scipy solver. Constraints are optional.
Analyze results
- All mentioned methods already provide some form of error-coefficient feedback to make quick decisions.
- with
fmf.plotError(All=True)a 3-dimensional chart will be given for each parameter with index,error,coefficient as axis. - with
fmf.loadConstants(constDict=dict)a dictionary with "name":value pairs will be set for internal coefficients. - with
fmf.ArrayToConstants(array)an array with ordered coefficients will be applied for future calculations. - with
fmf.resetIndex()the index is reset to the beginning of the dataset - with
Simulation = fmf.simulate(fmf.dataLength,"Tobj")[-fmf.datalength:]a fresh simulation will be stored, note that this returns an array with [index,error,y,y-predicted,c0,c1,c2,cn...] - To plot this nicely plotly is suitable; make sure that the pandas plotting backend is set to plotly
- `pd.DataFrame(Simulation,columns=fmf.columns).plot()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mufit-0.0.1.tar.gz.
File metadata
- Download URL: mufit-0.0.1.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81b44f2bc374b859cd4d1a87f4a787dfd982f764fbf6d240c4e17dbd57889d83
|
|
| MD5 |
905da659815c454d1585b87b08d08b48
|
|
| BLAKE2b-256 |
40cd28ec024af9b932166c5bdf6169682adaae9df06a675a8cbdb61dbd0769b6
|
File details
Details for the file mufit-0.0.1-py3-none-any.whl.
File metadata
- Download URL: mufit-0.0.1-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bcbdb56e48cbb099efd6f55812f7068e7bc2f183be229b607f9db23aea98258
|
|
| MD5 |
2f8547c66212cf0ec1ebaf2b5374fe32
|
|
| BLAKE2b-256 |
ae0ffe986e2f590ffeed4f7a77421ca5f9806493227b3002ab5f4d5731cf8f2b
|