sentiment / main.py
ThatOneDuck's picture
init sentiment
938a051
# --------------------------------------------
import keyring as kr
import os
import random
import json
import re
import sys
import time
from collections import defaultdict
from functools import reduce
import codefast as cf
import joblib
import numpy as np
import pandas as pd
from rich import print
from typing import List, Union, Callable, Set, Dict, Tuple, Optional, Any
from pydantic import BaseModel
import asyncio
import aiohttp
import aioredis
from codefast.patterns.pipeline import Pipeline, BeeMaxin
# —--------------------------------------------
import datasets
ds = datasets.load_dataset('ttxy/takeout_10k')
print(ds)
df = ds['train'].to_pandas()
df.rename(columns={'review':'text'},inplace=True)
df = df.sample(frac=1)
from sklearn.model_selection import train_test_split
X,Xv = train_test_split(df,test_size=0.1,random_state=42)
X,Xt = train_test_split(X,test_size=0.1,random_state=42)
print(X.shape,Xv.shape,Xt.shape)
X.to_csv('train.csv',index=False)
Xv.to_csv('valid.csv',index=False)
Xt.to_csv('test.csv',index=False)