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
import matplotlib.pyplot as plt | |
from scipy.integrate import quad | |
import numpy as np | |
plt.style.use("ggplot") | |
Vn = 132000 # Nominal voltage [V] | |
E = Vn * np.sqrt(2) / np.sqrt(3) # Peak phase voltage [V] | |
l = 80 # Line length [km] | |
L = 0.00048 * l # Line inductance [H] | |
R = 0.0754 * l # Line resistance [Ohm] |
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
import matplotlib.pyplot as plt | |
import numpy as np | |
plt.style.use("ggplot") | |
#------------------------------------------------------------------------------- | |
# Auxiliary functions | |
# Complex power | |
def complex_power(p, q): | |
return np.sqrt(p**2 + q**2) |
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
import numpy as np | |
import matplotlib.pyplot as plt | |
plt.style.use("ggplot") | |
#------------------------------------------------------------------------------- | |
# Helper functions | |
# Derive the function f and evaluate it in t | |
def differentiate(f, t, dt=0.01): | |
f_prime = (f(t + dt) - f(t))/dt |
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
import numpy as np | |
# R matrix | |
R = np.matrix([ [-1,-1,-1,-1,0,-1], | |
[-1,-1,-1,0,-1,100], | |
[-1,-1,-1,0,-1,-1], | |
[-1,0,0,-1,0,-1], | |
[-1,0,0,-1,-1,100], | |
[-1,0,-1,-1,0,100] ]) |
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
import tensorflow as tf | |
import pandas as pd | |
from sklearn.cross_validation import train_test_split | |
FILE_PATH = '~/Desktop/bank-add/bank_equalized.csv' # Path to .csv dataset | |
raw_data = pd.read_csv(FILE_PATH) # Open raw .csv | |
print("Raw data loaded successfully...\n") | |
#------------------------------------------------------------------------------ | |
# Variables |
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
import pandas as pd | |
import numpy as np | |
from sklearn import preprocessing | |
# Load data | |
data = pd.read_csv('bank-additional-full.csv', sep = ";") | |
# Variables names | |
var_names = data.columns.tolist() | |
# Categorical vars |
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
################################################################################ | |
# Loading data | |
rm( list=ls() ) | |
# load libs | |
require(neuralnet) | |
require(nnet) | |
# Load data and set names |
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
require(neuralnet) # neuralnet,compute, functions | |
require(nnet) # class.ind function | |
# Clearing workspace | |
rm( list=ls() ) | |
# Set seed | |
set.seed(100) | |
# Loading data |
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
set.seed(1) | |
# define some functions | |
## convert integer to binary | |
i2b <- function(integer, length=8) | |
as.numeric(intToBits(integer))[1:length] | |
## apply | |
int2bin <- function(integer, length=8) |
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
# Clean workspace | |
rm(list=ls()) | |
# Load MXNet | |
require(mxnet) | |
# Loading data and set up | |
#------------------------------------------------------------------------------- | |
# Load train and test datasets |