https://github.com/becxer/pytrain
Machine Learning library for python
https://github.com/becxer/pytrain
apriori clustering crf dbscan decision-trees feedforward-neural-network hmm kmeans knn linear-regression logistic-regression machine-learning naive-bayes neural-network numpy pattern-recognition python svm
Last synced: 9 days ago
JSON representation
Machine Learning library for python
- Host: GitHub
- URL: https://github.com/becxer/pytrain
- Owner: becxer
- License: mit
- Created: 2015-10-15T11:58:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-09-04T06:38:19.000Z (over 3 years ago)
- Last Synced: 2025-12-15T18:05:20.490Z (4 months ago)
- Topics: apriori, clustering, crf, dbscan, decision-trees, feedforward-neural-network, hmm, kmeans, knn, linear-regression, logistic-regression, machine-learning, naive-bayes, neural-network, numpy, pattern-recognition, python, svm
- Language: Python
- Homepage:
- Size: 39.4 MB
- Stars: 21
- Watchers: 3
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pytrain
Machine Learning library for python
This library implemented only with python and numpy

## Algorithms
+ Decision Tree(ID3)
+ Gaussian NaiveBayes
+ NaiveBayes
+ KNN
+ Neural Network(FNN)
+ Logistic Regression
+ Linear Regression
+ DBSCAN
+ Apriori
+ Kmeans
+ HierarchicalClustering
+ SVM
+ SVC (SVM classifier)
+ HMM
+ CRF
## Requirements
- Numpy
- Python 2 or 3
## Installation
$ sudo pip install --upgrade pytrain
## Basic Usage
import numpy as np
from pytrain.NeuralNetwork import FNN
# Simple dataset
train_mat = [[0.12,0.25],[3.24,4.33],[0.14,0.45],[7.30,4.23]]
train_label = [[0,1],[1,0],[0,1],[1,0]]
test_a = [0.10,0.33]
test_b = [4.0,4.5]
# Train model (FNN)
hidden_layer = [3,2]
fnn = FNN(train_mat, train_label, hidden_layer)
fnn.fit(lr = 0.01, epoch = 2000, err_th = 0.001, batch_size = 4)
# Test model (FNN)
res_a = np.rint(fnn.predict(test_a))
res_b = np.rint(fnn.predict(test_b))
print("X %s => Y %s" % (test_a, res_a))
print("X %s => Y %s" % (test_b, res_b))
———————— output ————————
X [0.1, 0.33] => Y [ 0. 1.]
X [4.0, 4.5] => Y [ 1. 0.]
[See more examples here](https://github.com/becxer/pytrain/tree/master/examples)
## How to contribute
Fork this repository, and write your algorithm, pull request.
Don't forgot proper test code in test_pytrain.
Test code should be work successfully in below command.
$ python test.py
## Reference
- Machine Learning in Action by Peter Harrington (2013)
- Pattern Recognition by Ohilseok (2008)
- Machine Learning to Deep Learning by Deepcumen (2015)
- Pattern Recognition and Machine Learning by Christopher M. Bishop (2006)
- Sequential Minimal Optimization for SVM by John C.Platt (1998)