<jupyter_start><jupyter_text>We begin similar to the tutorial, loading the data using Pandas, then converting to Numpy, taking only the two columns we need, converting from inches to centimeters, and pounds to kilograms:<jupyter_code>import numpy as np
import matplotlib.pyplot as pp
import pandas as pd
dataframe=pd.read_csv("https://raw.githubusercontent.com/PerttuHamalainen/MediaAI/master/Code/Datasets/weight-height.csv")
data=np.array(dataframe)
data=data[:,1:]
data=data.astype(np.float) 
data[:,0]*=2.54   
data[:,1]*=0.45359237<jupyter_output>c:\condaenvs\tensorflow2\lib\site-packages\numpy\_distributor_init.py:32: UserWarning: loaded more than 1 DLL from .libs:
c:\condaenvs\tensorflow2\lib\site-packages\numpy\.libs\libopenblas.BNVRK7633HSX7YVO2TADGR4A5KEKXJAW.gfortran-win_amd64.dll
c:\condaenvs\tensorflow2\lib\site-packages\numpy\.libs\libopenblas.PYQHXLVVQ7VESDPUVUADXEVJOBGHJPAY.gfortran-win_amd64.dll
  stacklevel=1)<jupyter_text>The first exercise was to only plot the first N points. This is easy with Python's flexible tensor indexing, no for loops needed.<jupyter_code>N=20
pp.scatter(data[:N,0],data[:N,1],marker=".")
pp.title("Relation of height and weight")
pp.xlabel("Height (centimeters)")
pp.ylabel("Weight (kilograms)")<jupyter_output><empty_output><jupyter_text>The second exercise was to visualize how the mean of height changes when you compute it from different amounts of data. The key lesson here is that mean computed from noisy data is also noisy, i.e., mean of random variables is also random variable.  Above, we've already used the ":" symbol to denote "all indices". It can also be used for defining arbitrary ranges. Note the following:* The indexing is zero-based, i.e., index 1 is the second element and index 0 is the first.* A range a:b includes a but not b. Instead, the last index in the range is b-1. Thus, this is how you print three elements starting from the second one:<jupyter_code>#we will use up to this many data points
maxData=1000  
#allocate a Numpy array for the results
means=np.zeros(maxData)
#loop over the ranges
for i in range(maxData):
    means[i]=np.mean(data[:i+1,0])
    
pp.plot(means)
pp.title("Mean of height with different amounts of data")
pp.xlabel("Number of data points")
pp.ylabel("Mean")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10221835580687255, 'fraction_numerical': 0.020878642888212267, 'mean_word_length': 5.7251461988304095, 'pattern_counts': {'":': 1, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '456486', 'license': 'Apache-2.0', 'n_tokens_mistral': 805, 'n_tokens_neox': 754, 'n_words': 243, 'path': 'Code/Jupyter/DataAndTensors_solutions.ipynb', 'repo_name': 'fcole90/MediaAI', 'size': '2299'}