text_plain_output_1.png
from sklearn.feature_extraction.text import TfidfVectorizer

import numpy as np

import pandas as pd

df = pd.read_csv('/kaggle/input/cleaning-cord-19-metadata/cord_metadata_cleaned.csv')
df = df.dropna(subset=['text_simplified']).reset_index(drop=True)

tfidf_vectorizer = TfidfVectorizer(input='content', lowercase=False, preprocessor=lambda text: text, tokenizer=lambda text: text.split(' '), token_pattern=None, analyzer='word', stop_words=None, ngram_range=(1, 1), max_features=10000, binary=False, norm='l2', use_idf=True, smooth_idf=True, sublinear_tf=False)
features = tfidf_vectorizer.fit_transform(df['text_simplified'])
features.shape

features = features.astype('float32').toarray()

sample_size = 0.1
sample_mask = np.random.choice(a=[True, False], size=len(features), p=[sample_size, 1 - sample_size])
features_sample = features[sample_mask]
features_sample.shape