AttributeError: 'DataFrame' object has no attribute 'column_names'

#1
by saravanankk57 - opened

AttributeError: 'DataFrame' object has no attribute 'column_names'

when i try to load an exel file and try to train facing this blocker,

code:
from datasets import Dataset, load_dataset
from sentence_transformers.losses import CosineSimilarityLoss

from setfit import SetFitModel, SetFitTrainer, sample_dataset
import pandas as pd

Load the dataset from an Excel file

xl_file = pd.read_excel("/content/asoc3_ap27.xlsx")
dataset = Dataset.from_pandas(xl_file)

Simulate the few-shot regime by sampling 8 examples per class

train_dataset = sample_dataset(dataset, label_column="Intent", num_samples=8)
eval_dataset = dataset

Load a SetFit model from Hub

model = SetFitModel.from_pretrained("sentence-transformers/paraphrase-mpnet-base-v2")

Create trainer

trainer = SetFitTrainer(
model=model,
train_dataset=train_dataset,
eval_dataset=eval_dataset,
loss_class=CosineSimilarityLoss,
metric="accuracy",
batch_size=16,
num_iterations=20, # The number of text pairs to generate for contrastive learning
num_epochs=1, # The number of epochs to use for contrastive learning

)

Train and evaluate

trainer.train()
metrics = trainer.evaluate()

Push model to the Hub

trainer.push_to_hub("my-awesome-setfit-model")

Download from Hub and run inference

model = SetFitModel.from_pretrained

Sign up or log in to comment