小编Kel*_*sey的帖子

如何在管道中重新采样文本(不平衡组)?

我正在尝试使用 MultinomialNB 进行一些文本分类,但我遇到了问题,因为我的数据不平衡。(为简单起见,下面是一些示例数据。实际上,我的数据要大得多。)我正在尝试使用过采样对我的数据进行重新采样,并且理想情况下我希望将其构建到此管道中。

下面的管道在没有过度采样的情况下工作正常,但同样,在现实生活中我的数据需要它。这是非常不平衡的。

使用此当前代码,我不断收到错误消息:“TypeError:所有中间步骤都应该是转换器并实现拟合和转换。”

如何将 RandomOverSampler 构建到此管道中?

data = [['round red fruit that is sweet','apple'],['long yellow fruit with a peel','banana'],
    ['round green fruit that is soft and sweet','pear'], ['red fruit that is common', 'apple'],
    ['tiny fruits that grow in bunches','grapes'],['purple fruits', 'grapes'], ['yellow and long', 'banana'],
    ['round, small, green', 'grapes'], ['can be red, green, or purple', 'grapes'], ['tiny fruits', 'grapes'], 
    ['small fruits', 'grapes']]

df = pd.DataFrame(data,columns=['Description','Type'])  

X_train, X_test, y_train, y_test = train_test_split(X, y, random_state = 0)
text_clf = Pipeline([('vect', …
Run Code Online (Sandbox Code Playgroud)

python pipeline resampling text-classification oversampling

5
推荐指数
1
解决办法
1794
查看次数

如何在没有numpy的情况下生成随机正态分布?(谷歌采访)

所以我在谷歌有一个数据科学面试,我正在努力准备。我在 Glassdoor 上看到很多以前在那里面试过的人提出的问题之一是:“编写代码来生成随机正态分布。” 虽然使用 numpy 很容易做到这一点,但我知道有时 Google 会要求候选人在不使用任何包或库的情况下进行编码,所以基本上是从头开始。

有任何想法吗?

python statistics

5
推荐指数
1
解决办法
2539
查看次数