<jupyter_start><jupyter_text>Simple Logging TutorialIn this tutorial, we will use a simple script that maintains two variables. Our goal is to log the values of these variables using TensorWatch and view it in real-time in variety of ways from Jupyter Notebook demonstrating various features offered by TensorWatch. We would execute this script from a console and its code looks like this: ``` available in test/simple_log/sum_log.pyimport time, randomimport tensorwatch as tw we will create two streams, one for  sums of integers, other for random numbersw = tw.Watcher()st_isum = w.create_stream('isums')st_rsum = w.create_stream('rsums')isum, rsum = 0, 0for i in range(10000):    isum += i    rsum += random.randint(i)     write to streams    st_isum.write((i, isum))    st_rsum.write((i, rsum))    time.sleep(1)```  Basic ConceptsThe `Watcher` object allows you to create streams. You can then write any values in to these streams. By default, the `Watcher` object opens up TCP/IP sockets so a client can request these streams. As values are being written on one end, they get serialized and sent to any client(s) on the other end. We will use Jupyter Notebook to create a client, open these streams and feed them to various visualizers. Create the ClientYou can either create a new Jupyter Notebook or get the existing one in the repo at `notebooks/simple_logging.ipynb`. Let's first do imports:<jupyter_code>%matplotlib notebook
import tensorwatch as tw<jupyter_output><empty_output><jupyter_text>Next, open the streams that we have created in above script:<jupyter_code>cli = tw.WatcherClient()
st_isum = cli.open_stream('isums')
st_rsum = cli.open_stream('rsums')<jupyter_output><empty_output><jupyter_text>Now lets visualize isum stream in textual format:<jupyter_code>text_vis = tw.Visualizer(st_isum, vis_type='text')
text_vis.show()<jupyter_output><empty_output><jupyter_text>That worked out good! How about feeding the same stream simultaneously to plot a graph?<jupyter_code>line_plot = tw.Visualizer(st_isum, vis_type='line', xtitle='i', ytitle='isum')
line_plot.show()<jupyter_output><empty_output><jupyter_text>Let's take step further. Say, we plot rsum as well but, just for fun, in the *same plot* as isum above. That's easy with the optional `host` parameter:<jupyter_code>line_plot2 = tw.Visualizer(st_rsum, vis_type='line', host=line_plot, ytitle='rsum')<jupyter_output><empty_output><jupyter_text>This instantly changes our line plot and a new Y-Axis is automatically added for our second stream. TensorWatch allows you to add multiple streams in same visualizer.Are you curious about statistics of these two streams? Let's display the live statistics of both streams side by side! To do this, we will use the `cell` parameter for the second visualization to place right next to the first one:<jupyter_code>istats = tw.Visualizer(st_isum, vis_type='summary')
istats.show()

rstats = tw.Visualizer(st_rsum, vis_type='summary', cell=istats)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08090939485122033, 'fraction_numerical': 0.003009027081243731, 'mean_word_length': 6.007025761124122, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '636390', 'license': 'MIT', 'n_tokens_mistral': 918, 'n_tokens_neox': 899, 'n_words': 352, 'path': 'notebooks/simple_logging.ipynb', 'repo_name': 'NunoEdgarGFlowHub/tensorwatch', 'size': '2991'}