LogisticRegression:未知标签类型:在python中使用sklearn的'continuous'吗?

时间:2019-07-18 12:46:19

标签: python sklearn-pandas

我的数据集中有2个分类器值1和0,并且我有67个图像及其系数。如何使用分类器对此进行回归分析?

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

df = pd.read_csv("bogu.csv",sep = ";")

x = df.iloc[:,0].values.reshape(-1,1)
y = df.iloc[:,1].values.reshape(-1,1)

x = x.astype(np.float)
y = y.astype(np.float)


from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x,y,test_size = 0.2,random_state=42)

from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
x_train = sc_X.fit_transform(x_train)
x_test = sc_X.transform(x_test)

from sklearn.linear_model import LogisticRegression
classifier = LogisticRegression(random_state = 42)
classifier.fit(x_train, y_train)

y_pred = classifier.predict(x_test)

"""from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_pred)
print(cm)
[[30,3],[10,24]]"""
result = df.predict(x_test)
from sklearn.metrics import confusion_matrix
# Parametre olarak karşılaştıracağımız verileri giriyoruz.
# y_test : Cinsiyet Test Verisi
# result : x_test verisinden tahmin ettiğimiz cinsiyet verileri
cm = confusion_matrix(y_test,result)
print(cm)
  

文件   “ C:\ Users \ User \ Anaconda2 \ envs \ jupyterlab \ lib \ site-packages \ sklearn \ utils \ multiclass.py”,   第169行,在check_classification_targets中       引发ValueError(“未知标签类型:%r”%y_type)

     

ValueError:未知标签类型:“连续”

我的数据集中有2个分类器值1和0,并且我有67个图像及其系数。如何使用分类器对此进行回归分析?

0 个答案:

没有答案