From 91415e4c357d26ef8c5181d5407b55554f94235d Mon Sep 17 00:00:00 2001 From: Ashley Xu Date: Wed, 24 Apr 2024 19:17:04 +0000 Subject: [PATCH] docs: address more technical writers' feedback --- bigframes/ml/cluster.py | 4 +-- bigframes/ml/decomposition.py | 4 +-- bigframes/ml/forecasting.py | 2 +- bigframes/ml/imported.py | 6 ++-- bigframes/ml/linear_model.py | 8 +++--- bigframes/ml/llm.py | 28 +++++++++---------- bigframes/ml/pipeline.py | 6 ++-- bigframes/ml/remote.py | 10 +++---- .../sklearn/cluster/_kmeans.py | 2 +- .../sklearn/ensemble/_forest.py | 2 +- .../sklearn/linear_model/_base.py | 2 +- .../sklearn/linear_model/_logistic.py | 2 +- .../sklearn/metrics/pairwise.py | 6 ++-- .../bigframes_vendored/sklearn/pipeline.py | 5 ++-- .../sklearn/preprocessing/_encoder.py | 4 +-- .../bigframes_vendored/xgboost/sklearn.py | 2 +- 16 files changed, 46 insertions(+), 47 deletions(-) diff --git a/bigframes/ml/cluster.py b/bigframes/ml/cluster.py index e63764e7bb..e572bb3bfb 100644 --- a/bigframes/ml/cluster.py +++ b/bigframes/ml/cluster.py @@ -175,12 +175,12 @@ def to_gbq(self, model_name: str, replace: bool = False) -> KMeans: Args: model_name (str): - the name of the model. + The name of the model. replace (bool, default False): Determine whether to replace if the model already exists. Default to False. Returns: - KMeans: saved model.""" + KMeans: Saved model.""" if not self._bqml_model: raise RuntimeError("A model must be fitted before it can be saved") diff --git a/bigframes/ml/decomposition.py b/bigframes/ml/decomposition.py index 0dfb46efaa..01b1fda628 100644 --- a/bigframes/ml/decomposition.py +++ b/bigframes/ml/decomposition.py @@ -169,12 +169,12 @@ def to_gbq(self, model_name: str, replace: bool = False) -> PCA: Args: model_name (str): - the name of the model. + The name of the model. replace (bool, default False): Determine whether to replace if the model already exists. Default to False. Returns: - PCA: saved model.""" + PCA: Saved model.""" if not self._bqml_model: raise RuntimeError("A model must be fitted before it can be saved") diff --git a/bigframes/ml/forecasting.py b/bigframes/ml/forecasting.py index a7e0c3c0d9..5bd01c8826 100644 --- a/bigframes/ml/forecasting.py +++ b/bigframes/ml/forecasting.py @@ -361,7 +361,7 @@ def to_gbq(self, model_name: str, replace: bool = False) -> ARIMAPlus: Args: model_name (str): - the name of the model. + The name of the model. replace (bool, default False): Determine whether to replace if the model already exists. Default to False. diff --git a/bigframes/ml/imported.py b/bigframes/ml/imported.py index 9198b4eafb..a642fae74d 100644 --- a/bigframes/ml/imported.py +++ b/bigframes/ml/imported.py @@ -89,7 +89,7 @@ def to_gbq(self, model_name: str, replace: bool = False) -> TensorFlowModel: Args: model_name (str): - the name of the model. + The name of the model. replace (bool, default False): Default to False. @@ -166,7 +166,7 @@ def to_gbq(self, model_name: str, replace: bool = False) -> ONNXModel: Args: model_name (str): - the name of the model. + The name of the model. replace (bool, default False): Determine whether to replace if the model already exists. Default to False. @@ -282,7 +282,7 @@ def to_gbq(self, model_name: str, replace: bool = False) -> XGBoostModel: Args: model_name (str): - the name of the model. + The name of the model. replace (bool, default False): Determine whether to replace if the model already exists. Default to False. diff --git a/bigframes/ml/linear_model.py b/bigframes/ml/linear_model.py index 63462be09f..0c76a39a1c 100644 --- a/bigframes/ml/linear_model.py +++ b/bigframes/ml/linear_model.py @@ -182,12 +182,12 @@ def to_gbq(self, model_name: str, replace: bool = False) -> LinearRegression: Args: model_name (str): - the name of the model. + The name of the model. replace (bool, default False): Determine whether to replace if the model already exists. Default to False. Returns: - LinearRegression: saved model.""" + LinearRegression: Saved model.""" if not self._bqml_model: raise RuntimeError("A model must be fitted before it can be saved") @@ -347,12 +347,12 @@ def to_gbq(self, model_name: str, replace: bool = False) -> LogisticRegression: Args: model_name (str): - the name of the model. + The name of the model. replace (bool, default False): Determine whether to replace if the model already exists. Default to False. Returns: - LogisticRegression: saved model.""" + LogisticRegression: Saved model.""" if not self._bqml_model: raise RuntimeError("A model must be fitted before it can be saved") diff --git a/bigframes/ml/llm.py b/bigframes/ml/llm.py index 4a58152d14..b455e35b67 100644 --- a/bigframes/ml/llm.py +++ b/bigframes/ml/llm.py @@ -64,8 +64,8 @@ class PaLM2TextGenerator(base.BaseEstimator): BQ session to create the model. If None, use the global default session. connection_name (str or None): Connection to connect with remote service. str of the format ... - if None, use default connection in session context. BigQuery DataFrame will try to create the connection and attach - permission if the connection isn't fully setup. + If None, use default connection in session context. BigQuery DataFrame will try to create the connection and attach + permission if the connection isn't fully set up. max_iterations (Optional[int], Default to 300): The number of steps to run when performing supervised tuning. """ @@ -191,7 +191,7 @@ def fit( Training labels. Returns: - PaLM2TextGenerator: Fitted Estimator. + PaLM2TextGenerator: Fitted estimator. """ X, y = utils.convert_to_dataframe(X, y) @@ -372,12 +372,12 @@ def to_gbq(self, model_name: str, replace: bool = False) -> PaLM2TextGenerator: Args: model_name (str): - the name of the model. + The name of the model. replace (bool, default False): Determine whether to replace if the model already exists. Default to False. Returns: - PaLM2TextGenerator: saved model.""" + PaLM2TextGenerator: Saved model.""" new_model = self._bqml_model.copy(model_name, replace) return new_model.session.read_gbq_model(model_name) @@ -390,7 +390,7 @@ class PaLM2TextEmbeddingGenerator(base.BaseEstimator): Args: model_name (str, Default to "textembedding-gecko"): The model for text embedding. “textembedding-gecko” returns model embeddings for text inputs. - "textembedding-gecko-multilingual" returns model embeddings for text inputs which support over 100 languages + "textembedding-gecko-multilingual" returns model embeddings for text inputs which support over 100 languages. Default to "textembedding-gecko". version (str or None): Model version. Accepted values are "001", "002", "003", "latest" etc. Will use the default version if unset. @@ -398,8 +398,8 @@ class PaLM2TextEmbeddingGenerator(base.BaseEstimator): session (bigframes.Session or None): BQ session to create the model. If None, use the global default session. connection_name (str or None): - connection to connect with remote service. str of the format ... - if None, use default connection in session context. + Connection to connect with remote service. str of the format ... + If None, use default connection in session context. """ def __init__( @@ -539,12 +539,12 @@ def to_gbq( Args: model_name (str): - the name of the model. + The name of the model. replace (bool, default False): Determine whether to replace if the model already exists. Default to False. Returns: - PaLM2TextEmbeddingGenerator: saved model.""" + PaLM2TextEmbeddingGenerator: Saved model.""" new_model = self._bqml_model.copy(model_name, replace) return new_model.session.read_gbq_model(model_name) @@ -565,8 +565,8 @@ class GeminiTextGenerator(base.BaseEstimator): BQ session to create the model. If None, use the global default session. connection_name (str or None): Connection to connect with remote service. str of the format ... - if None, use default connection in session context. BigQuery DataFrame will try to create the connection and attach - permission if the connection isn't fully setup. + If None, use default connection in session context. BigQuery DataFrame will try to create the connection and attach + permission if the connection isn't fully set up. """ def __init__( @@ -719,12 +719,12 @@ def to_gbq(self, model_name: str, replace: bool = False) -> GeminiTextGenerator: Args: model_name (str): - the name of the model. + The name of the model. replace (bool, default False): Determine whether to replace if the model already exists. Default to False. Returns: - GeminiTextGenerator: saved model.""" + GeminiTextGenerator: Saved model.""" new_model = self._bqml_model.copy(model_name, replace) return new_model.session.read_gbq_model(model_name) diff --git a/bigframes/ml/pipeline.py b/bigframes/ml/pipeline.py index 5df2378575..61b5a22da9 100644 --- a/bigframes/ml/pipeline.py +++ b/bigframes/ml/pipeline.py @@ -126,12 +126,12 @@ def to_gbq(self, model_name: str, replace: bool = False) -> Pipeline: Args: model_name (str): - the name of the model(pipeline). + The name of the model(pipeline). replace (bool, default False): - whether to replace if the model(pipeline) already exists. Default to False. + Whether to replace if the model(pipeline) already exists. Default to False. Returns: - Pipeline: saved model(pipeline).""" + Pipeline: Saved model(pipeline).""" if not self._estimator._bqml_model: raise RuntimeError("A model must be fitted before it can be saved") diff --git a/bigframes/ml/remote.py b/bigframes/ml/remote.py index 8cf892f536..8fb6d9db4c 100644 --- a/bigframes/ml/remote.py +++ b/bigframes/ml/remote.py @@ -30,12 +30,12 @@ @log_adapter.class_logger class VertexAIModel(base.BaseEstimator): - """Remote model from a Vertex AI https endpoint. User must specify https endpoint, input schema and output schema. - How to deploy a model in Vertex AI https://cloud.google.com/bigquery/docs/bigquery-ml-remote-model-tutorial#Deploy-Model-on-Vertex-AI. + """Remote model from a Vertex AI HTTPS endpoint. User must specify HTTPS endpoint, input schema and output schema. + For more information, see Deploy model on Vertex AI: https://cloud.google.com/bigquery/docs/bigquery-ml-remote-model-tutorial#Deploy-Model-on-Vertex-AI. Args: endpoint (str): - Vertex AI https endpoint. + Vertex AI HTTPS endpoint. input (Mapping): Input schema: `{column_name: column_type}`. Supported types are "bool", "string", "int64", "float64", "array", "array", "array", "array". output (Mapping): @@ -44,8 +44,8 @@ class VertexAIModel(base.BaseEstimator): BQ session to create the model. If None, use the global default session. connection_name (str or None): Connection to connect with remote service. str of the format ... - if None, use default connection in session context. BigQuery DataFrame will try to create the connection and attach - permission if the connection isn't fully setup. + If None, use default connection in session context. BigQuery DataFrame will try to create the connection and attach + permission if the connection isn't fully set up. """ def __init__( diff --git a/third_party/bigframes_vendored/sklearn/cluster/_kmeans.py b/third_party/bigframes_vendored/sklearn/cluster/_kmeans.py index 2a0acc8cfe..386b620f4a 100644 --- a/third_party/bigframes_vendored/sklearn/cluster/_kmeans.py +++ b/third_party/bigframes_vendored/sklearn/cluster/_kmeans.py @@ -75,7 +75,7 @@ def fit( Not used, present here for API consistency by convention. Returns: - KMeans: Fitted Estimator. + KMeans: Fitted estimator. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) diff --git a/third_party/bigframes_vendored/sklearn/ensemble/_forest.py b/third_party/bigframes_vendored/sklearn/ensemble/_forest.py index a55b7b80d3..92794bb68e 100644 --- a/third_party/bigframes_vendored/sklearn/ensemble/_forest.py +++ b/third_party/bigframes_vendored/sklearn/ensemble/_forest.py @@ -56,7 +56,7 @@ def fit(self, X, y): Returns: - ForestModel: Fitted Estimator. + ForestModel: Fitted estimator. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) diff --git a/third_party/bigframes_vendored/sklearn/linear_model/_base.py b/third_party/bigframes_vendored/sklearn/linear_model/_base.py index a845b782c0..69f98697af 100644 --- a/third_party/bigframes_vendored/sklearn/linear_model/_base.py +++ b/third_party/bigframes_vendored/sklearn/linear_model/_base.py @@ -109,6 +109,6 @@ def fit( Target values. Will be cast to X's dtype if necessary. Returns: - LinearRegression: Fitted Estimator. + LinearRegression: Fitted estimator. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) diff --git a/third_party/bigframes_vendored/sklearn/linear_model/_logistic.py b/third_party/bigframes_vendored/sklearn/linear_model/_logistic.py index 494c730a6d..49198eb9bd 100644 --- a/third_party/bigframes_vendored/sklearn/linear_model/_logistic.py +++ b/third_party/bigframes_vendored/sklearn/linear_model/_logistic.py @@ -79,6 +79,6 @@ def fit( Returns: - LogisticRegression: Fitted Estimator. + LogisticRegression: Fitted estimator. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) diff --git a/third_party/bigframes_vendored/sklearn/metrics/pairwise.py b/third_party/bigframes_vendored/sklearn/metrics/pairwise.py index be3d6753a7..7584230be6 100644 --- a/third_party/bigframes_vendored/sklearn/metrics/pairwise.py +++ b/third_party/bigframes_vendored/sklearn/metrics/pairwise.py @@ -21,7 +21,7 @@ def paired_cosine_distances(X, Y) -> bpd.DataFrame: Input data. X and Y are mapped by indexes, must have the same index. Returns: - bigframes.dataframe.DataFrame: DataFrame with columns of X, Y and cosine_distance + bigframes.dataframe.DataFrame: DataFrame with columns of X, Y and cosine_distance. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -36,7 +36,7 @@ def paired_manhattan_distance(X, Y) -> bpd.DataFrame: Input data. X and Y are mapped by indexes, must have the same index. Returns: - bigframes.dataframe.DataFrame: DataFrame with columns of X, Y and manhattan_distance + bigframes.dataframe.DataFrame: DataFrame with columns of X, Y and manhattan_distance. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -51,6 +51,6 @@ def paired_euclidean_distances(X, Y) -> bpd.DataFrame: Input data. X and Y are mapped by indexes, must have the same index. Returns: - bigframes.dataframe.DataFrame: DataFrame with columns of X, Y and euclidean_distance + bigframes.dataframe.DataFrame: DataFrame with columns of X, Y and euclidean_distance. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) diff --git a/third_party/bigframes_vendored/sklearn/pipeline.py b/third_party/bigframes_vendored/sklearn/pipeline.py index 8a98ee4141..96eaa903be 100644 --- a/third_party/bigframes_vendored/sklearn/pipeline.py +++ b/third_party/bigframes_vendored/sklearn/pipeline.py @@ -25,9 +25,8 @@ class Pipeline(BaseEstimator, metaclass=ABCMeta): The final estimator only needs to implement `fit`. The purpose of the pipeline is to assemble several steps that can be - cross-validated together while setting different parameters. This - simplifies code and allows for deploying an estimator and peprocessing - together, e.g. with `Pipeline.to_gbq(...).` + cross-validated together while setting different parameters. This simplifies code and allows for + deploying an estimator and preprocessing together, e.g. with `Pipeline.to_gbq(...).` """ def fit( diff --git a/third_party/bigframes_vendored/sklearn/preprocessing/_encoder.py b/third_party/bigframes_vendored/sklearn/preprocessing/_encoder.py index b883e82249..7cdca9229a 100644 --- a/third_party/bigframes_vendored/sklearn/preprocessing/_encoder.py +++ b/third_party/bigframes_vendored/sklearn/preprocessing/_encoder.py @@ -84,6 +84,6 @@ def transform(self, X): The DataFrame or Series to be transformed. Returns: - bigframes.dataframe.DataFrame: The result is categorized as index: number, value: number. - Where index is the position of the dict that seeing the category, and value is 0 or 1.""" + bigframes.dataframe.DataFrame: The result is categorized as index: number, value: number, + where index is the position of the dict seeing the category, and value is 0 or 1.""" raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) diff --git a/third_party/bigframes_vendored/xgboost/sklearn.py b/third_party/bigframes_vendored/xgboost/sklearn.py index 5a2a69dff4..da1396af02 100644 --- a/third_party/bigframes_vendored/xgboost/sklearn.py +++ b/third_party/bigframes_vendored/xgboost/sklearn.py @@ -38,7 +38,7 @@ def fit(self, X, y): Target values. Will be cast to X's dtype if necessary. Returns: - XGBModel: Fitted Estimator. + XGBModel: Fitted estimator. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)