Impute

Represents the Impute class, which enables users to impute both interval and nominal variables in various ways.

class sasviya.ml.preprocess.Impute(*, strategy='mean', values_numeric=None, values_string=None)

Parameters

strategy : {‘mean’, ‘median’, ‘min’, ‘max’, ‘midrange’, ‘mode’, ‘most_frequent’, ‘value’, ‘constant’}, default=’mean’

Specifies which of the following imputation strategies to use:

  • ‘mean’: replaces missing values with the mean of the column.

  • ‘median’: replaces missing values with the median of the column.

  • ‘min’: replaces missing values with the minimum of the column.

  • ‘max’: replaces missing values with the maximum of the column.

  • ‘midrange’: replaces missing values with the midrange of the column.

  • ‘mode’ or ‘most_frequent’: replaces missing values with the mode of the column.

  • ‘value’: replaces missing values with a specified value (see the values_numeric and values_string parameters).

  • ‘constant’: replaces missing values with a constant value (see the values_numeric and values_string parameters).

values_numeric : float or list(float), optional

Specifies the value to use in numeric columns when the strategy parameter value is ‘value’ or ‘constant’.

values_string : str or list(str), optional

Specifies the value to use in character columns when the strategy parameter value is ‘value’ or ‘constant’.

Attributes

details_ : Results

Stores information about the fitting process and its results.

n_features_in_ : int

Stores the number of input features.

feature_names_in_ : list(str)

Stores the list of input features.

imputed_values_ : list(float) or list(str)

Stores the list of imputed values.

Methods

Method Name

Description

customize_results()

Generates plots for all actions that support graphics, as well as filter tables from the results list, and creates custom result orders.

describe()

Describes the type of model, its inputs, and its output.

export()

Exports the internal SAS analytic store from a fitted model.

fit()

Fits the data.

fit_transform()

Fits and transforms the data.

get_feature_names_out()

Retrieves the output feature names.

get_params()

Gets parameters for this model.

save()

Saves the model to a file.

set_params()

Updates the parameters of the model.

transform()

Transforms the data.

customize_results()

customize_results(plots=None, width=None, height=None, dpi=None, theme=None, path=None, output_type=None, include_tables=None, exclude_tables=None, order=None)

Generates plots for all actions that support graphics, as well as filter tables from the results list, and creates custom result orders.

Parameters

plots : str or str list

Requests plots. You can request a single plot or a list of plots. The request can also be “all” or “none”. Arguments in parentheses are also allowed with each plot request. In addition, you can disable automatic plots from models by setting the environment variable AUTO_GRAPHICS to false. However, this variable does not disable automatic plot generation through the customize_results() method. You need to specify plots=”none” in the method to guarantee that only tables are returned. For more information, see SAS Viya: Managing Plots in Python Automatic Graphics.

width : int

Overrides the default width of the graph in pixels.

height : int

Overrides the default height of the graph in pixels.

dpi : int

Overrides the default resolution of the graph in dots per inch. The default is 96 dpi.

theme : {“light”, “dark”, “opal”, “midnight”, “raven”, “htmlencore”, “highcontrast”, “grayscale”, monochrome”}

Overrides the default theme that the graph uses. The default is “light”. You can specify the session default by setting the GRAPHICS_THEME environment variable.

path : str

Writes the plot results to the specified path in addition to the notebook.

output_type : {“svg”, “png”}

Overrides the default output type. The default type is “svg”, which contains image map information for tooltips. The “png” output type does not support tooltip information.

include_tables : str or str list

Includes only the specified tables from the displayed results. You can specify a keyword (“none”, “all”), a single table, or a list of tables. The default is “all”, which keeps all tables. The keyword “none” removes all tables, so that the results contain only plots that were generated. You can include tables by name (case-sensitive), and wildcarding is supported. These names appear in the top left corner of all displayed results. If you specify this parameter along with the exclude_tables parameter, then the include_tables parameter takes precedence.

exclude_tables : str or str list

Excludes tables from the displayed results. You can specify a keyword (“none”, “graph_tables”, “all”), a single table, or a list of tables. The default is “none”, which displays all tables. The keyword “graph_tables” removes all tables that were used to produce a graph. The keyword “all” removes all tables, so that the results contain only plots that were generated. You can also exclude tables by name (case-sensitive), and wildcarding is supported. Those names appear in the top left corner of all displayed results. If you specify this parameter along with the include_tables parameter, then the include_tables parameter takes precedence.

order : str or str list

Orders plot and tabular results for display. Any result that you do not specify in this parameter is excluded from the new results. The names for the results appear in the top left corner of all displayed results. If you specify this parameter along with the include_tables or exclude_tables parameter, those parameters are applied before the ordering is done. If the ordered list contains no results, then the order parameter is ignored.

Returns

CustomResults

Returns CustomResults that are a combination of both model results and plot results. These results do not replace the original model results. Instead, the CustomResults are typically assigned to a variable for later use or passed directly to the display() method for viewing in a Jupyter notebook cell.

describe()

describe(options=None)

Describes the type of model, its inputs, and its output.

Parameters

options: dict, optional

Specifies additional runtime options to pass to the description. The keys should be the option names as strings, and the values should be the corresponding option values.

Returns

Results

Returns a mapping of various properties that describe aspects of the model.

export()

export(file=None, replace=False)

Exports the internal SAS analytic store from a fitted model.

Generates an analytic store file that is common to other SAS products or procedures.

Parameters

file : str, pathlib.Path, or file-like, optional

Specifies the location where the exported model is saved. The location can be a path that specifies a file or an existing file-like object. It must be writable in binary format.

replace : bool, optional

Specifies whether or not to overwrite the file parameter if it already exists. This parameter is ignored unless the file parameter value is a file path.

Returns

bytes or None

Returns the analytic store in binary form if the file parameter is omitted. Otherwise None is returned.

fit()

fit(X, weight=None, y=None)

Fits the data.

Parameters

X : array-like of shape (n_samples, n_features)

Specifies the input data to perform a fit analysis on.

weight : str

Specifies a column from a NumPy ndarray or a Pandas DataFrame.

Returns

None

fit_transform()

fit_transform(X, weight=None, y=None, transform_options=None)

Fits and transforms the data.

Parameters

X : array-like of shape (n_samples, n_features)

Specifies the input data to perform a fit analysis on.

weight : str

Specifies a column from a NumPy ndarray or a Pandas DataFrame.

transform_options : dict, optional

Specifies additional runtime options to pass to the transformation. The keys should be the option names as strings, and the values should be the corresponding option values.

Returns

Returns an array-like result of transformed values.

get_feature_names_out()

get_feature_names_out()

Retrieves the output feature names.

Returns

list(str)

Returns a list of strings.

get_params()

get_params(deep=True)

Gets parameters for this model.

Parameters

deep : bool, default=True

This parameter is unused but is provided for compatibility with scikit-learn.

Returns

dict

Returns parameter names and current values.

save()

save(path)

Saves the model to a file.

Save uses pickle and can be loaded with the sasviya.load_model.

Parameters

path : str or pathlib.Path

Specifies the location where the model is to be saved.

Returns

None

set_params()

set_params(**params)

Updates the parameters of the model.

Parameters

**params : dict

Specifies name:value pairs of the parameters to update.

Returns

self

Returns itself.

transform()

transform(X, options=None)

Transforms the data.

Parameters

X : array-like of shape (n_samples, n_features)

Specifies the input data to perform a transform analysis on.

options : dict, optional

Specifies additional runtime options to pass to the transformation. The keys should be the option names as strings, and the values should be the corresponding option values.

Returns

result : array-like

Returns an array-like result of transformed values.

Last updated: July 29, 2026