misc
This commit is contained in:
parent
f65627a505
commit
456c4019c4
@ -2,50 +2,131 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 13,
|
"execution_count": 1,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false
|
"collapsed": false
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"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": [
|
"source": [
|
||||||
"using Plots, DataFrames, OnlineStats\n",
|
"using Plots, DataFrames, OnlineStats, OnlineAI\n",
|
||||||
"gadfly(); default(size=(500,300))\n",
|
"gadfly(); default(size=(500,300))\n",
|
||||||
"df = readtable(joinpath(Pkg.dir(\"Plots\"), \"examples\", \"meetup\", \"winequality-white.csv\"), separator=';');"
|
"df = readtable(joinpath(Pkg.dir(\"Plots\"), \"examples\", \"meetup\", \"winequality-white.csv\"), separator=';');"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 11,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false
|
"collapsed": false
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"y = float(df[:quality] .> 6)\n",
|
"y = float(df[:quality] .> 6)\n",
|
||||||
"x = Array(df[:,1:11]);"
|
"x = Array(df[:,1:11])\n",
|
||||||
|
"n, p = size(x)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 15,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false
|
"collapsed": false
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"ProxGrad(η = 1.0)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 15,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"# logistic regression\n",
|
"# logistic regression\n",
|
||||||
"reg = OnlineStats.ProxGrad()\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"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -159,7 +159,6 @@ function replaceType(vec, val)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function replaceAliases!(d::Dict, aliases::Dict)
|
function replaceAliases!(d::Dict, aliases::Dict)
|
||||||
@show d aliases
|
|
||||||
for (k,v) in d
|
for (k,v) in d
|
||||||
if haskey(aliases, k)
|
if haskey(aliases, k)
|
||||||
d[aliases[k]] = v
|
d[aliases[k]] = v
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user