tisimst / pydoe Goto Github PK
View Code? Open in Web Editor NEWDesign of experiments for Python
License: BSD 3-Clause "New" or "Revised" License
Design of experiments for Python
License: BSD 3-Clause "New" or "Revised" License
There is an issue with the fracfact() function when specifying the generator.
The following code should give me a 2^(3-1) design in 4 runs
gen = 'a b ab'; fracfact(gen)
But instead it treats the the generator string as "a b a b" and gives me a 2^4 design in 16 runs.
This comes from the following code in the fracfact() function:
A = [item for item in re.split('\-?\s?\+?', gen) if item]
The regex string should be '-?\s+?', this way the space isn't optional and it treats a string 'ab' as an interaction and not as two factor 'a' 'b' put together.
Excuse me.
As I know, full-factorial design can manipulate all the main and interaction effects already. The meaning of fraction factorial design is to reduce the runs based on that some interaction have little effect, such as some high-order interactions.
Why do I need "fracfact" if the runs of "fracfact" is equal or even bigger than the runs of "ff2n"?
Just because "fracfact" can list the columns of interaction?
Hi, I am using pyDOE for generating box Behnken and I got an error:
File "/root/anaconda3/lib/python3.6/site-packages/pyDOE/doe_repeat_center.py", line 43, in repeat_center
return np.zeros((repeat, n))
TypeError: 'float' object cannot be interpreted as an integer
I think the problem is in line 73 from the file pyDOE/doe_box_behnken:
nb_lines = (n*(n-1)/2)*H_fact.shape[0]
when I modify the above line to
nb_lines = int((n*(n-1)/2)*H_fact.shape[0])
it works well
I am using full fact. This was working fine until this morning. I got:
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scipy/special/_ufuncs.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace (_npy_asinh)
I believe that this is an issue with Apple Silicon. I did not find a solution (that I understood how to implement).
Suggestions would be greatly appreciated.
Model Name: MacBook Pro
Model Identifier: MacBookPro18,3
Chip: Apple M1 Pro
Total Number of Cores: 10 (8 performance and 2 efficiency)
Memory: 32 GB
System Firmware Version: 7459.141.1
OS Loader Version: 7459.141.1
I think maybe you should transpose the matrix (2D array) of Hcandidate (Hcandidate.T) in order to get the correct correlation matrix? The numpy documents states each row is associated with the samples of one variable (which is different from MATLAB). Thanks!
The code would be much more flexible if you passed a numpy random state in and used that for the random draws. Object oriented random number generator would allow the user to create and manage multiple lhs (and other) designs simultaneously.
def lhs(rstate, n, samples=None, criterion=None, iterations=None):
"""
Generate a latin-hypercube design
Parameters
rstate : np.random.RandomState
Random state which controls the seed and random draws
An example use is:
# set the random state once for each independent design
rstate = np.random.RandomState(master_seed)
# in the source code the draw is now controlled by the explicit random state object
u = rstate.rand(samples, n) # instead of np.random.rand(samples, n)
This design philosophy is much more flexible.
setup.py
imports pyDOE
, so this can't be installed unless it's already installed. A catch-22.
make html in doc
pyDOE2/doc/conf.py", line 59, in
release = pyDOE2.version
AttributeError: module 'pyDOE2' has no attribute 'version'
I get this result:
Python 2.7.5+ (default, Sep 19 2013, 13:48:49)
Type "copyright", "credits" or "license" for more information.
IPython 1.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from pyDOE import *
In [2]: bbdesign(3)
Out[2]:
array([[-3., -3., 0.],
[ 1., -3., 0.],
[-3., 1., 0.],
[ 1., 1., 0.],
[-3., 0., -3.],
[ 1., 0., -3.],
[-3., 0., 1.],
[ 1., 0., 1.],
[ 0., -3., -3.],
[ 0., 1., -3.],
[ 0., -3., 1.],
[ 0., 1., 1.],
[ 0., 0., 0.],
[ 0., 0., 0.],
[ 0., 0., 0.]])
Instead of this:
Help on function bbdesign in module pyDOE.doe_box_behnken:
...
Example
-------
::
>>> bbdesign(3)
array([[-1., -1., 0.],
[ 1., -1., 0.],
[-1., 1., 0.],
[ 1., 1., 0.],
[-1., 0., -1.],
[ 1., 0., -1.],
[-1., 0., 1.],
[ 1., 0., 1.],
[ 0., -1., -1.],
[ 0., 1., -1.],
[ 0., -1., 1.],
[ 0., 1., 1.],
[ 0., 0., 0.],
[ 0., 0., 0.],
[ 0., 0., 0.]])
The issue seems to be that we're getting -3s instead of -1s. Something similar seems to be happening in ccdesign
.
@tisimst Thank you for an extremely useful library. I am creating a conda recipe to build it for conda-forge: https://github.com/conda-forge
Would you consider adding tag for the newest version on github. Just add a git tag with the string 0.3.8
. That would make it simpler to refer to a specific version on github, and simplify the recipe a bit.
You can see the proposed recipe here: conda-forge/staged-recipes#1046
Hi,
I get the following TypeError with newer versions of Python. Any suggestions how to fix this?
Kind regards,
e-neu
pyDOE.fullfact([1, 2])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-65-d26355a11123> in <module>()
----> 1 pyDOE.fullfact([1, 2])
C:\Users\XXX\AppData\Roaming\Python\Python35\site-packages\pydoe-0.3.8-py3.5.egg\pyDOE\doe_factorial.py in fullfact(levels)
76 for j in range(levels[i]):
77 lvl += [j]*level_repeat
---> 78 rng = lvl*range_repeat
79 level_repeat *= levels[i]
80 H[:, i] = rng
TypeError: 'numpy.float64' object cannot be interpreted as an integer
import sys
sys.version
'3.5.2 |Anaconda custom (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]'
import pyDOE
pyDOE.__version__
'0.3.8'
bbdesing is not working on Python 3.8.5
This is the error if I try to run the example in the docstring
----> 1 doe.bbdesign(3)
~/virtual_enviroments/hamopt/lib/python3.8/site-packages/pyDOE/doe_box_behnken.py in bbdesign(n, center)
64
65 # First, compute a factorial DOE with 2 parameters
---> 66 H_fact = ff2n(2)
67 # Now we populate the real DOE with this DOE
68
~/virtual_enviroments/hamopt/lib/python3.8/site-packages/pyDOE/doe_factorial.py in ff2n(n)
113
114 """
--> 115 return 2*fullfact([2]*n) - 1
116
117 ################################################################################
~/virtual_enviroments/hamopt/lib/python3.8/site-packages/pyDOE/doe_factorial.py in fullfact(levels)
76 for j in range(levels[i]):
77 lvl += [j]*level_repeat
---> 78 rng = lvl*range_repeat
79 level_repeat *= levels[i]
80 H[:, i] = rng
TypeError: can't multiply sequence by non-int of type 'numpy.float64'
Hi,
I am playing with the latin hypercube samper and was wondering if there is
a way to set the random seed somewhere.
Thanks,
Holger
I think using Patsy would be nice: http://patsy.readthedocs.org/
I work on a team that would like to use the Latin Hypercube from PyDOE
. But I note there is no unit testing on this project.
If I were to build a set of unit tests (say with pytest
) and have them run via GitHub Actions, would you accept the PR?
(I notice there is not a lot of movement on the project in the last few years, so this may not be an option.)
when I try n=60 I do get a return array
but for 61 or 64 I get an error
as if that isnt a 4-fold...
while it works for n=17 :-)
How to get a PB design for large numbers of uncertainties (>48 .. 500)?
Erik
AssertionError Traceback (most recent call last)
in
11 # # Plackett-Burman, by concept, ignoring Factors, then merge all PB designs over all concepts into one JS table
12 # PB_Design_Array = pbdesign(NrFeatures_Concept)
---> 13 PB_Design_Array = pbdesign(64)
14 print(f' PB_Design_Array:=<{PB_Design_Array}>\n PB_Design_Array.shape={PB_Design_Array.shape}')
~\AppData\Local\Programs\Python\Python37\lib\site-packages\pyDOE\doe_plackett_burman.py in pbdesign(n)
67 k = [idx for idx, val in enumerate(np.logical_and(f==0.5, e>0)) if val]
68
---> 69 assert isinstance(n, int) and k!=[], 'Invalid inputs. n must be a multiple of 4.'
70
71 k = k[0]
AssertionError: Invalid inputs. n must be a multiple of 4.
(doe) LC25423:Envs corti938$ ipython
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.1.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from pyDOE import *
In [2]: import pyDOE
In [3]: pyDOE.version
Out[3]: '0.3.8'
TypeError Traceback (most recent call last)
in
----> 1 fullfact([2, 3])
~/my_codes/Envs/doe/lib/python3.6/site-packages/pyDOE/doe_factorial.py in fullfact(levels)
76 for j in range(levels[i]):
77 lvl += [j]level_repeat
---> 78 rng = lvlrange_repeat
79 level_repeat *= levels[i]
80 H[:, i] = rng
TypeError: can't multiply sequence by non-int of type 'numpy.float64'
Just a heads-up:
There's a mixup with the name for the correlation criterion for the Latin Hypercube. In doe_lhs.py
, the documentation says "correlation"
but the example says 'correlate'
. The check in the code uses 'correlation'
, but later the if that actually selects the used function uses 'correlate'
.
36: "centermaximin" or "cm", and "correlation" or "corr". If no value
88: >>> lhs(4, samples=5, criterion='correlate', iterations=10)
98: 'centermaximin', 'cm', 'correlation',
116: elif criterion.lower() in ('correlate', 'corr'):
Thanks!
how to install Latin Hypercube Sampling with multi-dimensional uniformity (lhsmdu) packages in python & anaconda?
The correlation coefficient in _lhscorrelate is calculated as:
R = np.corrcoef(Hcandidate)
According to NumPy documentation, this function expects each row to be a variable; however, lhs treats the columns as variables. The correct way to calculate the correlation coefficient should be:
R = np.corrcoef(Hcandidate, rowvar=False)
Hi,
The package on pip doesn't have the fix for the bug outlined in issue #8.
Would it be possible to release a new version?
cheers
Hi
I am new to Python. I am using miniconda. I installed pyDOE using conda install -c conda-forge pydoe
When I run the ccdesign command,
ccdesign(2)
I get the following error -
File "", line 1, in
pyDOE.ccdesign(2)
File "/home/home_shihab/miniconda3/lib/python3.6/site-packages/pyDOE/doe_composite.py", line 151, in ccdesign
H1 = ff2n(n)
File "/home/home_shihab/miniconda3/lib/python3.6/site-packages/pyDOE/doe_factorial.py", line 115, in ff2n
return 2*fullfact([2]n) - 1
File "/home/home_shihab/miniconda3/lib/python3.6/site-packages/pyDOE/doe_factorial.py", line 78, in fullfact
rng = lvlrange_repeat
TypeError: 'numpy.float64' object cannot be interpreted as an integer
What should I do?
In Python 3.6.0, numpy 1.11.3, the following warnings appear:
C:\Users\######\AppData\Local\Continuum\Anaconda3\lib\site-packages\pydoe-0.3.8-py3.6.egg\pyDOE\doe_repeat_center.py:43: VisibleDep
recationWarning: using a non-integer number instead of an integer will result in an error in the future
.C:\Users\######\AppData\Local\Continuum\Anaconda3\lib\site-packages\pydoe-0.3.8-py3.6.egg\pyDOE\doe_factorial.py:78: VisibleDeprec
ationWarning: using a non-integer number instead of an integer will result in an error in the future
At least one of them appears to be due to this line in bbdesign:
nb_lines = (n*(n-1)/2)*H_fact.shape[0]
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.