
# pykitml (Python Kit for Machine Learning)
Machine Learning library written in Python and NumPy.
### Installation
```
python3 -m pip install pykitml
```
### Documentation
https://pykitml.readthedocs.io/en/latest/
# Demo (MNIST)
### Training
``` python
import os.path
import numpy as np
import pykitml as pk
from pykitml.datasets import mnist
# Download dataset
if(not os.path.exists('mnist.pkl')): mnist.get()
# Load dataset
training_data, training_targets, testing_data, testing_targets = mnist.load()
# Create a new neural network
digit_classifier = pk.NeuralNetwork([784, 100, 10])
# Train it
digit_classifier.train(
training_data=training_data,
targets=training_targets,
batch_size=50,
epochs=1200,
optimizer=pk.Adam(learning_rate=0.012, decay_rate=0.95),
testing_data=testing_data,
testing_targets=testing_targets,
testing_freq=30,
decay_freq=15
)
# Save it
pk.save(digit_classifier, 'digit_classifier_network.pkl')
# Show performance
accuracy = digit_classifier.accuracy(training_data, training_targets)
print('Train Accuracy:', accuracy)
accuracy = digit_classifier.accuracy(testing_data, testing_targets)
print('Test Accuracy:', accuracy)
# Plot performance graph
digit_classifier.plot_performance()
# Show confusion matrix
digit_classifier.confusion_matrix(training_data, training_targets)
```
### Trying the model
```python
import random
import numpy as np
import matplotlib.pyplot as plt
import pykitml as pk
from pykitml.datasets import mnist
# Load dataset
training_data, training_targets, testing_data, testing_targets = mnist.load()
# Load the trained network
digit_classifier = pk.load('digit_classifier_network.pkl')
# Pick a random example from testing data
index = random.randint(0, 9999)
# Show the test data and the label
plt.imshow(training_data[index].reshape(28, 28))
plt.show()
print('Label: ', training_targets[index])
# Show prediction
digit_classifier.feed(training_data[index])
model_output = digit_classifier.get_output_onehot()
print('Predicted: ', model_output)
```
### Performance Graph

### Confusion Matrix

Raw data
{
"_id": null,
"home_page": "https://github.com/RainingComputers/pykitml",
"name": "pykitml",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "pykitml",
"author": "RainingComputers",
"author_email": "vishnu.vish.shankar@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/51/b4/b6f4206ef1948458a76ed7476c86a565c6dba6cc76d82a4da0fa767f7962/pykitml-0.1.3.tar.gz",
"platform": null,
"description": "\n\n# pykitml (Python Kit for Machine Learning)\nMachine Learning library written in Python and NumPy.\n\n### Installation\n\n```\npython3 -m pip install pykitml\n```\n\n### Documentation\n\nhttps://pykitml.readthedocs.io/en/latest/\n\n# Demo (MNIST)\n### Training\n``` python\nimport os.path\n\nimport numpy as np\nimport pykitml as pk\nfrom pykitml.datasets import mnist\n \n# Download dataset\nif(not os.path.exists('mnist.pkl')): mnist.get()\n\n# Load dataset\ntraining_data, training_targets, testing_data, testing_targets = mnist.load()\n \n# Create a new neural network\ndigit_classifier = pk.NeuralNetwork([784, 100, 10])\n \n# Train it\ndigit_classifier.train(\n training_data=training_data,\n targets=training_targets, \n batch_size=50, \n epochs=1200, \n optimizer=pk.Adam(learning_rate=0.012, decay_rate=0.95), \n testing_data=testing_data, \n testing_targets=testing_targets,\n testing_freq=30,\n decay_freq=15\n)\n \n# Save it\npk.save(digit_classifier, 'digit_classifier_network.pkl')\n\n# Show performance\naccuracy = digit_classifier.accuracy(training_data, training_targets)\nprint('Train Accuracy:', accuracy) \naccuracy = digit_classifier.accuracy(testing_data, testing_targets)\nprint('Test Accuracy:', accuracy)\n \n# Plot performance graph\ndigit_classifier.plot_performance()\n\n# Show confusion matrix\ndigit_classifier.confusion_matrix(training_data, training_targets)\n```\n\n### Trying the model\n```python\nimport random\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport pykitml as pk\nfrom pykitml.datasets import mnist\n\n# Load dataset\ntraining_data, training_targets, testing_data, testing_targets = mnist.load()\n\n# Load the trained network\ndigit_classifier = pk.load('digit_classifier_network.pkl')\n\n# Pick a random example from testing data\nindex = random.randint(0, 9999)\n\n# Show the test data and the label\nplt.imshow(training_data[index].reshape(28, 28))\nplt.show()\nprint('Label: ', training_targets[index])\n\n# Show prediction\ndigit_classifier.feed(training_data[index])\nmodel_output = digit_classifier.get_output_onehot()\nprint('Predicted: ', model_output)\n```\n\n### Performance Graph\n\n\n\n### Confusion Matrix\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Machine Learning library written in Python and NumPy.",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://github.com/RainingComputers/pykitml"
},
"split_keywords": [
"pykitml"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "299d8745e5074bbe8e95d5807d7ec3727f4c811c625206d8384cbcfb67b5b43a",
"md5": "20311da5b869649f550e9b0d434fb2b2",
"sha256": "76c9beffc244b60430ebf003262a6182e7c3b5fab2866b6a5a6cfd46fbf1cd77"
},
"downloads": -1,
"filename": "pykitml-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "20311da5b869649f550e9b0d434fb2b2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 93888,
"upload_time": "2024-12-31T19:27:15",
"upload_time_iso_8601": "2024-12-31T19:27:15.194327Z",
"url": "https://files.pythonhosted.org/packages/29/9d/8745e5074bbe8e95d5807d7ec3727f4c811c625206d8384cbcfb67b5b43a/pykitml-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "51b4b6f4206ef1948458a76ed7476c86a565c6dba6cc76d82a4da0fa767f7962",
"md5": "13b73a7a03149b289b0389e603163447",
"sha256": "db00cf6d04273764be1b1d3b2e36a86ba6c1488f9d39858893a2e7ec0ac7c1bb"
},
"downloads": -1,
"filename": "pykitml-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "13b73a7a03149b289b0389e603163447",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 89509,
"upload_time": "2024-12-31T19:27:19",
"upload_time_iso_8601": "2024-12-31T19:27:19.052559Z",
"url": "https://files.pythonhosted.org/packages/51/b4/b6f4206ef1948458a76ed7476c86a565c6dba6cc76d82a4da0fa767f7962/pykitml-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-31 19:27:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "RainingComputers",
"github_project": "pykitml",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "numpy",
"specs": []
},
{
"name": "matplotlib",
"specs": []
},
{
"name": "tqdm",
"specs": []
},
{
"name": "graphviz",
"specs": []
},
{
"name": "sphinx-rtd-theme",
"specs": []
}
],
"lcname": "pykitml"
}