所以我浏览了一个用户在这里提供的心脏病分类教程。在学习本教程时,我遇到了一个问题并且找不到解决方案。我收到一条错误消息: "ValueError: could not convert string to float: 'thal'" 。这是数据集
这是程序:
import tensorflow as tf
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
hd = pd.read_csv("heart.csv", sep=",", header=None)
hd.iloc[:,1].describe()
IVs = hd.iloc[:,2:13]
DV = hd.iloc[:,1]
DV = pd.get_dummies(DV) # One-Hot Encoding - required by classification algorithms
# In order to feed the data into a Neural Network, I must turn the data into numpy objects
IVs = IVs.values
DV = DV.values
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(IVs, DV, test_size=0.25, random_state=173)
print(X_train.shape, y_train.shape)
print(X_test.shape, y_test.shape)
# Scale the variables using Z-scores
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)
肥皂起泡泡
素胚勾勒不出你
相关分类