Giter Site home page Giter Site logo

lightml.jl's Introduction

LightML.jl

Build Status Build status Coverage Status

About

LightML.jl is a collection of reimplementation of general machine learning algorithm in Julia.

The purpose of this project is purely self-educational.

Why?

This project is targeting people who want to learn internals of ml algorithms or implement them from scratch.

The code is much easier to follow than the optimized libraries and easier to play with.

All algorithms are implemented in Julia.

You should access test function of every implementation for its usage in detail. Every model is actually constructed in a similar manner.

Installation

First make sure you have correct python dependency. You can use the Conda Julia package to install more Python packages, and import Conda to print the Conda.PYTHONDIR directory where python was installed. On GNU/Linux systems, PyCall will default to using the python program (if any) in your PATH.

The advantage of a Conda-based configuration is particularly compelling if you are installing PyCall in order to use packages like PyPlot.jl or SymPy.jl, as these can then automatically install their Python dependencies.

ENV["PYTHON"]=""
Pkg.add("Conda")
using Conda
Conda.add("python==2.7.13")
Conda.add("matplotlib")
Conda.add("scikit-learn")
Pkg.add("PyCall")
Pkg.build("PyCall")

or you can simply

Pkg.build("LightML")

It's actually same with the procedure above.

Then every dependency should be configured, you can simply run command below to install the package.

Pkg.clone("https://github.com/memoiry/LightML.jl")

Running Implementations

Let's first try the overall functionality test.

using LightML
test_LSC()

Figure 1: Smiley, spirals, shapes and cassini Datasets using LSC(large scale spectral clustering)

Running Demo

using LightML
demo()

Figure 2: The Digit Dataset using Demo algorithms

Current Implementations

Supervised Learning:

Unsupervised Learning:

Test Example available

  • test_ClassificationTree()
  • test_RegressionTree()
  • test_label_propagation()
  • test_LDA()
  • test_naive()
  • test_NeuralNetwork()
  • test_svm()
  • test_kmeans_random()
  • test_PCA()
  • test_Adaboost()
  • test_BoostingTree()
  • test_spec_cluster()
  • test_LogisticRegression()
  • test_LinearRegression()
  • test_kneast_regression()
  • test_kneast_classification()
  • test_LSC()
  • test_GaussianMixture() (Fixing)
  • test_GDA() (Fixing)
  • test_HMM() (Fixing)
  • test_xgboost (Fixing)

Contribution

Please examine the todo list for contribution detials.

Any Pull request is welcome.

Selected Examples

LinearRegression

using LightML
test_LinearRegression()

Figure 3: The regression Dataset using LinearRegression

Adaboost

test_Adaboost()

Figure 4: The classification Dataset using Adaboost

SVM

test_svm()

Figure 5: The classification Dataset using LinearRegression

Classification Tree

test_ClassificationTree()

Figure 6: The digit Dataset using Classification Tree

kmeans

test_kmeans_random()

Figure 7: The blobs Dataset using k-means

LDA

test_LDA()

Figure 8: The classification Dataset using LDA

PCA

test_PCA()

Figure 9: The Digit Dataset using PCA

lightml.jl's People

Contributors

memoiry avatar szcf-weiya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lightml.jl's Issues

test_LinearRegression ERROR

julia> test_LinearRegression()
LinearRegression!200
ERROR: MethodError: no method matching add_reg(::ForwardDiff.Dual{2,Float64}, ::Array{ForwardDiff.Dual{2,Float64},1})
Closest candidates are:
  add_reg(::Any, ::Any, ::Any) at /home/rick/.julia/v0.5/LightML/src/supervised_learning/baseRegression.jl:146
 in vector_mode_gradient(::LightML.#cost_linear, ::Array{Float64,1}, ::ForwardDiff.GradientConfig{2,Float64,Array{ForwardDiff.Dual{2,Float64},1}}) at /home/rick/.julia/v0.5/ForwardDiff/src/gradient.jl:60
 in gradient(::LightML.#cost_linear, ::Array{Float64,1}, ::ForwardDiff.GradientConfig{2,Float64,Array{ForwardDiff.Dual{2,Float64},1}}) at /home/rick/.julia/v0.5/ForwardDiff/src/gradient.jl:7
 in train!(::LightML.LinearRegression, ::Array{Float64,2}, ::Array{Float64,1}) at /home/rick/.julia/v0.5/LightML/src/supervised_learning/baseRegression.jl:79
 in #test_LinearRegression#5(::String, ::Function) at /home/rick/.julia/v0.5/LightML/src/supervised_learning/baseRegression.jl:159
 in test_LinearRegression() at /home/rick/.julia/v0.5/LightML/src/supervised_learning/baseRegression.jl:157

I like this library but it needs some modifications to be good.

  1. test functions should be in the test folder.
  2. perhaps using pycall to test against scikit-learn is a better option, although some of the stuff there is buggy as well.
  3. I would implement a core concept module and have other modules extend functions from this module.

TypeError: in Type{...} expression, expected UnionAll, got typeof(Base.Nullable)

julia 0.7 , Follow the reference method.
but input using LightML.There is an error:

julia> using LightML
[ Info: Precompiling LightML [21c72615-c80e-5f28-8897-21b7f06a9402]
┌ Warning: Deprecated syntax try without catch or finally at /root/.julia/packages/Gadfly/ojGNo/src/Gadfly.jl:971.
└ @ ~/.julia/packages/Gadfly/ojGNo/src/Gadfly.jl:971
┌ Warning: Deprecated syntax try without catch or finally at /root/.julia/packages/Gadfly/ojGNo/src/Gadfly.jl:980.
└ @ ~/.julia/packages/Gadfly/ojGNo/src/Gadfly.jl:980
┌ Warning: Deprecated syntax try without catch or finally at /root/.julia/packages/Compose/y7cU7/src/Compose.jl:207.
└ @ ~/.julia/packages/Compose/y7cU7/src/Compose.jl:207
WARNING: importing deprecated binding Base.Nullable into Compose.
ERROR: LoadError: LoadError: TypeError: in Type{...} expression, expected UnionAll, got typeof(Base.Nullable)
Stacktrace:
[1] top-level scope at none:0
[2] include at ./boot.jl:317 [inlined]
[3] include_relative(::Module, ::String) at ./loading.jl:1038
[4] include at ./sysimg.jl:29 [inlined]
[5] include(::String) at /root/.julia/packages/Compose/y7cU7/src/Compose.jl:3
[6] top-level scope at none:0
[7] include at ./boot.jl:317 [inlined]
[8] include_relative(::Module, ::String) at ./loading.jl:1038
[9] include(::Module, ::String) at ./sysimg.jl:29
[10] top-level scope at none:2
[11] eval at ./boot.jl:319 [inlined]
[12] eval(::Expr) at ./client.jl:399
[13] top-level scope at ./none:3
in expression starting at /root/.julia/packages/Compose/y7cU7/src/measure.jl:133
in expression starting at /root/.julia/packages/Compose/y7cU7/src/Compose.jl:69
ERROR: LoadError: Failed to precompile Compose [a81c6b42-2e10-5240-aca2-a61377ecd94b] to /root/.julia/compiled/v0.7/Compose/sbiEw.ji.
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] macro expansion at ./logging.jl:313 [inlined]
[3] compilecache(::Base.PkgId, ::String) at ./loading.jl:1185
[4] _require(::Base.PkgId) at ./logging.jl:311
[5] require(::Base.PkgId) at ./loading.jl:852
[6] macro expansion at ./logging.jl:311 [inlined]
[7] require(::Module, ::Symbol) at ./loading.jl:834
[8] include at ./boot.jl:317 [inlined]
[9] include_relative(::Module, ::String) at ./loading.jl:1038
[10] include(::Module, ::String) at ./sysimg.jl:29
[11] top-level scope at none:2
[12] eval at ./boot.jl:319 [inlined]
[13] eval(::Expr) at ./client.jl:399
[14] top-level scope at ./none:3
in expression starting at /root/.julia/packages/Gadfly/ojGNo/src/Gadfly.jl:7
ERROR: LoadError: Failed to precompile Gadfly [c91e804a-d5a3-530f-b6f0-dfbca275c004] to /root/.julia/compiled/v0.7/Gadfly/DvECm.ji.
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] macro expansion at ./logging.jl:313 [inlined]
[3] compilecache(::Base.PkgId, ::String) at ./loading.jl:1185
[4] _require(::Base.PkgId) at ./logging.jl:311
[5] require(::Base.PkgId) at ./loading.jl:852
[6] macro expansion at ./logging.jl:311 [inlined]
[7] require(::Module, ::Symbol) at ./loading.jl:834
[8] include at ./boot.jl:317 [inlined]
[9] include_relative(::Module, ::String) at ./loading.jl:1038
[10] include(::Module, ::String) at ./sysimg.jl:29
[11] top-level scope at none:2
[12] eval at ./boot.jl:319 [inlined]
[13] eval(::Expr) at ./client.jl:399
[14] top-level scope at ./none:3
in expression starting at /root/.julia/dev/LightML/src/LightML.jl:4
ERROR: Failed to precompile LightML [21c72615-c80e-5f28-8897-21b7f06a9402] to /root/.julia/compiled/v0.7/LightML/hSDel.ji.
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] macro expansion at ./logging.jl:313 [inlined]
[3] compilecache(::Base.PkgId, ::String) at ./loading.jl:1185
[4] _require(::Base.PkgId) at ./logging.jl:311
[5] require(::Base.PkgId) at ./loading.jl:852
[6] macro expansion at ./logging.jl:311 [inlined]
[7] require(::Module, ::Symbol) at ./loading.jl:834

How can I do? Thank you!!

Document or fetch all prerequisites

It's expected that there are some prerequisites, and it would be nice if there were no errors when first trying to use LightML.jl.

My Pkg.clone(... completed without error, but the first using LightML failed after building several packages and then couldn't locate sklearn.

 $ ./julia 
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.1 (2017-03-05 13:25 UTC)
 _/ |\__'_|_|_|\__'_|  |  
|__/                   |  x86_64-redhat-linux

julia> Pkg.clone("https://github.com/memoiry/LightML.jl")
INFO: Cloning LightML from https://github.com/memoiry/LightML.jl
INFO: Computing changes...
INFO: Cloning cache of AxisAlgorithms from https://github.com/timholy/AxisAlgorithms.jl.git
INFO: Cloning cache of Clustering from https://github.com/JuliaStats/Clustering.jl.git
INFO: Cloning cache of Compose from https://github.com/GiovineItalia/Compose.jl.git
INFO: Cloning cache of Conda from https://github.com/JuliaPy/Conda.jl.git
INFO: Cloning cache of Contour from https://github.com/tlycken/Contour.jl.git
INFO: Cloning cache of DiffBase from https://github.com/JuliaDiff/DiffBase.jl.git
INFO: Cloning cache of Distances from https://github.com/JuliaStats/Distances.jl.git
INFO: Cloning cache of DualNumbers from https://github.com/JuliaDiff/DualNumbers.jl.git
INFO: Cloning cache of FixedSizeArrays from https://github.com/SimonDanisch/FixedSizeArrays.jl.git
INFO: Cloning cache of ForwardDiff from https://github.com/JuliaDiff/ForwardDiff.jl.git
INFO: Cloning cache of Gadfly from https://github.com/GiovineItalia/Gadfly.jl.git
INFO: Cloning cache of Hexagons from https://github.com/GiovineItalia/Hexagons.jl.git
INFO: Cloning cache of Interpolations from https://github.com/JuliaMath/Interpolations.jl.git
INFO: Cloning cache of Iterators from https://github.com/JuliaCollections/Iterators.jl.git
INFO: Cloning cache of KernelDensity from https://github.com/JuliaStats/KernelDensity.jl.git
INFO: Cloning cache of LaTeXStrings from https://github.com/stevengj/LaTeXStrings.jl.git
INFO: Cloning cache of LineSearches from https://github.com/JuliaNLSolvers/LineSearches.jl.git
INFO: Cloning cache of Loess from https://github.com/JuliaStats/Loess.jl.git
INFO: Cloning cache of Measures from https://github.com/JuliaGraphics/Measures.jl.git
INFO: Cloning cache of NaNMath from https://github.com/mlubin/NaNMath.jl.git
INFO: Cloning cache of NearestNeighbors from https://github.com/KristofferC/NearestNeighbors.jl.git
INFO: Cloning cache of Optim from https://github.com/JuliaNLSolvers/Optim.jl.git
INFO: Cloning cache of PositiveFactorizations from https://github.com/timholy/PositiveFactorizations.jl.git
INFO: Cloning cache of PyCall from https://github.com/JuliaPy/PyCall.jl.git
INFO: Cloning cache of PyPlot from https://github.com/JuliaPy/PyPlot.jl.git
INFO: Cloning cache of Ratios from https://github.com/timholy/Ratios.jl.git
INFO: Cloning cache of Showoff from https://github.com/JuliaGraphics/Showoff.jl.git
INFO: Cloning cache of StaticArrays from https://github.com/JuliaArrays/StaticArrays.jl.git
INFO: Cloning cache of WoodburyMatrices from https://github.com/timholy/WoodburyMatrices.jl.git
INFO: Installing AxisAlgorithms v0.1.6
INFO: Installing Clustering v0.7.0
INFO: Installing ColorTypes v0.3.5
INFO: Installing Colors v0.7.3
INFO: Installing Compose v0.4.5
INFO: Installing Conda v0.5.2
INFO: Installing Contour v0.2.0
INFO: Installing DiffBase v0.1.0
INFO: Installing Distances v0.4.1
INFO: Installing DualNumbers v0.3.0
INFO: Installing FixedPointNumbers v0.3.5
INFO: Installing FixedSizeArrays v0.2.5
INFO: Installing ForwardDiff v0.4.1
INFO: Installing Gadfly v0.6.0
INFO: Installing Hexagons v0.0.4
INFO: Installing Hiccup v0.1.1
INFO: Installing Interpolations v0.3.8
INFO: Installing Iterators v0.3.0
INFO: Installing JSON v0.8.3
INFO: Installing Juno v0.2.7
INFO: Installing KernelDensity v0.3.2
INFO: Installing LaTeXStrings v0.2.0
INFO: Installing LineSearches v0.1.5
INFO: Installing Loess v0.1.0
INFO: Installing MacroTools v0.3.6
INFO: Installing Measures v0.0.3
INFO: Installing Media v0.2.5
INFO: Installing NaNMath v0.2.4
INFO: Installing NearestNeighbors v0.2.0
INFO: Installing Optim v0.7.8
INFO: Installing PositiveFactorizations v0.0.4
INFO: Installing PyCall v1.11.0
INFO: Installing PyPlot v2.3.1
INFO: Installing Ratios v0.0.4
INFO: Installing Showoff v0.0.7
INFO: Installing StaticArrays v0.3.0
INFO: Installing WoodburyMatrices v0.2.2
INFO: Building Conda
INFO: Building Rmath
INFO: Building PyCall
INFO: PyCall is using python (Python 2.7.13) at /usr/bin/python, libpython = /usr/lib64/libpython2.7
INFO: /home/rick/.julia/v0.5/PyCall/deps/deps.jl has been updated
INFO: /home/rick/.julia/v0.5/PyCall/deps/PYTHON has been updated

julia> using LightML
INFO: Precompiling module Gadfly.
INFO: Precompiling module PyCall.
INFO: Precompiling module PyPlot.
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
INFO: Precompiling module Clustering.
ERROR: LoadError: PyError (:PyImport_ImportModule) <type 'exceptions.ImportError'>
ImportError('No module named sklearn.datasets',)

 in pyerr_check at /home/rick/.julia/v0.5/PyCall/src/exception.jl:56 [inlined]
 in pyerr_check at /home/rick/.julia/v0.5/PyCall/src/exception.jl:61 [inlined]
 in macro expansion at /home/rick/.julia/v0.5/PyCall/src/exception.jl:81 [inlined]
 in pyimport(::String) at /home/rick/.julia/v0.5/PyCall/src/PyCall.jl:392
 in include_from_node1(::String) at ./loading.jl:488
 in eval(::Module, ::Any) at ./boot.jl:234
 in require(::Symbol) at ./loading.jl:415
while loading /home/rick/.julia/v0.5/LightML/src/LightML.jl, in expression starting on line 432

julia> 

convert to a module

@memoiry, thanks for doing this. I was wondering if there are any plans to wrap this code such that it could be used as a module? I can assist if that is the intent.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.