I am trying to divide a dataset into training dataset and testing dataset for multi-label classification. The datset I am working on is this one. It is divided into a file which contains the features and another file which contains the targets. They look like this below.
This is the image about the features.
This is the image about the targets.
I intend to use this dataset for multilabel classification. I am following this tutorial . Here the dataset looks like this.
The dataset that I am working on has 17203824 samples and 58255 different and unique labels in the target file. So to follow the tutorial what I intend to create is a new numpy 2d array with 17203824 rows and 58255 columns where appropriate indices will be marked with 1. I am able to create it. But when I try to populate with 1s in the appropriate indices, I am getting an error. Its says that I don't have enough memory. My code is given below.
questions = pd.read_csv("/kaggle/input/stacklite/questions.csv")
question_tags = pd.read_csv("/kaggle/input/stacklite/question_tags.csv")
d = {v: i[0] for i, v in np.ndenumerate(question_tags["Tag"].unique())}
y = np.zeros([questions.shape[0], len(question_tags["Tag"].unique())], dtype = int)
for k in question_tags["Tag"]:
j = d[k]
for i, l in enumerate(y):
y[i][j] = 1
Can anyone please help in telling me how I should proceed?