Usage

PyLearn provides different features from supervised and unsupervised learning.

To use them, just import pylearn:

import pylearn as pl

Each model can be saved to storage to prevent training your model again. Just import it:

import pl.save, pl.load

If you want to normalize your input data, simply import:

import pl.min_max_normalization, pl.z_normalization

You can evaluate every model with accuracy, precision, recall and F1 score:

import pl.accuracy, pl.precision, pl.recall, pl.f1_score

Change numbers into a one hot representation:

import pl.to_one_hot

The major features are:


Classification

You can use Gaussian Naive Bayes.

Gaussian works for continuous data. Multinomial Naive Bayes works perfect for text classification and will come in version 1.1.0.

The usage is quite simple:

gnb = pl.GaussianNaiveBayes()

Now, train the model by using the fit function:

gnb.fit(features, output)

Let the model predict your input:

gnb.predict(features)


Clustering

You can choose between K-Means and K-Medoids as clustering models.

The usage of both is quite similar:

kmeans = pl.KMeans()
kmedoids = pl.KMedoids()

Now, train the model by using the fit function, we will use kmeans to continue:

kmeans.fit(points)

This returns a list of the to the data points assigned clusters. You could visualize the result with matplotlib.


If you want to customize the result, the following functions may help you:

kmeans.assigned_clusters(any_cluster)
kmeans.rename(old, new)


Neural Network

The neural network comes with different activation functions and loss functions.

First, you need to create a network, for example:

network = [
     pl.Dense_layer(input_length, output_length),
     pl.Tanh(),
     plpDense_layer(input_length, output_length),
     pl.Tanh()
 ]

Now, train the model:

pl.NeuralNetwork.fit(x_train, y_train, network, loss, loss_derivative, epochs, log_error, log_duration)

Let the model predict your input:

pl.NeuralNetwork.predict(x, network)