import pandas as pd
Read the data
file_path = ‘/content/finaldata3.csv’
df = pd.read_csv(file_path)
df
columns_to_delete = [‘Unnamed: 8’]
df.drop(columns=columns_to_delete, inplace=True)
X = df[[‘Material_Id’, ‘Vendor_Id’]]
y = df[‘Lead_Time’]
y = pd.to_numeric(y)
dataset = tfdf.keras.pd_dataframe_to_tf_dataset(df, label=“Lead_Time”, task=tfdf.keras.Task.REGRESSION)
model = tfdf.keras.RandomForestModel(task=tfdf.keras.Task.REGRESSION)
model.compile(metrics=[“mse”])
model.fit(dataset)
import pickle
with open(“/content/trained_model2.pkl”, “wb”) as f:
pickle.dump(model, f)
with open(“/content/trained_model2.pkl”, “rb”) as f:
pretrained_model = pickle.load(f)
new_data_file_path = ‘/content/mat1ven3.csv’
new_data_df = pd.read_csv(new_data_file_path)
X_new = new_data_df[[‘Material_Id’, ‘Vendor_Id’]]
y_new = new_data_df[‘Lead_Time’]
y_new = pd.to_numeric(y_new)
new_dataset = tfdf.keras.pd_dataframe_to_tf_dataset(new_data_df, label=“Lead_Time”, task=tfdf.keras.Task.REGRESSION)
pretrained_model.compile(metrics=[“mse”])
pretrained_model.fit(new_dataset)
I am getting the error as
ValueError: The model’s task
attribute (CLASSIFICATION) does not match the task
attribute passed to pd_dataframe_to_tf_dataset
(REGRESSION).