LinearRegression
Ordinary least squares linear regression.
Parameters
- fit_intercept : bool, optional
-
Specifies whether or not to include a bias term in the model.
- verbose : int
-
Specifies the amount of information to print about the fitted model.
Attributes
- coef_ : pandas.DataFrame of shape (n_parameters, )
-
Specifies the model coefficients. The number of parameters can be greater than the number of features if additional parameters are introduced to handle missing values, or less than the number of features if variable selection is used.
- details_ : Results
-
Specifies additional information about the model fitting process and the final results.
- feature_names_in_ : list(str)
-
Specifies the column names of the input features that are seen during model fitting.
- intercept_ : pandas.DataFrame of shape (, n_intercepts)
-
Specifies the bias term(s) to be added to the model.
- n_features_in_ : int
-
Specifies the number of input features that are seen by the model.
- target_name_in_ : str
-
Specifies 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. | |
|
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 continuous values given input features. | |
|
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.
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, ).
- nominals : list(str), optional
-
Specifies the names of columns in X that should be treated as categorical.
Returns
- self
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 continuous values given input features.
Parameters
- X : array-like
-
Specifies the samples to predict values 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 continuous values in the shape (n_samples, ).
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.