我正在学习有关机器学习的Google课程,并试图使其在Atom上运行,而不是简单地使用colab版本。模型训练和其他工作进展顺利,但使用describe()函数时遇到问题。我已经查阅了文档,但是仍然无法显示摘要。它仅在我在命令行上尝试交互式python时有效。我的代码的相关部分如下。谢谢您的帮助。
import math
from IPython import display
from matplotlib import cm
from matplotlib import gridspec
from matplotlib import pyplot as plt
import numpy as np
import pandas as pd
from sklearn import metrics
import tensorflow as tf
from tensorflow.python.data import Dataset
tf.logging.set_verbosity(tf.logging.ERROR)
pd.options.display.max_rows = 10
pd.options.display.float_format = '{:.lf}'.format
# Load data set
california_housing_dataframe = pd.read_csv("https://storage.googleapis.com/mledu-datasets/california_housing_train.csv", sep=",")
......
# Split the data set into training sets of the first 12000/17000 examples,
training_examples = preprocess_features(california_housing_dataframe.head(12000))
training_targets = preprocess_targets(california_housing_dataframe.head(12000))
# and validation sets of the last 5000/17000 examples.
validation_examples = preprocess_features(california_housing_dataframe.tail(5000))
validation_targets = preprocess_targets(california_housing_dataframe.tail(5000))
# Double-check that the splitting is correct. (NOT WORKING YET)
print("Training examples summary:")
training_examples.describe()
运行代码后,我的终端仅忽略了describe()的行并打印出
Training examples summary: Validation examples summary: Training targets summary: Validation targets summary:
然后进行训练模型。
我也在做Google的ML课程,并遇到了一个相同的问题,即describe函数未打印到我的输出窗口。对我有用的是将describe()包装在下面的print()函数中。
打印(california_housing_dataframe.describe())
那在我的输出窗口中产生了描述性统计数据。
免责声明:我正在从Sublime而不是Atom运行python程序,并且正在使用以下软件包:
崇高文字3
熊猫0.23.0
张量流-gpu 1.8.0
CUDA 9.0.176.2
库顿7.1
希望这可以帮助!