bigframes.bigquery.ai.predict#
- bigframes.bigquery.ai.predict(training_df: DataFrame | DataFrame, prediction_df: DataFrame | DataFrame, *, label_col: str = 'label') DataFrame[source]#
Uses TabFm, a pre-trained foundation model for tabular data, to perform regression and classification tasks on structured data.
- Examples:
>>> df = bpd.read_gbq("bigquery-public-data.ml_datasets.penguins") >>> df = df[df['body_mass_g'] > 0]
>>> size = len(df) >>> training_size = int(size * 0.8) >>> training_df = df.head(training_size) >>> prediction_df = df.tail(size - training_size).dropna(subset=['body_mass_g'])
>>> result = bbq.ai.predict(training_df,prediction_df,label_col='body_mass_g') >>> type(result) <class 'pandas...DataFrame'>
- Parameters:
training_df (DataFrame) – The dataframe that contains the training data. It could be either a BigFrames Dataframe or a pandas DataFrame. If it’s a pandas DataFrame, the global BigQuery session will be used to load the data. The table or query result must contain a column named label or the column that you specify in the ‘label_col’ argument. Every other column is considered a feature column. The feature and label columns must be one of the following types: string, bool, int, float, or decimal
prediction_df (DataFrame) – The table or query that contains the data to run prediction on. It could be either a BigFrames Dataframe or a pandas DataFrame. If it’s a pandas DataFrame, the global BigQuery session will be used to load the data. The table or query result must contain all of the feature columns in the training data and can optionally contain additional columns.
label_col (str, default 'label') – A string value that specifies the name of the label column in the training data.