This page documents the different functions available in the statease
Python module. The module is available on
pypi.org, and can be
installed with the Python package manager command, pip install statease
.
If you have not yet done this, you will need to follow the instructions in the
Python Introduction tutorial. This will guide you through
the process of installing the module, as well as configuring Stat-Ease
to use the correct Python environment.
There are several ways to run a Python script in SE360.
The recommended method is to simply open the script dialog via the Python button in the main toolbar. From there you can open your script, or create a new one. The dialog includes an editor with syntax highlighting and an output window.
You can also use the included se_console.exe executable to process a script from the command line. Simply pass the Python script you want to run as a parameter and it will run immediately.
"C:\Program Files\Stat-Ease 360\se_console.exe" example.py
Finally, you can use se_console.exe to run in “listen” mode by passing –listen as an argument. This will wait for a Python script running from an external interpreter (e.g. from another terminal, or from the JetBrains IDE) to connect and execute.
"C:\Program Files\Stat-Ease 360\se_console.exe" --listen
In order to interact with Stat-Ease, you first need to connect to it
using the statease.connect()
function. This will create a
statease.SEClient
instance that you will want to store. It is
used for high-level interaction with Stat-Ease.
Creates a connection to Stat-Ease 360.
>>> import statease as se
>>> se_conn = se.connect()
Creates an analysis for a response.
response_name (str) – The name of the response to analyze.
analysis_name (str) – The desired name for this analysis.
transform (str) – The transform to apply to the response for this analysis. The default is “No Transform”.
Creates a factor.
factor_name (str) – The name of the factor.
factor_levels (list) – The actual levels of the factor. For continuous factors this should simply be [low, high]. For categoric or discrete factors this should be a list of all valid factor levels. The default is [-1, 1].
factor_type (str) – The type of the factor. The default is “numeric”.
categoric_type (str) – If the factor type is “categoric”, this will set type of categoric factor (e.g. nominal or ordinal). The default is “nominal”.
Creates a response. :param str response_name: The desired name of the response. :param str response_units: The response units. :param str response_format: The format of the response values in the user interface. The default is “General”.
Deletes an analysis.
analysis_name (str) – The name of the analysis to delete.
Deletes a factor.
factor_name (str) – The name of the factor to delete.
Deletes a response.
response_name (str) – The name of the response to delete.
Retrieves a factor from the current design.
name (str) – The name of the factor. Case insensitive.
>>> import statease as se
>>> se_conn = se.connect()
>>> se_conn.get_factor("n-propanol")
name: “N-Propanol”
units: “wt %”
length: 20
Retrieve all Factor objects in the current design. :rtype: Python list of statease.factor.Factor objects
>>> import statease as se
>>> se_conn = se.connect()
>>> factors = se_conn.get_factors()
Retrieves the current value of a preference.
key (str) – The preference key. This can be found in the Stat-Ease 360 preference dialog.
Retrieves a response from the current design.
name (str) – The name of the response. Case insensitive.
>>> import statease as se
>>> se_conn = se.connect()
>>> se_conn.get_response("CFU")
name: “CFU”
units: “per cm^2”
length: 20
Retrieve all response objects in the current design. :rtype: Python list of statease.response.Response objects
>>> import statease as se
>>> se_conn = se.connect()
>>> responses = se_conn.get_responses()
Returns a list of all factor names in the current design.
Use get_factor()
to retrieve factor settings and row data.
>>> import statease as se
>>> se_conn = se.connect()
>>> se_conn.list_factors()
["A", "B", "C"]
Returns a list of all response names in the current design.
Use get_response()
to retrieve response settings and row data.
>>> import statease as se
>>> se_conn = se.connect()
>>> se_conn.list_responses()
["R1", "R2"]
Sets the comment on a row.
>>> se_conn.set_row_comment(1, 'Bad batch')
These functions allow you to interact with factors and responses in Stat-Ease, as well as other properties of the current design.
The Factor class holds information about an individual Factor in
Stat-Ease 360. Instances of this class are typically created by
statease.client.SEClient.get_factor()
name (str): the name of the factor
units (str): the units of the factor
values (tuple): the values of the factor, in run order
low (str, read only): the actual low that corresponds to the coded low (this is usually, but not necessarily, the minimum observed value)
high (str, read only): the actual high that corresponds to the coded high (this is usually, but not necessarily, the maximum observed value)
coded_low (str, read only): the coded low value, typically -1 or 0
coded_high (str, read only): the coded high value, typically 1
Get the coded factor values in the current coding.
>>> # get a list of the coded values
>>> xc = factor.coded_values
Test for categorical factor type.
>>> # get a list of the coded values
>>> # values if the factor is categorical
>>> x = []
>>> if (factor.is_categorical):
>>> x = factor.coded_values
>>> else: # Factor is not categorical
>>> x = factor.values
Get or set the factor values. When setting the factor values, you may use either a list or a dictionary. If fewer values are assigned than there are rows in the design, they will be filled in starting with first row. If a dictionary is used, it must use integers as keys, and it will fill factor values in rows indexed by the dictionary keys. The indices are 0-based, so the first row is index 0, the second index 1, and so on.
>>> # sets the first 4 rows to a list of values
>>> factor.values = [.1, .2, .3, .4]
>>> # sets the 7th through 10th rows to specific values
>>> factor.values = { 6: .1, 7: .2, 8: .3, 9: .4 }
>>> # sets the 6th run to a specific value
>>> factor.values = { 5: .8 }
The Response class holds information about an individual Response in
Stat-Ease 360. Instances of this class are typically created by
statease.client.SEClient.get_response()
.
name (str) – the name of the response
units (str) – the units of the response
values (list) – the values of the response, in run order
Simulates data for a response.
equation (str) – An equation that is recognized by the Stat-Ease 360 simulator. Search the help for “Equation Entry” for more information on the equation format.
std_dev (float) – This adds some normal error to each simulated value.
variance_ratio (float) – If there are groups in the design, inter-group variability will be simulated using a combination of this parameter and the std_dev parameter.
is_simulation (bool) – If False, sets the std_dev parameter to 0 and sets the response analysis to “equation only”. Use this to create a function that does not require regression analysis, but will availble in numerical optimization. Note: The default is true, but this parameter takes precendance over the std_dev parameter when False.
>>> response.simulate('a+b+sin(a)', std_dev=2) # A simulation with noise
>>> response.simulate('exp(1+a-2*b)',is_simulation=False) # Noiseless equation
Get or set the response values. When setting the response values, you may use either a list or a dictionary. If fewer values are assigned than there are rows in the design, they will be filled in starting with first row. If a dictionary is used, it must use integers as keys, and it will fill response values in rows indexed by the dictionary keys. The indices are 0-based, so the first row is index 0, the second index 1, and so on.
>>> # sets the first 4 rows to a list of values
>>> response.values = [.1, .2, .3, .4]
>>> # sets the 7th through 10th rows to specific values
>>> response.values = { 6: .1, 7: .2, 8: .3, 9: .4 }
>>> # sets the 6th run to a specific value
>>> response.values = { 5: .8 }
The Analysis class holds information about an Analysis in
Stat-Ease 360. Instances of this class are typically created by
statease.client.SEClient.get_analysis()
.
Performs an auto-selection on an initial model.
initial_model (str) – A model to auto-select a subset of terms from.
criterion (str) – The criterion used to evaluate each sub-model. Valid options are “AICc”, “BIC”, “pValues”, or “AdjRSquared” (case-insensitive).
method (str) – The method used to select sub-models. Valid options are “Forward”, “Backward”, “Stepwise”, and “AllHierarchical” (case-insensitive).
alpha (float) – This is the alpha used to either include or exclude terms when using the “pValues” criterion. You can also pass alpha_in and/or alpha_out to set those values separately (setting both only has an effect when using the “Stepwise” method).
select_by_degree (bool) – Restricts the sub-model comparisons to lower order terms before considering higher order terms.
>>> result_model = analysis.auto_select('A+B+C+AB+BC+ABC', 'BICc', 'Backward')
>>> print(result_model)
>>> "A+B+AB"
An enumeration representing the different types of goals a Criteria can have.
The Criteria class is used by the optimizer to calculate a desirability score for a given point in the design space, which is then used to search for an optimal point.
Each Analysis and Factor can have a Criteria (e.g. you might maximize the output of an Analysis, and target a certain value of a Factor).
The goal of this Criteria (e.g. Goal.MAXIMIZE).
The importance of this Criteria, relative to other Criteria.
The lower limit for this Criteria.
The lower weight for this Criteria.
The name of this Criteria (analysis/response or factor name).
The restrict discrete for this Criteria.
The target for this Criteria, if using Goal.EQUAL_TO or Goal.TARGET
The upper limit for this Criteria.
The upper weight for this Criteria.