= np.linspace(0,5,44100*5)
t = np.sin(2*np.pi*520*t)
sine = Audio(sine, rate=44100)
audio
display(audio)
Neat Tricks from other Libs
Small tricks and small usage libs I had no other place to put on
IPython
Displaying audio
Displaying Progress Bar
HTML style
= ProgressBar(12)
pb for _ in pb: time.sleep(0.5)
Old school
for i in range(11):
= i
pb.progress print('\r', pb, sep='', end='')
0.5) time.sleep(
[================================================== ] 10/12
Changing ProgressBar
properties
= ProgressBar(35)
pb2 = '70ex'
pb2.html_width = 50
pb2.text_width pb2.display()
for i in range(11):
= i
pb2.progress print('\r', pb2, sep='', end='')
0.5) time.sleep(
[============== ] 10/35
Displaying HTML
= '''<table>
html <tr>
<th>Method</th>
<th>Pros</th>
<th>Cons</th>
</tr>
<tr>
<td>KS-test</td>
<td>Easy to implement, widely used, suitable for continuous data</td>
<td>Assumes normal distribution, may not work well for small sample sizes</td>
</tr>
<tr>
<td>t-test</td>
<td>Easy to implement, widely used, suitable for continuous data</td>
<td>Assumes normal distribution, may not work well for small sample sizes, requires equal variances</td>
</tr>
<tr>
<td>Jensen-Shannon</td>
<td>Works well for both continuous and discrete data, does not assume normal distribution</td>
<td>May be computationally expensive for large datasets, may not work well for high-dimensional data</td>
</tr>
<tr>
<td>Wasserstein distance</td>
<td>Works well for both continuous and discrete data, does not assume normal distribution</td>
<td>May be computationally expensive for large datasets, may not work well for high-dimensional data</td>
</tr>
<tr>
<td>PSI</td>
<td>Can detect both magnitude and direction of drift, suitable for both continuous and categorical data</td>
<td>May be sensitive to small changes, may require a large reference dataset</td>
</tr>
</table>'''
display(HTML(html))
Method | Pros | Cons |
KS-test | Easy to implement, widely used, suitable for continuous data | Assumes normal distribution, may not work well for small sample sizes |
t-test | Easy to implement, widely used, suitable for continuous data | Assumes normal distribution, may not work well for small sample sizes, requires equal variances |
Jensen-Shannon | Works well for both continuous and discrete data, does not assume normal distribution | May be computationally expensive for large datasets, may not work well for high-dimensional data |
Wasserstein distance | Works well for both continuous and discrete data, does not assume normal distribution | May be computationally expensive for large datasets, may not work well for high-dimensional data |
PSI | Can detect both magnitude and direction of drift, suitable for both continuous and categorical data | May be sensitive to small changes, may require a large reference dataset |
Display Math expressions
'$ {x_{a}}^2$') Math(
\(\displaystyle {x_{a}}^2\)
PyAutoGUI
= True
pa.FAILSAFE = pa.size()
w,h 42)
random.seed(
def moveWithin():
0,w),random.randint(0,h), duration=2)
pa.moveTo(random.randint(
while True:
try:
moveWithin()except pa.FailSafeException:
print(f"Stopping with the randomness 'cause: {pa.FailSafeException}")
break
print(pa.position())
Stopping with the randomness 'cause: <class 'pyautogui.FailSafeException'>
Point(x=0, y=1079)
Redlines
Find differences between two texts
= 'She sells seashells in Seychelles'
t1 = 'She shells seysells in Seachelles'
t2 = Redlines(t2, t1)
diff display(Markdown(diff.output_markdown))
She shells seysells sells seashells in SeachellesSeychelles