Coder Social home page Coder Social logo

Comments (3)

joinr avatar joinr commented on July 18, 2024

Note:

I got the vector example (not using clatrix), 0 problems on my joinr/incanter 1.9.3-SNAPSHOT fork, and the deployed incanter 1.9.3 on clojars (a bit behind mine, but compatible):

user> (use 'incanter.core)
nil
user> (require 'incanter.stats)
nil
user> (incanter.stats/linear-model [1 2 3] [1 2 3])
{:y [1 2 3], :sse 9.466330862652142E-30, :msr 2.0, :design-matrix #vectorz/array [[1.0,1.0],[1.0,2.0],[1.0,3.0]], :mse 9.466330862652142E-30, :t-probs [0.769946543837384 1.3322676295501878E-15], :adj-r-square NaN, :df [1 1], :coef-var #vectorz/matrix [[2.2088105346188328E-29,-9.466330862652142E-30],
[-9.466330862652142E-30,4.733165431326071E-30]], :residuals (1.7763568394002505E-15 1.7763568394002505E-15 1.7763568394002505E-15), :ssr 2.0, :sst 2.0, :coefs (-1.7763568394002505E-15 1.0), :f-stat 2.1127510003803822E29, :r-square 1.0, :f-prob 0.0, :t-tests [-0.37796447300922725 4.5964671220192394E14], :x #vectorz/array [[1.0,1.0],[1.0,2.0],[1.0,3.0]], :std-errors #vectorz/vector [4.6997984367617645E-15,2.175583928816829E-15], :fitted (0.9999999999999982 1.9999999999999982 2.9999999999999982), :coefs-ci ((-6.14929580020137E-14 5.79402443232132E-14) (0.9999999999999724 1.0000000000000275))}

from incanter.

joinr avatar joinr commented on July 18, 2024

update:

you need to include clatrix 0.5.0 in your dependencies, with the following caveat (based off of what incanter does):

[clatrix "0.5.0" :exclusions [org.clojure/clojure net.mikera/core.matrix]]

That version works with 1.9.3 and your example. It basically says (don't use the clojure and core matrix deps that clatrix bundles, since they're old 1.7alpha and 0.36.1, incanter is using 1.8 and 0.52 respectively). Clatrix is a dev dependency for incanter.core, so it's not on the classpath by default.

from incanter.

joinr avatar joinr commented on July 18, 2024

A general approach that deviates from the example is to use the built-in incanter.core/matrix function.
This will delegate to the bundled vectorz library and works for n-dimensional vectors.

(def X (incanter.core/matrix [8.401 14.475 13.396 12.127 5.044
8.339 15.692 17.108 9.253 12.029]))
(def Y (incanter.core/matrix [-1.57 2.32 0.424 0.814 -2.3 0.01 1.954 2.296 -0.635 0.328]))

user> (incanter.stats/linear-model Y X )
{:y #vectorz/vector [-1.57,2.32,0.424,0.814,-2.3,0.01,1.954,2.296,-0.635,0.328], :sse 2.586225034528488, :msr 19.66839986547147, :design-matrix #vectorz/array [[1.0,8.401],[1.0,14.475],[1.0,13.396],[1.0,12.127],[1.0,5.044],[1.0,8.339],[1.0,15.692],[1.0,17.108],[1.0,9.253],[1.0,12.029]], :mse 0.323278129316061, :t-probs [1.3052188908235784E-4 5.2372232961728216E-5], :adj-r-square 0.8505862719364365, :df [1 8], :coef-var #vectorz/matrix [[0.3703451108456678,-0.029173625795248025],
[-0.029173625795248025,0.00251791978485535]], :residuals (-0.6873445559690559 0.8253111334125083 -0.6483716931997257 0.2383108767994172 -0.10342541689330798 0.9169220471357094 -0.017018801724573818 -0.22923670489146586 -0.08581465024744017 -0.20933223442208276), :ssr 19.66839986547147, :sst 22.25462489999996, :coefs (-4.170780164726611 0.3913968242704043), :f-stat 60.840490221477886, :r-square 0.8837893226172284, :f-prob 5.237223296161719E-5, :t-tests [-6.853524847485774 7.800031424390413], :x #vectorz/array [[1.0,8.401],[1.0,14.475],[1.0,13.396],[1.0,12.127],[1.0,5.044],[1.0,8.339],[1.0,15.692],[1.0,17.108],[1.0,9.253],[1.0,12.029]], :std-errors #vectorz/vector [0.6085598662791261,0.05017887787560967], :fitted (-0.8826554440309442 1.4946888665874916 1.0723716931997256 0.5756891232005827 -2.196574583106692 -0.9069220471357093 1.9710188017245738 2.5252367048914657 -0.5491853497525598 0.5373322344220828), :coefs-ci ((-5.574121732978319 -2.7674385964749026) (0.2756841243816959 0.5071095241591126))}

from incanter.

Related Issues (20)

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.