This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_signal_train.isnull().sum().sum() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
preds_test = [] | |
for i in range(N_SPLITS): | |
model.load_weights('weights_{}.h5'.format(i)) | |
pred = model.predict(X_test_input, batch_size=300, verbose=1) | |
pred_3 = [] | |
for pred_scalar in pred: | |
for i in range(3): | |
pred_3.append(pred_scalar) | |
preds_test.append(pred_3) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to open/create a new html file in the write mode | |
f = open('index8050.html', 'w') | |
# the html code which will go in the file GFG.html | |
html_template = """<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<h2>VSB Power Line Fault Detection:Classification</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subplot = sns.countplot(x='target', data=df_metadata_train) | |
# https://github.com/mwaskom/seaborn/issues/1582 | |
for i,j in enumerate(subplot.patches): | |
percent = np.round((df_metadata_train[df_metadata_train['target']==i].shape[0]/df_metadata_train['target'].shape[0])*100, 2) | |
subplot.annotate(str(df_metadata_train[df_metadata_train['target']==i].shape[0]) + f" ({percent}%)", | |
(j.get_x()+j.get_width()/2, j.get_height())) | |
plt.title("Distribution of target classes") | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sns.countplot(x = 'target',hue = 'phase',data =df_metadata_train) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.w3resource.com/graphics/matplotlib/piechart/matplotlib-piechart-exercise-2.php | |
data = df_metadata_train['phase'].value_counts() | |
labels = ['Phase 0', 'Phase 1', 'Phase 3'] | |
#colors = ["#1f77b4", "#ff7f0e", "#2ca02c"] | |
title = 'Count of signals distributed by phase' | |
plt.pie(data, labels=labels, shadow=True, startangle=90,autopct='%.1f%%') | |
plt.title(title, bbox={'facecolor':'0.8', 'pad':5}) | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.manifold import TSNE | |
tsne = TSNE(n_components=2, perplexity=30, learning_rate=200, random_state=42) | |
X_embedding = tsne.fit_transform(df_signal_train) | |
y = np.array(df_signal_train['target']) | |
tsne = np.hstack((X_embedding, y.reshape(-1,1))) | |
tsne_to_df = pd.DataFrame(data=tsne, columns=['Dimension_x','Dimension_y','Score']) | |
colors = {0:'red', 1:'blue', 2:'green'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig=plt.figure(figsize=(14, 8), dpi= 120, facecolor='w', edgecolor='k') | |
plot_labels = ['Phase_0', 'Phase_1', 'Phase_2'] | |
plt.plot((df_signal_train.loc[0].values), label=plot_labels[0]) | |
plt.plot((df_signal_train.loc[1].values), label=plot_labels[1]) | |
plt.plot((df_signal_train.loc[2].values), label=plot_labels[2]) | |
plt.ylim((-60, 60)) | |
plt.legend(loc='lower right') | |
plt.title('Raw Signal Data without Partial Discharge Fault') | |
plt.xlabel('Sample') | |
plt.ylabel('Amplitude [bit]') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def filtering(x, alpha=50, beta=1): | |
x_new = np.zeros_like(x) | |
zero = x[0] | |
for i in range(1, len(x)): | |
zero = zero*(alpha-beta)/alpha + beta*x[i]/alpha | |
x_new[i] = x[i] - zero | |
return x_new | |
#Flattening a Normal signal | |
normal_signal_filter = [None] * 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def standardize_data(signal, min_data, max_data, range_needed=(-1,1)): | |
if min_data < 0: | |
signal_std = (signal + abs(min_data)) / (max_data + abs(min_data)) | |
else: | |
signal_std = (signal - min_data) / (max_data - min_data) | |
if range_needed[0] < 0: | |
return signal_std * (range_needed[1] + abs(range_needed[0])) + range_needed[0] | |
else: | |
return signal_std * (range_needed[1] - range_needed[0]) + range_needed[0] |
OlderNewer