File size: 771 Bytes
7a4c140
 
 
348106a
 
1e7f99b
348106a
 
9514195
 
d8f18bc
 
348106a
9514195
fd0a05b
348106a
9514195
fd0a05b
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from datasets import load_dataset
import pandas as pd

class LoadDataset :
    """
    Scarica il dataset da Hugging Face e ne rende disponibili feature (tweet) e target (sentiment sottoforma di testo)
    """

    def __init__(self) :
        # Import del dataset da Hugging Face
        # Prendo solo 10 record per problemi prestazionali (timeout) in fase di caricamento su HuggingFace di un dataset troppo grande
        self.ds = load_dataset("SetFit/tweet_sentiment_extraction", split="train", streaming=True).take(10)

        # Per comodità trasformo il dataset in un dataframe di pandas
        self.df = pd.DataFrame(list(self.ds))

        # Identifico feature e target
        self.X = self.df['text'].tolist()
        self.y = self.df['label_text'].tolist()