【问题标题】:Not getting the same output as the tutorial没有得到与教程相同的输出
【发布时间】:2020-12-01 19:08:04
【问题描述】:

我正在尝试Kaggle 上的机器学习教程

当他们这样做时,他们得到的输出是:Kaggle outupt

这是我的代码:

import pandas as pd

pd.set_option('display.max_rows', 5000)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
# Read file from source
data = pd.read_csv(r"C:\Users\harsh\Documents\My Dream\Desktop\Machine Learning\melb_data.csv", skiprows=0)

data = data.dropna(axis=0)

# Column that you want to predict = y
y = data.Price

# Columns that are inputted into the model to make predictions (dependants)
data_features = ['Rooms', 'Bathroom', 'Landsize', 'Lattitude', 'Longtitude']

X = data[data_features]

from sklearn.tree import DecisionTreeRegressor

# Define model. Specify a number for random_state to ensure same results each run
data_model = DecisionTreeRegressor(random_state=1)

# Fit model
data_model.fit(X, y)

我的输出只是

 Process finished with exit code 0

每当我想在运行区域中输出任何内容时,我都必须将函数放入print()

我的问题主要是:

  1. 如何在我的 PyCharm 中将输出作为 Kaggle 输出?我是否正确配置了 IDE?

  2. 为什么每次都需要放print()函数来显示结果?我需要这么长时间吗?

  3. 使用 print(),我得到如下输出:

    DecisionTreeRegressor(random_state=1)

    我错过了什么?

我正在使用 PyCharm 2019.2.6 和 Python 3.7 配置

【问题讨论】:

    标签: python machine-learning scikit-learn decision-tree


    【解决方案1】:

    Sklearn 没有打印出模型参数。您可以使用print(data_model.get_params()) 打印DecisionTreeRegressor 参数

    【讨论】:

    • 有没有办法在没有打印功能的情况下得到输出?
    • @Harshad 可能与sklearn的版本有关,我在Jupyter中运行示例代码时没有任何输出。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-06
    • 2016-06-19
    • 2018-12-21
    相关资源
    最近更新 更多