简体   繁体   English

CreateML 不接受 float64?

[英]CreateML won't accept float64?

I am trying out Create ML for the first time and I am trying to use a CSV file.我是第一次尝试 Create ML,我正在尝试使用 CSV 文件。 Problem is that the CSV column for the target is a float type.问题是目标的 CSV 列是浮点类型。 It only accepts int or string.它只接受 int 或 string。 So, I used pandas to convert the column to a string with:因此,我使用 pandas 将列转换为字符串:

df.pris_yrs = df.pris_yrs.astype(str)

# I have also tried

df.pris_yrs = df.pris_yrs.apply(str)

Checking the dtype of the dataframe returns an object which is also a string in Pandas, but Create ML still is having the same error.检查 dataframe 的 dtype 返回一个 object,它也是 Pandas 中的一个字符串,但 Create ML 仍然有相同的错误。

Question: How do I get an a dataframe object to work as the target in Create ML?问题:如何获得 a dataframe object 作为 Create ML 中的目标?

To transform one column of a dataframe to int I recommend you:要将 dataframe 的一列转换为int ,我建议您:

df["pris_yrs "]=df["pris_yrs "].astype(int)

For every ML model you should use numerical targets (even if you have a categorical feature, you can transform it easily labelling it).对于每个 ML model,你应该使用数字目标(即使你有一个分类特征,你也可以很容易地转换它来标记它)。

You obtain an error probably because your ML model don't support a string as a target.您收到错误可能是因为您的 ML model 不支持将字符串作为目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM