我想知道Weka的简单逻辑函数是否使用正则化.
我在文档中没有看到任何提及,但我不确定.任何人都可以证实吗?
*用于构建线性逻辑回归模型的分类器.使用简单回归函数作为基础学习者的LogitBoost用于拟合逻辑模型.要执行的最佳LogitBoost迭代次数是交叉验证的,这会导致自动选择属性.有关更多信息,请参阅
Niels Landwehr,Mark Hall,Eibe Frank(2005).物流模型树.Marc Sumner,Eibe Frank,Mark Hall:加快Logistic Model Tree Induction.参见:第9届欧洲数据库知识发现原理与实践会议,675-683,2005.
OPTIONS
debug - 如果设置为true,分类器可能会向控制台输出其他信息.useCrossValidation - 设置是否要交叉验证LogitBoost迭代次数,还是应使用训练集上的停止条件.如果未设置(并且没有给出固定的迭代次数),则使用LogitBoost迭代次数来最小化训练集上的错误(错误分类错误或概率错误取决于errorOnProbabilities).
errorOnProbabilities - 在确定LogitBoost迭代的最佳数量时,将概率上的错误用作错误度量.如果设置,则选择LogitBoost迭代次数,以最小化均方根误差(在训练集或交叉验证中,具体取决于useCrossValidation).weightTrimBeta - 设置LogitBoost中用于重量修剪的beta值.仅在前一次迭代中携带(1-β)%权重的实例用于下一次迭代.设置为0表示没有重量修剪.默认值为0. numBoostingIterations - 设置LogitBoost的固定迭代次数.如果> = 0,则设置要执行的LogitBoost迭代次数.如果<0,则交叉验证该数字或使用训练集上的停止标准(取决于useCrossValidation的值).
useAIC - AIC用于确定何时停止LogitBoost迭代(而不是交叉验证或训练错误).
heuristicStop - 如果heuristicStop> 0,则启用贪婪停止的启发式,同时交叉验证LogitBoost迭代次数.这意味着如果在最后一次heuristicStop迭代中没有达到新的最小错误,则停止LogitBoost.建议使用此启发式算法,特别是在小型数据集上,它可以大幅提升速度.默认值为50.
maxBoostingIterations - 设置LogitBoost的最大迭代次数.默认值为500,对于非常小/大的数据集,可能更低/更高的值.*
朴素贝叶斯和Logistic回归都可以对这两个数据集进行完美分类吗?我的理解是,朴素贝叶斯(Naive Bayes)可以,带有复杂项的Logistic回归可以对这些数据集进行分类。如果我错了,请帮忙。
数据集的图像在这里:
classification machine-learning dataset data-mining logistic-regression
我想执行多项逻辑回归[使用glm()]并在C++中做一些图[gplot()].
我无法在C++中为这种回归编写函数,但也许可以打开R并调用glm()函数以便在C++中执行它,是吗?怎么样?我很感激任何想法.
提前致谢!
我想模拟来自多级逻辑分布 1000 次和每次估计参数的数据并计算估计值的平均值。但看起来,在glmer()函数结果中不能像lm()函数那样被提取出来,比如说,lm(y~x)$coef。如何从glmer()函数中提取结果?
这是R代码:
#Simulating data from multilevel logistic distribution
library(mvtnorm)
library(lme4)
set.seed(1234)
## J = number of groups
## n = group size
## g00,g10,g01,g11 = fixed effect parameters .
## s2_0,s2_1,s01 = variance values for the group level random effect .
simu <- function(J,n,g00,g10,g01,g11,s2_0,s2_1,s01){
n_j <- rep(n,J) ## number of individuals in jth group
N <- sum(n_j) ## sample size
#Simulate the covariate value for this sample size .
z …Run Code Online (Sandbox Code Playgroud) 我的数据集格式如下所示:
8,2,1,1,1,0,3,2,6,2,2,2,2
8,2,1,2,0,0,15,2,1,2,2,2,1
5,5,4,4,0,0,6,1,6,2,2,1,2
8,2,1,3,0,0,2,2,6,2,2,2,2
8,2,1,2,0,0,3,2,1,2,2,2,1
8,2,1,4,0,1,3,2,1,2,2,2,1
8,2,1,2,0,0,3,2,1,2,2,2,1
8,2,1,3,0,0,2,2,6,2,2,2,2
8,2,1,12,0,0,5,2,2,2,2,2,1
3,1,1,2,0,0,3,2,1,2,2,2,1
Run Code Online (Sandbox Code Playgroud)
它由所有分类数据组成,其中每个特征均以数字形式编码。我尝试使用以下代码:
monthly_income = tf.contrib.layers.sparse_column_with_keys("monthly_income", keys=['1','2','3','4','5','6'])
#Other columns are also declared in the same way
m = tf.contrib.learn.LinearClassifier(feature_columns=[
caste, religion, differently_abled, nature_of_activity, school, dropout, qualification,
computer_literate, monthly_income, smoke,drink,tobacco,sex],
model_dir=model_dir)
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
TypeError: Signature mismatch. Keys must be dtype <dtype: 'string'>, got <dtype: 'int64'>.
Run Code Online (Sandbox Code Playgroud) 使用此代码时,我注意到它收敛速度令人难以置信(一秒的小部分),即使模型和/或数据非常大.我怀疑在某些情况下,我没有得到任何接近最佳解决方案的东西,但这很难证明.对于某种类型的全局优化器(如流域跳跃算法),可以选择,即使这消耗了100到1000倍的CPU.有没有人对这个问题有任何想法?
我想使用我的训练数据和测试数据为我的逻辑回归计算两个混淆矩阵:
logitMod <- glm(LoanStatus_B ~ ., data=train, family=binomial(link="logit"))
Run Code Online (Sandbox Code Playgroud)
我将预测概率的阈值设置为 0.5:
confusionMatrix(table(predict(logitMod, type="response") >= 0.5,
train$LoanStatus_B == 1))
Run Code Online (Sandbox Code Playgroud)
下面的代码适用于我的训练集。但是,当我使用测试集时:
confusionMatrix(table(predict(logitMod, type="response") >= 0.5,
test$LoanStatus_B == 1))
Run Code Online (Sandbox Code Playgroud)
它给了我一个错误
Error in table(predict(logitMod, type = "response") >= 0.5, test$LoanStatus_B == : all arguments must have the same length
Run Code Online (Sandbox Code Playgroud)
为什么是这样?我怎样才能解决这个问题?谢谢!
我是机器学习的新手,我正在尝试使用scikit-learn来制作一个简单的逻辑回归模型,其中包含1个输入变量(X)和一个二元结果(Y).我的数据包括325个样本,39个成功和286个失败.数据被分成训练和测试(30%)集.
我的目标实际上是根据我的数据获得任何给定X的预测成功概率,而不是分类预测本身.也就是说,我将把预测的概率用于我正在构建的单独模型中,并且根本不会使用逻辑回归作为分类器.因此,预测的概率实际上适合数据是很重要的.
但是,我无法理解我的模型是否适合数据,或者计算的概率是否真实准确.
我得到以下指标:
分类准确度:metrics.accuracy_score(Y_test,预测) = 0.92.我对这个指标的理解是模型很有可能做出正确的预测,所以我觉得这个模型非常合适.
记录丢失:cross_val_score(LogisticRegression(),X,Y,scoring ='neg_log_loss',cv = 10) = -0.26这对我来说可能是最令人困惑的指标,显然最重要的是因为它是预测概率的准确性.我知道得分越接近于零越好 - 但距离足够接近?
AUC:metrics.roc_auc_score(Y_test,probs [:,1]) = 0.9.再次,这看起来不错,因为ROC得分越接近1越好.
混淆矩阵:metrics.confusion_matrix(Y_test,预测) =
[ 88, 0]
[8, 2]
Run Code Online (Sandbox Code Playgroud)
我在这里的理解是,对角线给出了训练集中正确预测的数量,所以这看起来不错.
报告:metrics.classification_report(Y_test,预测) =
precision recall f1-score support
0.0 0.92 1.00 0.96 88
1.0 1.00 0.20 0.33 10
avg / total 0.93 0.92 0.89 98
Run Code Online (Sandbox Code Playgroud)
根据该分类报告,该模型具有良好的精度,因此非常适合.我不确定如何解释召回或者如果这个报告对我的模型来说是个坏消息 - sklearn文档指出召回是一种模型能力,可以找到所有正样本 - 因此预测为1时得分为0.2意味着它只有20%的时间才能找到积极因素?这听起来像是非常不合适的数据.
如果有人能够澄清我正在以正确的方式处理这些指标,我真的很感激 - 也许可以说明我的模型是好还是虚假.此外,如果我还有其他测试可以确定计算的概率是否准确,请告诉我.
如果这些不是很好的度量标准分数,我真的很欣赏在改进方面的下一步方向.
谢谢!!
我对此有点新意.我在python scikit-learn中使用了一个简单的Logistic回归分类器.我有4个功能.我的代码是
X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size = 0.2, random_state = 42)
classifier = LogisticRegression(random_state = 0, C=100)
classifier.fit(X_train, y_train)
coef = classifier.coef_[0]
print (coef)
[-1.07091645 -0.07848958 0.66913624 0.43500273]
Run Code Online (Sandbox Code Playgroud)
machine-learning scikit-learn logistic-regression coefficients
x = df2.Tweet
y = df2.Class
from sklearn.cross_validation import train_test_split
SEED = 2000
x_train, x_validation_and_test, y_train, y_validation_and_test = train_test_split(x, y, test_size=.02, random_state=SEED)
x_validation, x_test, y_validation, y_test = train_test_split(x_validation_and_test, y_validation_and_test, test_size=.5, random_state=SEED)
print ("Train set has total {0} entries with {1:.2f}% negative, {2:.2f}% positive".format(len(x_train),(len(x_train[y_train == 0])/ (len(x_train)*1.))*100,(len(x_train[y_train == 1]) / (len(x_train)*1.))*100))
print("Validation set has total {0} entries with {1:.2f}% negative, {2:.2f}% positive".format(len(x_validation),(len(x_validation[y_validation == 0]) / (len(x_validation)*1.))*100,(len(x_validation[y_validation == 1]) / (len(x_validation)*1.))*100))
print ("Test set has total {0} entries with {1:.2f}% negative,{2:.2f}% positive".format(len(x_test),(len(x_test[y_test …Run Code Online (Sandbox Code Playgroud) classification python-3.x pandas logistic-regression sklearn-pandas
r ×3
scikit-learn ×3
data-mining ×2
python ×2
c++ ×1
call ×1
coefficients ×1
dataset ×1
pandas ×1
python-3.x ×1
regression ×1
statistics ×1
tensorflow ×1
validation ×1
weka ×1