Spaces:
Runtime error
Runtime error
# %% | |
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) | |
# %% | |