MLDLNL is a tensorflow based high level API. It facilitates creating machine learning models(for now).
-Python -Numpy -Tensorflow 1.x.x
You can run the module including into working directory. You can also install it into python3. After the installation, you can run the module without including into working directory.
Follow this steps for install the module(optional)- Open the terminal. After that
git clone https://github.com/alihakimtaskiran/mldlnl.git
cd "mldlnl"
sudo cp mldlnl.py /usr/lib/python[version]
- If you haven't installed numpy, install the numpy with
pip3 install numpy
- If you haven't installed tensorflow 1.x, install the tensorflow 1.x with
pip3 install tensorflow==1.15.0
Finally, you can use the module in python3 just one lines of code:import mldlnl
mldlnl---| | |---LinReg()--| | |--fit(x,y,lr=0.1,iter_no=80000,loss_fun="L2",lang="en") | |--get_variables() | |--calc(x) | |--save(file_name) | |--restore(file_name) | |--restore_manually(weight,bias) | | |---MultiLinReg(n_of_params)--| | |--fit(x,y,lr=0.05,iter_no=70000,loss_fun="L2",lang="en") | |--get_variables() | |--calc(x) | |--save(file_name) | |--restore(file_name) | | |---Perceptron(neurons=[1,1,1],activation_fun="tanh")--| | |--fit(x,y,epochs=5,batch_size=200,lr=0.01,keep_prob=1.) | |--calc(x,argmax=False) | |--save(file) | |--restore(file) | |--test(x,y) | |--properties() | | |---tools--| | |--split_batch(x,batch_size) | | |---ExpReg()--| | |--fit(x,y,lr=0.01,iter_no=50000) | |--calc(x) | |--get_variables() | |--save(n_of_file) | |--restore(n_of_file) | |---CExpReg()--| |--fit(x,y,lr=0.01,iter_no=50000) |--calc(x) |--get_variables() |--save(n_of_file) |--restore(n_of_file)
-
type:objectLinear Regression object. Use this object to create linear regression models.
fit(x,y,lr=0.1,iter_no=80000,loss_fun="L2",lang="en")
type:method fit() optimizes model with specic loss function. It uses
tf.train.AdamOptimizer to find optimum weight and bias
.x
is input,y
is output.lr
islearning rate, it's default 0.1.iter_no
is number of train step.loss_fun
is a string represents loss function.It's default L2, you can also use L1 with"L1"
.
get_variables()
type:method The function exports variables and returns a tupleweight,bias)
calc(x)
type:method
Computes the output value with spesific input.
save(file_n)
type:method
Exports and saves parametrs into a file.file_n
is a string takes name of file. Don't add directory into the string.
restore(file_n)
type:method
Imports and restores parameters from file.file_n
is a string takes name of file. Don't add directory into the string.
restore_manually(W,B)
type:method
This function utilizes restore parameters manually. You can initialize variables by this function.
type:object
n_of_params
is number of parameters.
fit(x,y,lr=0.1,iter_no=80000,loss_fun="L2",lang="en")
type:method fit() optimizes model with specific loss function. It uses tf.train.AdamOptimizer to find optimum weight and bias
.x
is input,y
is output. lr
is learning rate, it's default 0.1.iter_no
is number of train step.loss_fun
is a string represents loss function.It's default L2, you can also use L1 with "L1"
.
get_variables()
type:method The function exports variables and returns a tupleweight,bias)
calc(x)
type:method
Computes the output value with spesific input.
save(file_n)
type:method
Exports and saves parametrs into a file.file_n
is a string takes name of file. Don't add directory into the string.
restore(file_n)
type:method
Imports and restores parameters from file.file_n
is a string takes name of file. Don't add directory into the string.
type:object
neurons
is a list(like [784,256,128,10]
) to represent number of neuron per layer. The list should have at least 3 elements.activation_fun
is specific activation function for perceptron.tanh
,ReLU
and sigmoid
are supported activation functions. Activation function of last layer is softmax
independed from specific activation function.
fit(x,y,epochs=5,batch_size=200,lr=0.01,keep_prob=1.)
type:method fit()
utilizes train perceptron. It uses AdamOptimizer to optimize model.x
is input data and y
is output data to train perceptron. You don't need to split into batchs the data. Percepton
object has internal batch splitting system.epochs
is training epochs.batch_size
is default set into 200.lr
is default set into 0.01.keep_prob
is probibilty of retained neurons after dropout
calc(x,argmax=False)
type: method This function feed forwards an input value. You can compute the output of perceptron.x
is input. argmax
is a boolean. If it's True, the function returns index of maximum value of percpetron's output. If it's False, function returns output of perceptron.
save(file)
type:method It exports parameters of perceptrons into a filefile
is name of the file.
restore(file)
type:method It imports parameters of perceptron from file. file
is name of the file.
test(x,y)
type:method Computes cross entropy loss and accuracy of spesific data. x
is input and y
is true output. Function returns loss,accuracy
properties()
type:method Shows number of neurons in each layer and activation function. Function returns a tuple (neurons, activation function)
- This class contains usefull tools for data science.
type:class
split_batch(x,batch_size)
type:method This function facilates spliting dataset into batchs.x
is input data, batch_size
is size of batch, it's an integer.
ExpReg object utilizes creating exponential regression model. It's ideal for pandemic analysis. Number of infected poeple growth exponentially.
- type:class
- fit(x,y,lr=0.01,iter_no=50000)
type:method
It optimizes the model with dataset.x
is dataset's x values andy
is y values of dataset.lr
is learning rate set as 0.01.iter_no
is training steps for optimizer. calc(x)
type:method
Computes the output value with spesific input.
get_variables()
save(n_of_file)
type:method The function exports variables and returns a tupleweight,bias)
type:method
Exports and saves parametrs into a file.n_of_file
is a string takes name of file. Don't add directory into the string.
restore(n_of_file)
type:method
Imports and restores parameters from file.n_of_file
is a string takes name of file. Don't add directory into the string.
CExpReg object utilizes creating exponential regression model. It's a bit complex than exponential regression. It has more variables than ExpReg. It's ideal for pandemic analysis more than ExpReg.
- type:class
- fit(x,y,lr=0.01,iter_no=50000)
type:method
It optimizes the model with dataset.x
is dataset's x values andy
is y values of dataset.lr
is learning rate set as 0.01.iter_no
is training steps for optimizer. calc(x)
type:method
Computes the output value with spesific input.
get_variables()
save(n_of_file)
type:method The function exports variables and returns a tupleweight,bias)
type:method
Exports and saves parametrs into a file.n_of_file
is a string takes name of file. Don't add directory into the string.
restore(n_of_file)
type:method
Imports and restores parameters from file.n_of_file
is a string takes name of file. Don't add directory into the string.