Skip to content

Instantly share code, notes, and snippets.

View mick001's full-sized avatar

Michy mick001

View GitHub Profile
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]
@mick001
mick001 / radial_lines.py
Created November 30, 2016 10:51
A program to solve radial transmission lines in Python.
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)
@mick001
mick001 / skydivers.py
Created September 13, 2016 11:26
Simulation of a skydiving in Python
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
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] ])
@mick001
mick001 / dmlp.py
Last active March 13, 2019 08:16
Deep MLP in Tensorflow.
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
@mick001
mick001 / preprocessing_b.py
Created September 11, 2016 16:03
Preprocessing the Bank Marketing dataset
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
@mick001
mick001 / mtlbl_clf.R
Created August 25, 2016 00:37
Multilabel classification using R and the neuralnet package
################################################################################
# Loading data
rm( list=ls() )
# load libs
require(neuralnet)
require(nnet)
# Load data and set names
@mick001
mick001 / mtlbl_pr.R
Last active August 19, 2016 12:26
Multilable prediction in R using neuralnet package.
require(neuralnet) # neuralnet,compute, functions
require(nnet) # class.ind function
# Clearing workspace
rm( list=ls() )
# Set seed
set.seed(100)
# Loading data
@mick001
mick001 / LSTM.R
Created August 8, 2016 19:54 — forked from bquast/LSTM.R
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)
@mick001
mick001 / convolutional_nn_tutorial_3.R
Last active May 7, 2019 09:36
Image recognition tutorial in R using deep convolutional neural networks (MXNet package). Part 3. Full article at https://firsttimeprogrammer.blogspot.com/2016/08/image-recognition-tutorial-in-r-using.html
# Clean workspace
rm(list=ls())
# Load MXNet
require(mxnet)
# Loading data and set up
#-------------------------------------------------------------------------------
# Load train and test datasets