Spaces:
Runtime error
Runtime error
File size: 1,729 Bytes
e82c355 1115bb5 e82c355 1115bb5 e82c355 bf902a7 93ec191 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# %%
import pandas as pd
import numpy as np
np.random.seed(24)
df = pd.DataFrame({'A': np.linspace(1, 10, 10)})
df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), columns=list('BCDE'))],
axis=1)
df.iloc[0, 2] = np.nan
df['reaction_show'] = True
df
# %%
s = ''
for v in df.reaction_show:
s += str(int(v))
s
# %%
s = '101100'
g2p = ''
for i in range(len(s)-1):
# print(i, i+2, s)
# print(s[0:2])
g2p += '1' if '1' in s[i:i+2] else '0'
g2p
# %%
# import plotly.express as px
from plotly.offline import init_notebook_mode, iplot
import numpy as np
init_notebook_mode()
x = np.linspace(0, 1)
iplot([{'x': x, 'y': 1-np.exp(-x)}])
# # def highlight_greaterthan(s,column):
# # is_max = pd.Series(data=False, index=s.index)
# # is_max[column] = s.loc[column] >= 1
# # return ['background-color: red' if is_max.any() else '' for v in is_max]
# def highlight_greaterthan_1(s):
# if s.B > 1.0:
# return ['background-color: white']+['background-color: yellow']+['background-color: white']*3
# else:
# return ['background-color: white']*5
# df.style.apply(highlight_greaterthan_1, axis=1)
# %%
from transformers import pipeline
classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base", return_all_scores=True)
emotion = classifier("the sentence")
# %%
emotion[0]
# %%
emotion[0][0]
# %%
sorted(emotion[0], key=lambda x: x['score'], reverse=True)
# %%
import random
values = [1,2, 3, 4, 5, 6]
k = random.randint(0,len(values))
numbers = random.choices(values, k=k)
print(k, "random numbers", numbers)
# %%
k = random.randint(0,len(values))
numbers = random.sample(values, k=k)
print(k, "random numbers", numbers)
# %%
|