标签: classification

xgboost模型中n_estimators的默认值是多少?

我正在使用 gridsearchCV 来调整 xgboost 分类器模型的参数(lambda、gamma、max_depth、eta)。我没有设置提前停止或 n_estimator 值。并且运行gs.fit()需要花费很多时间。我想知道 xgboost 的 n_estimators 是否有默认值。谢谢 !

parameters tree classification xgboost

3
推荐指数
2
解决办法
5719
查看次数

R 错误:未使用的参数(measures = list("f1", FALSE, etc)

我正在尝试使用 R 中的“mlr”库和 iris 数据集上的“c50”算法(使用 F1 分数作为指标):

library(mlr)
library(C50)
data(iris)

zooTask <- makeClassifTask(data = iris, target = "Species")
forest <- makeLearner("classif.C50")

forestParamSpace <- makeParamSet(
makeIntegerParam("minCases", lower = 1, upper = 100))


randSearch <- makeTuneControlRandom(maxit = 100)


cvForTuning <- makeResampleDesc("CV", iters = 5,  measures = f1)


tunedForestPars <- tuneParams(forest, task = zooTask,
resampling = cvForTuning,
par.set = forestParamSpace,
control = randSearch)



tunedForestPars
Run Code Online (Sandbox Code Playgroud)

但这会导致以下错误:

Error in makeResampleDescCV(iters = 5, measures = list(id = "f1", minimize = FALSE,  : 
  unused argument (measures = …
Run Code Online (Sandbox Code Playgroud)

r classification mlr

3
推荐指数
1
解决办法
123
查看次数

How to use different feature matrices for sklearn.ensemble.StackingClassifier (with class inheritance)?

I have a dataset where there a bunch of different types of data for each each sample and I'd like to use separate models for different data types and use them together in sklearn.ensemble.StackingClassifier. However, StackingClassifier takes the same feature matrix and applies different algorithms to it, then sends the probabilities to the meta classifier.

Is there a way to specify particular feature matrices (representing the same samples) that correspond with specific algorithms in the StackingClassifier?

If not, …

python statistics classification machine-learning scikit-learn

3
推荐指数
1
解决办法
880
查看次数

使用 sklearn pipeline 进行分类任务时,形状图(树解释器)中出现错误

我正在使用 sklearn 管道进行分类任务,如下所示:

from sklearn.datasets import fetch_openml
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.impute import SimpleImputer
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import OrdinalEncoder

import shap


# -----------------------------------------------------------------------------
# Data
# -----------------------------------------------------------------------------

X, y = fetch_openml("titanic", version=1, as_frame=True, return_X_y=True)

categorical_columns = ["pclass", "sex", "embarked"]
numerical_columns = ["age", "sibsp", "parch", "fare"]

X = X[categorical_columns + numerical_columns]   # [1309, 7] , there is Nan values.
X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y, random_state=42)


# …
Run Code Online (Sandbox Code Playgroud)

pipeline classification treemodel scikit-learn shap

3
推荐指数
1
解决办法
2706
查看次数

获取 TF-IDF 数据时的内存问题

介绍

\n

我正在努力对大型推文数据集进行文本分类,如果有人能给我指出正确的方向,我将不胜感激。

\n

总体而言,我需要训练一个分类器来区分庞大数据集(最多 600 万个文本)上的两个类。我一直在食谱框架中执行此操作,然后通过tidymodels运行 glmnet lasso 。具体问题是我在计算 tf-idf 时内存不足。

\n

问题

\n

我应该朝哪个方向努力来解决这个问题?我基本上可以批量手动获取所有 tf​​-idf 值,然后再次手动将它们组合成稀疏矩阵对象。这听起来很肛门,肯定有人以前遇到过这个问题并解决了它?另一种选择是 Spark,但它远远超出了我目前的能力范围,并且对于一次性任务来说可能有些过大了。或者也许我遗漏了一些东西,而现有的工具能够做到这一点?

\n

具体来说,我在运行以下命令时遇到两种问题(变量应该是不言自明的,但我稍后将提供完整的可重现代码):

\n
recipe <-\n  recipe(Class ~ text, data = corpus) %>% \n  step_tokenize(text) %>%\n  step_stopwords(text) %>% \n  step_tokenfilter(text, max_tokens = m) %>% \n  step_tfidf(text) %>% \n  prep()\n
Run Code Online (Sandbox Code Playgroud)\n

如果corpus太大或者m太大,Rstudio就会崩溃。如果它们相当大,它会发出警告

\n
In asMethod(object) :\n  sparse->dense coercion: allocating vector of size 1.2 GiB\n
Run Code Online (Sandbox Code Playgroud)\n

我在网上没有找到相关内容,我也不太明白。为什么它试图强迫某些东西从稀疏变成密集?这对于任何大型数据集来说肯定会带来麻烦。难道我做错了什么?如果这是可以预防的,也许我的完整数据集会有更好的运气?

\n

或者是否没有希望step_tfidf应对 600 万个观测值并且对最大令牌没有限制?

\n …

r classification tf-idf tidytext tidymodels

3
推荐指数
1
解决办法
139
查看次数

SVM序列最小优化收敛性问题

我已经在支持向量机上工作了大约2个月了.我自己编写了SVM编码,对于SVM的优化问题,我使用了John Platt博士的Sequential Minimal Optimization(SMO).

现在我正处于我要进行网格搜索以找到我的数据集的最佳C值的阶段.(请在此处查找我的项目应用程序和数据集详细信息的详细信息SVM分类 - 每个类的最小输入集数量)

我已经成功检查了我自定义实现的SVM的精度,C值范围从2 ^ 0到2 ^ 6.但是现在我遇到了关于C> 128的SMO收敛的一些问题.就像我试图找到C = 128的alpha值一样,它在实际收敛并成功给出alpha值之前需要很长时间.

对于C = 100,SMO收敛所花费的时间约为5小时.这个巨大的我认为(因为SMO应该很快.)虽然我的准确度很高?我被搞砸了,因为我不能测试更高C值的准确性.

我实际上显示了SMO每次传递中更改的alpha数,并且让10,13,8 ... alphas不断变化.KKT条件确保收敛,所以这里发生了什么奇怪的事情?

请注意,虽然执行时间很长,但我的实现在C <= 100时工作正常且准确性很高.

请给我关于这个问题的意见.

谢谢你和干杯.

smo classification machine-learning convex-optimization svm

2
推荐指数
1
解决办法
1876
查看次数

如何提高matlab中决策树的准确性

我有一组数据,我使用决策树在matlab中对它们进行分类.我将这组分为两部分; 一个训练数据(85%)和其他测试数据(15%).问题是准确率在90左右,我不知道如何改进它.如果您对此有任何想法,我将不胜感激.

matlab classification machine-learning decision-tree

2
推荐指数
1
解决办法
9071
查看次数

使用Mahout Native Bayes分类器算法需要哪些步骤?

我正在尝试使用Native Bayes Classifier来检测欺诈交易.我在excel表中有大约5000的样本数据,这是我将用于训练分类器的数据,我有大约1000的测试数据,我将在其上应用测试分类器.

我的问题是,我不知道如何训练分类器.在将训练数据传递到训练分类器之前,是否需要将训练数据转换为某种特定格式.训练分类器将如何知道哪个是我的目标值以及哪个是其特征.

有人可以帮帮我吗?

classification fraud-prevention mahout

2
推荐指数
1
解决办法
3494
查看次数

在Matlab中为KNN选择k

我目前正在使用Matlab的k最近邻分类器(knnclassify)来训练和测试二进制属性.如果没有提供k,则k的默认值参数为1,并且可以选择k的其他值.我已经完成了在线研究和stackoverflow研究,但是没有任何相关内容可以解决我的问题,即k的最佳用途是什么.是否有内置函数可以告诉我对于我的特定数据,还是只是猜测并等待看到的精度是什么?任何帮助将不胜感激.

以下是matlab的knnclassify文档的链接:knnclassify

matlab classification knn

2
推荐指数
1
解决办法
2419
查看次数

合并词袋scikits分类器与任意数字字段

你如何合并一个scikits-learn 分类器,它运行在一个单词袋上,一个在任意数字字段上运行?

我知道这些在幕后基本上是一样的,但是我很难通过现有的库方法找出如何做到这一点.例如,我的词袋分类器使用管道:

classifier = Pipeline([
    ('vectorizer', HashingVectorizer(ngram_range=(1,4), non_negative=True)),
    ('tfidf', TfidfTransformer()),
    ('clf', OneVsRestClassifier(LinearSVC())),
])
classifier.fit(['some random text','some other text', ...], [CLS_A, CLS_B, ...])
Run Code Online (Sandbox Code Playgroud)

而我的其他用法如下:

classifier = LinearSVC()
classifier.fit([1.23, 4.23, ...], [CLS_A, CLS_B, ...])
Run Code Online (Sandbox Code Playgroud)

我如何构建一个可以使用两组数据进行训练的LinearSVC分类器?例如

classifier = ?
classifier.fit([('some random text',1.23),('some other text',4.23), ...], [CLS_A, CLS_B, ...])
Run Code Online (Sandbox Code Playgroud)

python classification scikit-learn

2
推荐指数
1
解决办法
1467
查看次数