具有协方差/相关的群的多标签分类

2024-04-25 00:54:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图将基因型相似的动物分为4类。数据被标记,我们知道被分配给每个被测对象的基因型。我能够得到97%的测试精度使用随机森林分类器没有过/欠拟合。然而,我的问题是,基因型在现实中并不是完全不同的,它们之间可能存在一些相互关系/协方差。因此,我不想为新实例确定不同的基因型,而是想找出一个新实例属于四个类中任何一个的概率(例如,80%的类1,10%的类2,10%的类3)

我刚刚在Scikit learn中学习了高斯混合模型(GMM)。所以,我的问题是:第一,GMM是否是解决这个问题的合适方法,第二,对其他算法的建议。你知道吗


Tags: 数据对象实例标记关系分类器森林精度
1条回答
网友
1楼 · 发布于 2024-04-25 00:54:56

我想我找到了解决办法。这将是多项逻辑回归。你知道吗

from sklearn.linear_model import LogisticRegression

# Currently the ‘multinomial’ option is supported only by the ‘lbfgs’, ‘sag’, ‘saga’ and ‘newton-cg’ solvers

solvers = ['lbfgs', 'sag', 'saga','newton-cg']
clf = LogisticRegression(random_state=0, solver=solvers[0],
                     multi_class='multinomial').fit(X_train, y_train)
y_pred = clf.predict_proba(X_test) 

y_pred_proba = clf.predict_proba(X_test) 

clf.score(X_test, y_test)

#For example
# Probability of classes 0 to 3, for the third test instance:
print(y_pred_proba[3,:])
array([0.00094984, 0.65902225, 0.33647559, 0.00355232])

相关问题 更多 >