Skip to content

Commit

Permalink
Merge pull request #229 from shrit/organize
Browse files Browse the repository at this point in the history
Organize
  • Loading branch information
shrit authored Jun 26, 2024
2 parents 728c1c8 + 59ae675 commit 78ddf19
Show file tree
Hide file tree
Showing 136 changed files with 1,286 additions and 1,549 deletions.
16 changes: 5 additions & 11 deletions .ci/linux-steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,20 @@ steps:
# Download datasets.
- script: |
python -m pip install tqdm requests
cd tools/
cd scripts/
./download_data_set.py
cd ../
ls data/
displayName: "Download datasets"

# Now build the examples.
# Now build the examples, only c++.
- script: |
for f in */Makefile; do
for f in cpp/*/*/*; do
dir=`dirname $f`;
# TODO: the dataset cannot be loaded.
if [ "$dir" == "mnist_vae_cnn" ];
then
continue;
fi
# TODO: the dataset cannot be loaded.
if [ "$dir" == "spam" ];
if [ "$dir" == "c++/neural_networks/mnist_vae_cnn" ];
then
continue;
fi
Expand All @@ -102,7 +96,7 @@ steps:
else
echo "Example succeeded; ${PIPESTATUS[0]}, ${PIPESTATUS[1]}";
fi
cd ../;
cd ../../../;
done
# Print any failures.
Expand Down
16 changes: 5 additions & 11 deletions .ci/macos-steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,22 @@ steps:
# Download datasets.
- script: |
python -m pip install tqdm requests
cd tools/
cd scripts/
./download_data_set.py
cd ../
ls data/
displayName: "Download datasets"

# Now build the examples.
# Now build the examples, only c++.
- script: |
for f in */Makefile; do
for f in cpp/*/*/*; do
dir=`dirname $f`;
# Remove the -fopenmp flag from the Makefile.
sed -i '' 's/ -fopenmp//' $f;
# TODO: the dataset cannot be loaded.
if [ "$dir" == "mnist_vae_cnn" ];
then
continue;
fi
# TODO: the dataset cannot be loaded.
if [ "$dir" == "spam" ];
if [ "$dir" == "c++/neural_networks/mnist_vae_cnn" ];
then
continue;
fi
Expand All @@ -108,7 +102,7 @@ steps:
else
echo "Example succeeded; ${PIPESTATUS[0]}, ${PIPESTATUS[1]}";
fi
cd ../;
cd ../../../;
done
# Print any failures.
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ cmake-build-*
*.so
data
plots
*__pycache__*
mnist_*
nn_*
cifar_*
covertype-rf
dominant_colors
pima_indians_diabetes
*__pycache__*
88 changes: 31 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
The mlpack **examples** repository contains simple example usages of mlpack.
You can take the code here and adapt it into your application, or compile it and
see what it does and play with it.

Each of the examples are meant to be as simple as possible, and they are
extensively documented.
see what it does and play with it. Each of the examples are meant to be as
simple as possible, and they are extensively documented.

All the notebooks in this repository can be easily run on
https://lab.mlpack.org/.

mlpack is a C++ library that provides machine learning support, but it also
provides bindings to other languages, including Python and Julia, and it also
provides command-line programs, see the [main mlpack
repository](https://github.com/mlpack/mlpack) and [mlpack
website](https://www.mlpack.org/) for more information on how to install mlpack.

### 0. Contents

1. [Overview](#1-overview)
2. [Building the examples and usage](#2-Building-the-examples-and-usage)
3. [List of examples](#3-List-of-examples)
4. [Datasets](#4-datasets)
3. [Datasets](#3-datasets)

### 1. Overview

Expand All @@ -23,73 +26,44 @@ for your machine learning task, this repository would definitely be a good place
to look, along with the [mlpack
documentation](https://www.mlpack.org/docs.html).

mlpack is a C++ library that provides machine learning support, but it also
provides bindings to other languages, including Python and Julia, and it also
provides command-line programs.
Therefore, this repository contains examples that are using common datasets.
This repository is organized per language and per method that is used.

Therefore, this repository contains examples not just in C++ but also in other
languages. C++ mlpack usage examples are contained in the `c++/` directory;
Python examples in the `python/` directory, command-line examples in the
`command-line/` directory, and so forth.
* `cpp/`: various mlpack C++ examples showing different machine learning
algorithms.
* `jupyter_notebook/`: mlpack examples C++ or Python written in jupyter
notebook format.
* `embedded/`: directory contains mlpack C++ examples with more focus on
embedded system in the case of compilation and optimized binary and sensor
input.
* `cli/` directory contains mlpack methods executed directly from the terminal
command line, suitable if you have a ready to use dataset and you do not want
to jump to the code.

### 2. Building the examples and usage

In order to keep this repository as simple as possible, there is no build
system, and all examples are minimal. For the C++ examples, there is a Makefile
in each example's directory; if you have mlpack installed on your system,
running `make` should work fine. Some other examples may also use other
running `make` should work fine. Rarely, some other examples may also use other
libraries, and the Makefile expects those dependencies to also be available.
See the README in each directory for more information, and see the [main mlpack
repository](https://github.com/mlpack/mlpack) and [mlpack
website](https://www.mlpack.org/) for more information on how to install mlpack.

For Python examples and other-language examples, it's expected that you have
mlpack and its dependencies installed.
See the README in each directory for more information, For Python examples and
other-language examples, it's expected that you have mlpack and its
dependencies installed.

Each example should be easily runnable and should perform a simple machine
learning task on a dataset. You might need to download the dataset first---so
be sure to check any README for the example.

### 3. List of examples

Below is a list of examples available in this repository along with a quick
description (just a little bit more than the title):

- `lstm_electricity_consumption`: use an LSTM-based recurrent neural network to
predict electricity consumption

- `lstm_stock_prediction`: predict Google's historical stock price (daily high
_and_ low) using an LSTM-based recurrent neural network

- `spam`: predict whether a mobile phone text message in Indonesian is spam
or not using logistic regression

- `mnist_batch_norm`: use batch normalization in a simple feedforward neural
network to recognize the MNIST digits

- `mnist_cnn`: use a convolutional neural network (CNN) similar to LeNet-5 to
recognize the MNIST digits

- `mnist_simple`: use a very simple three-layer feedforward neural network with
dropout to recognize the MNIST digits

- `mnist_vae_cnn`: use a variational autoencoder with convolutional neural
networks in the encoder and reparametrization networks to recognize the MNIST
digits

- `neural_network_regression`: use neural network to do regression on Body fat
dataset

- `q_learning`: train a simple deep Q-network agent on CartPole environment

### 4. Datasets
### 3. Datasets

All the required dataset needed by the examples can be downloaded using the
provided script in the `tools` directory. You will have to execute
`download_data_set.py` from the `tools/` directory and it will download and
extract all the necessary dataset in order for examples to work perfectly:
provided script in the `scripts` directory. You will have to execute
`download_data_set.py` from the `scripts/` directory and it will download and
extract all the necessary datasets inside the `data/` directory in order for
examples to work perfectly:

```sh
cd tools/
cd scripts/
./download_data_set.py
```
8 changes: 0 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ environment:
# Architecture: x86_amd64
# VCPREFIX:'C:\Program Files (x86)\Microsoft Visual Studio 14.0'
# VCVARS: 'VC\vcvarsall.bat'
# BOOST_ROOT: C:\Libraries\boost_1_69_0
# BOOST_LIBRARYDIR: C:\Libraries\boost_1_69_0\lib64-msvc-14.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
VSVER: Visual Studio 15 2017 Win64
VCPREFIX: 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community'
VCVARS: 'VC/Auxiliary/Build/vcvars64.bat'
BOOST_ROOT: C:\Libraries\boost_1_69_0
BOOST_LIBRARYDIR: C:\Libraries\boost_1_69_0\lib64-msvc-14.0

configuration: Release

Expand All @@ -36,8 +32,6 @@ build_script:
cmake -G "%VSVER%"
-DDEBUG=OFF -DPROFILE=OFF
-DUSE_OPENMP=OFF
-DBOOST_ROOT=%BOOST_ROOT%
-DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR%
-DBUILD_CLI_EXECUTABLES=OFF
-DBUILD_JULIA_BINDINGS=OFF
-DBUILD_PYTHON_BINDINGS=OFF
Expand All @@ -55,8 +49,6 @@ build_script:
# - >
# cmake -G "%VSVER%"
# -DDEBUG=OFF -DPROFILE=OFF
# -DBOOST_ROOT=%BOOST_ROOT%
# -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR%
# -DMLPACK_LIBRARY:FILEPATH=%MLPACK_LIB%
# -DMLPACK_INCLUDE_DIR:PATH=%MLPACK_INCLUDE%
# -DBUILD_PYTHON_BINDINGS=OFF -DCMAKE_BUILD_TYPE=Release
Expand Down
Loading

0 comments on commit 78ddf19

Please sign in to comment.