pandas describe() 不显示

我正在按照谷歌的机器学习课程学习,并尝试在Atom上运行,而不是简单地使用Colab版本。模型训练和其他部分都进行得很顺利,但我在使用describe()函数时遇到了问题。我查阅了文档,但仍然无法显示摘要。只有在命令行上使用交互式Python时它才有效。以下是我代码的相关部分。感谢您的帮助。

import mathfrom IPython import displayfrom matplotlib import cmfrom matplotlib import gridspecfrom matplotlib import pyplot as pltimport numpy as npimport pandas as pdfrom sklearn import metricsimport tensorflow as tffrom tensorflow.python.data import Datasettf.logging.set_verbosity(tf.logging.ERROR)pd.options.display.max_rows = 10pd.options.display.float_format = '{:.lf}'.format# Load data setcalifornia_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:

然后继续进行模型训练。


回答:

在不知道堆栈跟踪的情况下,我的猜测是

pd.options.display.float_format = '{:.lf}'.format

中的一个打字错误影响了您的数据输入。那个字母 l 应该是数字 1。您是在告诉格式化程序您想要打印的浮点精度的位数。正确的语法是

pd.options.display.float_format = '{:.1f}'.format

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注