{"id":15634018,"url":"https://github.com/tirthajyoti/doepy","last_synced_at":"2025-04-05T21:06:26.741Z","repository":{"id":45426130,"uuid":"198116865","full_name":"tirthajyoti/doepy","owner":"tirthajyoti","description":"Design of Experiment Generator. Read the docs at: https://doepy.readthedocs.io/en/latest/","archived":false,"fork":false,"pushed_at":"2024-02-05T23:02:32.000Z","size":5951,"stargazers_count":158,"open_issues_count":17,"forks_count":41,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T20:06:36.802Z","etag":null,"topics":["design","design-of-experiments","doe","engineering","factorial-experiment","phsyics","python","random-design","research","science","statistics"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tirthajyoti.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-21T23:56:34.000Z","updated_at":"2025-03-28T06:56:14.000Z","dependencies_parsed_at":"2024-06-18T21:14:10.205Z","dependency_job_id":"7e9c1236-e4af-42ab-a30d-847a70fe7bd9","html_url":"https://github.com/tirthajyoti/doepy","commit_stats":{"total_commits":49,"total_committers":2,"mean_commits":24.5,"dds":"0.020408163265306145","last_synced_commit":"241576e219ee08813e4a7097548cb2cfe01a2ad6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tirthajyoti%2Fdoepy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tirthajyoti%2Fdoepy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tirthajyoti%2Fdoepy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tirthajyoti%2Fdoepy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tirthajyoti","download_url":"https://codeload.github.com/tirthajyoti/doepy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399873,"owners_count":20932876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["design","design-of-experiments","doe","engineering","factorial-experiment","phsyics","python","random-design","research","science","statistics"],"created_at":"2024-10-03T10:51:02.340Z","updated_at":"2025-04-05T21:06:26.714Z","avatar_url":"https://github.com/tirthajyoti.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Welcome to DOEPY\n=================\nDesign of Experiments Generator in Python (`pip install doepy`)\n------------------------------------------------------------------\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"500\" height=\"250\" src=\"https://raw.githubusercontent.com/tirthajyoti/doepy/master/images/doe_1.PNG\"\u003e\n\u003c/p\u003e\n\nAuthored and maintained by [Dr. Tirthajyoti Sarkar](https://www.linkedin.com/in/tirthajyoti-sarkar-2127aa7/), Fremont, California.\n\nCheck [my website](https://tirthajyoti.github.io) for details about my other projects and data science/ML articles.\n\n## Introduction\n---\n[Design of Experiments (DOE)](https://en.wikipedia.org/wiki/Design_of_experiments) is an important activity for any scientist, engineer, or statistician planning to conduct experimental analysis. This exercise has become **critical in this age of rapidly expanding field of data science and associated statistical modeling and machine learning**. A well-planned DOE can give a researcher a meaningful data set to act upon with the optimal number of experiments, thus preserving critical resources.\n\n\u003e After all, the aim of Data Science is essentially to conduct the highest quality scientific investigation and modeling with real world data. And to do good science with data, one needs to collect it through carefully thought-out experiments to cover all corner cases and reduce any possible bias.\n\n## How to use it?\n### What supporting packages are required?\nFirst make sure you have all the necessary packages installed. You can simply run the .bash (Unix/Linux) and .bat (Windows) files provided in the repo, to install those packages from your command line interface. They contain the following commands,\n\n```\npip install numpy\npip install pandas\npip install pydoe\npip install diversipy\n```\n\n### How to install the package?\n(On Linux and Windows) You can use ``pip`` to install ``doepy``::\n\n\tpip install doepy\n\n(On Mac OS), first install pip,\n```\ncurl https://bootstrap.pypa.io/get-pip.py -o get-pip.py\npython get-pip.py\n```\nThen proceed as above.\n\n### Github\nThe package is hosted at this **[Github repo](https://github.com/tirthajyoti/doepy)**.\n\n### Quick start\nLet's say you have a design problem with the following table for the parameters range. Imagine this as a generic example of a chemical process in a manufacturing plant. You have 3 levels of `Pressure`, 3 levels of `Temperature`, 2 levels of `FlowRate`, and 2 levels of `Time`.\n\nPressure | Temperature | FlowRate | Time\n------------ | ------------- | -------------|-----------------\n40 | 290 | 0.2 | 5\n50 | 320 | 0.3 | 8\n70 | 350 | - | -\n\nFirst, import `build` module from the package,\n\n```from doepy import build```\n\nThen, try a simple example by building a **full factorial design**. We will use `build.full_fact()` function for this. You have to pass a dictionary object to the function which encodes your experimental data.\n\n```\nbuild.full_fact(\n{'Pressure':[40,55,70],\n'Temperature':[290, 320, 350],\n'Flow rate':[0.2,0.4], \n'Time':[5,8]}\n)\n```\n\nIf you build a full-factorial DOE out of this, you should get a table with 3x3x2x2 = 36 entries.\n\nPressure | Temperature | FlowRate | Time\n------------ | ------------- | -------------|-----------------\n40 | 290 | 0.2 | 5\n50 | 290 | 0.2 | 5\n70 | 290 | 0.2 | 5\n40 | 320 | 0.2 | 5\n... | ... | ... | ...\n...| ... | ... | ...\n40 | 290 | 0.3 | 8\n50 | 290 | 0.3 | 8\n70 | 290 | 0.3 | 8\n40 | 320 | 0.3 | 8\n... | ... | ... | ...\n...| ... | ... | ...\n\nThere are, of course, half-factorial designs to try!\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"500\" height=\"250\" src=\"http://pcb.iconnect007.com/index.php/download_file/view_inline/6616/\"\u003e\n\u003c/p\u003e\n\n### Latin Hypercube design\nSometimes, a set of **randomized design points within a given range** could be attractive for the experimenter to asses the impact of the process variables on the output. [Monte Carlo simulations](https://en.wikipedia.org/wiki/Monte_Carlo_method) are a close example of this approach. \n\nHowever, a Latin Hypercube design is a better choice for experimental design rather than building a complete random matrix, as it tries to subdivide the sample space in smaller cells and choose only one element out of each subcell. This way, a more **uniform spreading of the random sample points** can be obtained. \n\nUser can choose the density of sample points. For example, if we choose to generate a Latin Hypercube of 12 experiments from the same input files, that could look like,\n```\nbuild.space_filling_lhs(\n{'Pressure':[40,55,70],\n'Temperature':[290, 320, 350],\n'Flow rate':[0.2,0.4], \n'Time':[5,11]},\nnum_samples = 12\n)\n```\n\nPressure | Temperature | FlowRate | Time\n------------ | ------------- | -------------|-----------------\n63.16 | 313.32 | 0.37 | 10.52\n61.16 | 343.88 | 0.23 | 5.04\n57.83 | 327.46 | 0.35 | 9.47\n68.61 | 309.81 | 0.35 | 8.39\n66.01 | 301.29 | 0.22 | 6.34\n45.76 | 347.97 | 0.27 | 6.94\n40.48 | 320.72 | 0.29 | 9.68\n51.46 | 293.35 | 0.20 | 7.11\n43.63 | 334.92 | 0.30 | 7.66\n47.87 | 339.68 | 0.26 | 8.59\n55.28 | 317.68 | 0.39 | 5.61\n53.99 | 297.07 | 0.32 | 10.43\n\nOf course, there is no guarantee that you will get the same matrix if you run this function because this are randomly sampled, but you get the idea!\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"400\" height=\"350\" src=\"http://sumo.intec.ugent.be/sites/sumo/files//sed_3d.png\"\u003e\u003c/p\u003e\n\n### Other functions to try\nTry any one of the following designs,\n\n* Full factorial: `build.full_fact()`\n* 2-level fractional factorial: `build.frac_fact_res()`\n* Plackett-Burman: `build.plackett_burman()`\n* Sukharev grid: `build.sukharev()`\n* Box-Behnken: ``build.box_behnken()``\n* Box-Wilson (Central-composite) with center-faced option: ``build.central_composite()`` with ``face='ccf'`` option\n* Box-Wilson (Central-composite) with center-inscribed option: ``build.central_composite()`` with ``face='cci'`` option\n* Box-Wilson (Central-composite) with center-circumscribed option: ``build.central_composite()`` with ``face='ccc'`` option\n* Latin hypercube (simple): ``build.lhs()``\n* Latin hypercube (space-filling): ``build.space_filling_lhs()``\n* Random k-means cluster: ``build.random_k_means()``\n* Maximin reconstruction: ``build.maximin()``\n* Halton sequence based: ``build.halton()``\n* Uniform random matrix: ``build.uniform_random()``\n\n### Read from and write to CSV files\n\nInternally, you pass on a dictionary object and get back a Pandas DataFrame. But, for reading from and writing to CSV files, you have to use the `read_write` module of the package.\n\n```\nfrom doepy import read_write\ndata_in=read_write.read_variables_csv('../Data/params.csv')\n```\n\nThen you can use this `data_in` object in the DOE generating functions.\n\nFor writing back to a CSV,\n\n```\ndf_lhs=build.space_filling_lhs(data_in,num_samples=100)\nfilename = 'lhs'\nread_write.write_csv(df_lhs,filename=filename)\n```\nYou should see a `lhs.csv` file in your directory.\n\n### A simple pipeline for building a DOE table\nCombining the `build` functions and the `read_write` module, one can devise a simple pipeline to build a DOE from a CSV file input.\n\nSuppose you have a file in your directory called `ranges.csv` that contains min/max values of an arbitrary number of parameters. Just two lines of code will generate a space-filling Latin hypercube design, based on this file, with 100 randomized samples spanning over the min/max ranges and save it to a file called `DOE_table.csv`.\n\n```\nfrom doepy import build, read_write\n\nread_write.write_csv(\nbuild.space_filling_lhs(read_write.read_variables_csv('ranges.csv'),\nnum_samples=100),\nfilename='DOE_table.csv'\n)\n```\n\n## Features\nAt its heart, `doepy` is just a collection of functions, which wrap around the core packages (mentioned below) and generate **design-of-experiment (DOE) matrices** for a statistician or engineer from an arbitrary range of input variables.\n\n### Limitation of the foundation packages used\nBoth the core packages, which act as foundations to this repo, are not complete in the sense that they do not cover all the necessary functions to generate a DOE table that a design engineer may need while planning an experiment. Also, they offer only low-level APIs in the sense that the standard output from them are normalized numpy arrays. It was felt that users, who may not be comfortable in dealing with Python objects directly, should be able to take advantage of their functionalities through a simplified user interface.\n\n### Simplified user interface\nThere are other DOE generators out there, but they generate n-dimensional arrays. `doepy` is built on the simple theme of being intuitive and easy to work with - for researchers, engineers, and social scientists of all background - not just the ones who can code.\n\n**User just needs to provide a simple CSV file with a single table of variables and their ranges (2-level i.e. min/max or 3-level).** \n\nSome of the functions work with 2-level min/max range while some others need 3-level ranges from the user (low-mid-high). Intelligence is built into the code to handle the case if the range input is not appropriate and to generate levels by simple linear interpolation from the given input.\n\nThe code will generate the DOE as per user's choice and write the matrix in a CSV file on to the disk. \n\nIn this way, **the only API user needs to be exposed to, are input and output CSV files**. These files then can be used in any engineering simulator, software, process-control module, or fed into process equipments.\n\n### Pandas DataFrame support\nUnder the hood, `doepy` generates Numpy arrays and convert them to Pandas DataFrame. Therefore, programmatically, it is simple to get those Numpy arrays or DataFrames to do more, if the user wishes so.\n\n### Coming in a future release - support for more types of files\nSupport for more input/output types will come in future releases - MS Excel, JSON, etc.\n\n### Designs available\n* Full factorial,\n* 2-level fractional factorial,\n* Plackett-Burman,\n* Sukharev grid,\n* Box-Behnken,\n* Box-Wilson (Central-composite) with center-faced option,\n* Box-Wilson (Central-composite) with center-inscribed option,\n* Box-Wilson (Central-composite) with center-circumscribed option,\n* Latin hypercube (simple),\n* Latin hypercube (space-filling),\n* Random k-means cluster,\n* Maximin reconstruction,\n* Halton sequence based,\n* Uniform random matrix\n\n## About Design of Experiment\n\n### What is a scientific experiment?\nIn its simplest form, a scientific experiment aims to predict the outcome by introducing a change of the preconditions, which is represented by one or more [independent variables](https://en.wikipedia.org/wiki/Dependent_and_independent_variables), also referred to as “input variables” or “predictor variables.” The change in one or more independent variables is generally hypothesized to result in a change in one or more [dependent variables](https://en.wikipedia.org/wiki/Dependent_and_independent_variables), also referred to as “output variables” or “response variables.” The experimental design may also identify [control variables](https://en.wikipedia.org/wiki/Controlling_for_a_variable) that must be held constant to prevent external factors from affecting the results.\n\n### What is Experimental Design?\nExperimental design involves not only the selection of suitable independent, dependent, and control variables, but planning the delivery of the experiment under statistically optimal conditions given the constraints of available resources. There are multiple approaches for determining the set of design points (unique combinations of the settings of the independent variables) to be used in the experiment.\n\nMain concerns in experimental design include the establishment of [validity](https://en.wikipedia.org/wiki/Validity_%28statistics%29), [reliability](https://en.wikipedia.org/wiki/Reliability_%28statistics%29), and [replicability](https://en.wikipedia.org/wiki/Reproducibility). For example, these concerns can be partially addressed by carefully choosing the independent variable, reducing the risk of measurement error, and ensuring that the documentation of the method is sufficiently detailed. Related concerns include achieving appropriate levels of [statistical power](https://en.wikipedia.org/wiki/Statistical_power) and [sensitivity](https://en.wikipedia.org/wiki/Sensitivity_and_specificity).\n\nThe need for careful design of experiment arises in all fields of serious scientific, technological, and even social science investigation — *computer science, physics, geology, political science, electrical engineering, psychology, business marketing analysis, financial analytics*, etc…\n\n### Options for open-source DOE builder package in Python?\nUnfortunately, the majority of the state-of-the-art DOE generators are part of commercial statistical software packages like [JMP (SAS)](https://www.jmp.com/) or [Minitab](www.minitab.com/en-US/default.aspx). However, a researcher will surely benefit if there is open-source code that presents an intuitive user interface for generating an experimental design plan from a simple list of input variables. There are a couple of DOE builder Python packages but individually they don’t cover all the necessary DOE methods and they lack a simplified user API, where one can just input a CSV file of input variables’ range and get back the DOE matrix in another CSV file.\n\n## Acknowledgements and Requirements\nThe code was written in Python 3.7. It uses following external packages that needs to be installed on your system to use it,\n\n* **`pydoe`**: A package designed to help the scientist, engineer, statistician, etc., to construct appropriate experimental designs. [Check the docs here](https://pythonhosted.org/pyDOE/).\n* **`diversipy`**: A collection of algorithms for sampling in hypercubes, selecting diverse subsets, and measuring diversity. [Check the docs here](https://www.simonwessing.de/diversipy/doc/).\n* **`numpy`**\n* **`pandas`**\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftirthajyoti%2Fdoepy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftirthajyoti%2Fdoepy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftirthajyoti%2Fdoepy/lists"}