【问题标题】:Not able to load dataset as per the instructions in article无法按照文章中的说明加载数据集
【发布时间】:2019-06-01 03:24:13
【问题描述】:

我是数据科学领域的新手。 我是通过这篇文章来的 https://towardsdatascience.com/train-test-split-and-cross-validation-in-python-80b61beca4b6 在这里,我无法按照他们编写的代码加载糖尿病数据集。

# Load the Diabetes dataset

columns = “age sex bmi map tc ldl hdl tch ltg glu”.split() # Declare the columns names
diabetes = datasets.load_diabetes() # Call the diabetes dataset from sklearn
df = pd.DataFrame(diabetes.data, columns=columns) # load the dataset as a pandas data frame
y = diabetes.target # define the target variable (dependent variable) as y

我曾尝试通过 csv 加载数据集,但没有成功。

【问题讨论】:

  • 尝试时会发生什么?您收到错误消息吗?将其包含在您的问题中。
  • 确保使用实引号 " 来分隔字符串,而不是代码片段中的 ”,

标签: python python-3.x machine-learning


【解决方案1】:

正如@DYZ所说,这是引号问题,复制粘贴下面并运行

import pandas as pd
from sklearn import datasets, linear_model
from sklearn.model_selection import train_test_split
from matplotlib import pyplot as plt



columns = "age sex bmi map tc ldl hdl tch ltg glu".split() # Declare the columns names
diabetes = datasets.load_diabetes() # Call the diabetes dataset from sklearn
df = pd.DataFrame(diabetes.data, columns=columns) # load the dataset as a pandas data frame
y = diabetes.target # define the target variable (dependent variable) as y

【讨论】:

    猜你喜欢
    • 2019-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-03
    • 1970-01-01
    • 1970-01-01
    • 2013-12-14
    相关资源
    最近更新 更多