BNET
Bayesian Network Classification Model
Parameters
- num_bin : int, optional
-
Specifies the number of binning levels for all continuous variables.
- pre_screening : {0, 1}, optional
-
Specifies the initial screening for the input variables.
- var_select : {0, 1, 2, 3}, optional
-
Specifies the selection for the input variables.
- missing_int : {“ignore”, “impute”}, optional
-
Specifies how to handle missing values for continuous variables.
- missing_nom : {“ignore”, “impute”, “level”}, optional
-
Specifies how to handle missing values for nominal variables.
- indep_test : {“all”, “chigsquare”, “chisquare”, “gsquare”, “mi”},
-
Specifies the methods for independence tests.
- alpha : float, optional
-
Specifies the significance level for independence tests by using chi-square or G-square statistics.
- mi_alpha “ float, optional
-
Specifies the significance level for independence tests by using mutual information.
- structure : {“GENERAL”, “GN”, “NAIVE”, “MB”, “TAN”, “PC”}, optional
-
Specifies the network structure types.
- parenting : {“bestone”, “bestset”}, optional
-
Specifies the structure learning methods.
- max_parents : int, optional
-
Specifies the maximum number of parents that are allowed for each node in the network.
- best_model : bool, optional
-
Requests that the best model be selected.
- verbose: int, optional
-
Specifies the amount of information to print during model fitting.
Attributes
- classes_ : list of str
-
Stores class labels that are seen during model fitting.
- details_ : Results
-
Stores additional information about the model fitting process and the final results.
- feature_names_in : list of str
-
Stores the column names of the input features that are seen during fitting.
- n_features_in_ : int
-
Stores the number of input features that are seen by the model.
- outnetwork_ : DataFrame
-
Stores the parent-child connections that the fitted network contains.
- target_name_in_ : str
-
Stores the column name of the target variable.
Methods
|
Method Name |
Description |
|---|---|
|
Generates plots for all actions that support graphics, as well as filter tables from the results list, and creates custom result orders. | |
|
Computes the decision function given input features. | |
|
Describes the type of model, its inputs, and its output. | |
|
Exports the internal SAS analytic store from a fitted model. | |
|
Fits the model to the training data. | |
|
Gets parameters for this model. | |
|
Predicts class labels given input features. | |
|
Estimates probabilities for each class label. | |
|
Saves the model to a file. | |
|
Determines model accuracy by using the data set X and the targets y. | |
|
Updates the parameters of the model. |
customize_results()
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.
decision_function()
Computes the decision function given input features.
Parameters
- X : array-like
-
Specifies training features in the shape (n_samples, n_features).
- options: dict, optional
-
Specifies additional runtime options to pass to the decision function. The keys should be the option names as strings, and the values should be the corresponding option values.
Returns
- array-like
-
Returns the estimated posterior probability for the target class. This is (n_samples, n_classes) for the multiclass case and (n_samples, ) with just self.classes_[1] returned for the binary case.
describe()
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()
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()
Fits the model to the training data.
Parameters
- X : array-like
-
Specifies the training features in the shape (n_samples, n_features).
- y : array-like
-
Specifies the target labels in the shape (n_samples, ). The target is assumed to be categorical.
- nominals: list of str, optional
-
Specifies the names of columns in X to treat as categorical.
Returns
- self : object
-
Returns the instance itself.
get_params()
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.
predict()
Predicts class labels given input features.
Parameters
- X : array-like
-
Specifies the samples to predict class labels for, with the shape (n_samples, n_features).
- copy_var : str or list of str, optional
-
Specifies variable(s) to be copied from the data. Can be a single variable name as a string or a list of variable names. For DuckDB queries, these variables will be added to the query if they don’t already exist in X.
- options: dict, optional
-
Specifies additional runtime options to pass to the prediction. The keys should be the option names as strings, and the values should be the corresponding option values.
Returns
- array-like
-
Returns predicted class labels in the shape (n_samples, ).
predict_proba()
Estimates probabilities for each class label.
Parameters
- X : array-like
-
Specifies the samples to predict class labels for, with the shape (n_samples, n_features).
- copy_var : str or list of str, optional
-
Specifies variable(s) to be copied from the data. Can be a single variable name as a string or a list of variable names. For DuckDB queries, these variables will be added to the query if they don’t already exist in X.
- options: dict, optional
-
Specifies additional runtime options to pass to the prediction. The keys should be the option names as strings, and the values should be the corresponding option values.
Returns
- array-like
-
Returns estimated class label probabilities in the shape (n_samples, n_classes).
save()
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
score()
Determines model accuracy by using the data set X and the targets y.
Parameters
- X : array-like
-
Specifies the data set to score on.
- y : array-like
-
Specifies the target values to compare the predictions to.
- options: dict, optional
-
Specifies additional runtime options to pass to the scoring task. The keys should be the option names as strings, and the values should be the corresponding option values.
set_params()
Updates the parameters of the model.
Parameters
- **params : dict
-
Specifies name:value pairs of the parameters to update.
Returns
- self
-
Returns itself.