I am following Google's Machine Learning Crash Course, so that I can move on to TensorFlow. However, when I try to execute the code in First Steps With TensorFlow, I get no output from the following line:
california_housing_dataframe.describe()
Here is my full code in case it helps:
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 = '{:.1f}'.format
california_housing_dataframe = pd.read_csv("https://storage.googleapis.com/mledu-datasets/california_housing_train.csv", sep=",")
california_housing_dataframe = california_housing_dataframe.reindex(np.random.permutation(california_housing_dataframe.index))
california_housing_dataframe["median_house_value"] /= 1000.0
california_housing_dataframe.describe()
So far, I have tried the following:
Execute the .py file with the python command.
Execute the .py file with the ipython command. I also tried to use arguments -i -c (i.e. ipython -i -c "%run filename.py").
Open ipython.exe and use the run command to execute my script.
Open ipython.exe and copy the code line by line.
Out of the above, only copying every line individually into IPython gave proper output. Is there a way to execute my script without having to copy every line in IPython?
Within a program only the function creating the summary in describe()
is executed; in a console environment silently the result is automatically printed as well, as this is what you typically want to see there.
In your program you would have to call
print(california_housing_dataframe.describe())
explicitly.
The interactive python console, jupyter console etc are geared up to allow you to type a variable name, or it's attribute to display it. This is not the case when running a script non-interactively. Instead you must use the print()
function.
print(varaible_name.attribute)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With