158 lines
5.2 KiB
Plaintext
158 lines
5.2 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"WARNING: Base.FloatingPoint is deprecated, use AbstractFloat instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Qwt/src/widgets.jl:5\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:13\n",
|
|
"WARNING: Base.Uint32 is deprecated, use UInt32 instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:13\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:13\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:18\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:18\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:21\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:21\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:45\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:120\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:191\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:274\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:336\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:338\n",
|
|
"WARNING: Base.String is deprecated, use AbstractString instead.\n",
|
|
" likely near /home/tom/.julia/v0.4/Glob/src/Glob.jl:346\n"
|
|
]
|
|
},
|
|
{
|
|
"ename": "LoadError",
|
|
"evalue": "LoadError: LoadError: LoadError: ArgumentError: Calendar not found in path\nwhile loading /home/tom/.julia/v0.4/CTechCommon/src/CTechCommon.jl, in expression starting on line 9\nwhile loading /home/tom/.julia/v0.4/OnlineAI/src/OnlineAI.jl, in expression starting on line 9\nwhile loading In[1], in expression starting on line 1",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"LoadError: LoadError: LoadError: ArgumentError: Calendar not found in path\nwhile loading /home/tom/.julia/v0.4/CTechCommon/src/CTechCommon.jl, in expression starting on line 9\nwhile loading /home/tom/.julia/v0.4/OnlineAI/src/OnlineAI.jl, in expression starting on line 9\nwhile loading In[1], in expression starting on line 1",
|
|
"",
|
|
" in require at ./loading.jl:233",
|
|
" in include at ./boot.jl:261",
|
|
" in include_from_node1 at ./loading.jl:304",
|
|
" in require at ./loading.jl:243",
|
|
" in include at ./boot.jl:261",
|
|
" in include_from_node1 at ./loading.jl:304",
|
|
" in require at ./loading.jl:243"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"using Plots, DataFrames, OnlineStats, OnlineAI\n",
|
|
"gadfly(); default(size=(500,300))\n",
|
|
"df = readtable(joinpath(Pkg.dir(\"Plots\"), \"examples\", \"meetup\", \"winequality-white.csv\"), separator=';');"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"y = float(df[:quality] .> 6)\n",
|
|
"x = Array(df[:,1:11])\n",
|
|
"n, p = size(x)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# logistic regression\n",
|
|
"reg = StochasticModel(x, y; model=LogisticRegression())"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"yhat = predict(reg, x)\n",
|
|
"scatter(yhat, y, xlab=\"Estimate\", ylab=\"Actual\", title=\"Logistic Regression\", smooth=.95, alpha=0.2, w=0, nbins=50)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"for i in 1:10000\n",
|
|
" row = sample(1:n)\n",
|
|
" update!(reg, vec(x[row,:]), y[row])\n",
|
|
"end\n",
|
|
"reg"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"y"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Julia 0.4.0",
|
|
"language": "julia",
|
|
"name": "julia-0.4"
|
|
},
|
|
"language_info": {
|
|
"file_extension": ".jl",
|
|
"mimetype": "application/julia",
|
|
"name": "julia",
|
|
"version": "0.4.0"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 0
|
|
}
|