The Alternating Condtional Expectation (ACE) algorithm
ACE was invented by L. Breiman and J. Friedman [Breiman85]. It is a powerful way to perform multidimensional regression without assuming any functional form of the model. Given a data set:
\(y = f(X)\)
where \(X\) is made up of a number of independent variables xi, ACE will tell you how \(y\) varies vs. each of the individual independents \(xi\). This can be used to:
- Understand the relative shape and magnitude of y’s dependence on each xi
- Produce a lightweight surrogate model of a more complex response
- other stuff
Bases: object
Runs the Alternating Conditional Expectation algorithm to perform regressions
Methods
Define input to ACE
Parameters: | x_input : list
y_input : array
|
---|
The Model module is a front-end to the ace.ace module. ACE itself just gives transformations back as discontinuous data points. This module loads data, runs ACE, and then performs interpolations on the results, giving the user continuous functions that may be evaluated at any point within the range trained.
This is a convenience/frontend/demo module. If you want to control ACE yourself, you may want to just use the ace module manually.
Bases: object
A continuous model of data based on ACE regressions
Methods
Compute 1-D interpolation functions for all the transforms so they’re continuous.
Construct the model and perform regressions based on data in a txt file.
Parameters: | fname : str
|
---|
Construct the model and perform regressions based on x, y data.
Scatterplot smoother with a fixed span. Takes x,y scattered data and returns a set of (x,s) points that form a smoother curve fitting the data with moving least squares estimates. Similar to a moving average, but with better characteristics. The fundamental issue with this smoother is that the choice of span (window size) is not known in advance. The SuperSmoother uses these smoothers to figure out which span is optimal.
This is a Python port of J. Friedman’s 1982 fixed-span Smoother [Friedman82]
Example:
s = Smoother()
s.specify_data_set(x, y, sort_data = True)
s.set_span(0.05)
s.compute()
smoothed_y = s.smooth_result
Bases: ace.smoother.Smoother
A basic fixed-span smoother
Simple least-squares linear local smoother.
Uses fast updates of means, variances.
Methods
Bases: ace.smoother.BasicFixedSpanSmoother
Uses slow means and variances at each step. Used to validate fast updates
Methods
alias of BasicFixedSpanSmoother
Bases: object
Smoothers accept data and produce smoother curves that fit the data.
Methods
Plot the input data and resulting smooth
Parameters: | fname : str, optional
|
---|
Set the window-size for computing the least squares fit
Parameters: | span : float
|
---|
Fully define data by lists of x values and y values.
This will sort them by increasing x but remember how to unsort them for providing results.
Parameters: | x_input : iterable
y_input : iterable
sort_data : bool, optional
|
---|
Convenience function to run the basic smoother
Parameters: | x_values : iterable
y_ values : iterable
span : float, optional
smoother_cls : Class
|
---|---|
Returns: | smoother : object
|
A variable-span data smoother. This uses the fixed-span smoother to determine a changing optimal span for the data based on cross-validated residuals. It is an adaptive smoother that requires several passes over the data.
The SuperSmoother provides a mechanism to evaluate the conditional expectations in the ACE algorithm.
Based on [Friedman82].
Example:
s = SuperSmoother()
s.specify_data_set(x, y, sort_data = True)
s.compute()
smoothed_y = s.smooth_result
Bases: ace.smoother.Smoother
Variable-span smoother
Methods
Bases: ace.supersmoother.SuperSmoother
Auxiliary subclass for researching/understanding the SuperSmoother
Methods
ace is a multivariate regression tool that solves alternating conditional expectations
See full documentation at http://partofthething.com/ace
To use, get some sample data:
from ace.samples import wang04
x, y = wang04.build_sample_ace_problem_wang04(N=200)
and run:
from ace import model
myace = model.Model()
myace.build_model_from_xy(x, y)
myace.eval([0.1, 0.2, 0.5, 0.3, 0.5])
For some plotting (matplotlib required), try:
from ace import ace
ace.plot_transforms(myace, fname = 'mytransforms.pdf')
myace.ace.write_transforms_to_file(fname = 'mytransforms.txt')