-
Notifications
You must be signed in to change notification settings - Fork 1
/
dataanalys.jl
81 lines (55 loc) · 1.48 KB
/
dataanalys.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using StatsPlots, CSV, DataFrames, DataFramesMeta, SQLite, GLM, Optim,
Dates, StatsBase, StatsFuns, Distributions, Turing,
MCMCChains, Zygote, Memoization, ReverseDiff, Revise
using Statistics
df = DataFrame(x=rand(100),y=rand(100),z=Date(2000,01,01) .+ Dates.Day.(rand(Int,100).% 100))
median(df.x)
mean(df.x)
summarystats(df.x)
describe(df.x)
CSV.write("testfile.csv",df)
df2 = CSV.File("testfile.csv")
df3 = CSV.read("testfile.csv",DataFrame)
p = @df df plot(:x,:y)
@df df plot!(:y,:x)
display(p)
p2 = @df df scatter(:z,:y)
@df df scatter!(:z,:x)
display(p2)
h1 = @df df histogram(:x)
@df df histogram!(:y)
display(h1)
d1 = @df df density(:x)
@df df density!(:y)
display(d1)
ols = lm(@formula(y~x),df)
display(ols)
@chain df begin
@subset :x .> .5
@subset :y .< .5
@orderby :x
@transform :p = 2 * :x
end
try
Base.Filesystem.rm("foo.db")
catch e
end
db = SQLite.DB("foo.db")
SQLite.load!(df,db,"foo")
df3 = DBInterface.execute(db,"select * from foo where x > ?", (.25,)) |> DataFrame
df4 = DBInterface.execute(db,"select * from foo") |> DataFrame
@model function foo(data)
n ~ Gamma(3,2)
foo ~ arraydist([Gamma(3,2) for i in 1:length(data)])
bar ~ MvNormal([0.0 for i in 1:length(data)],1.0)
baz ~ Normal(3.0,2.0)
end
Turing.setadbackend(:reversediff)
Turing.setrdcache(true)
Turing.emptyrdcache()
ch = sample(foo(collect(1:100)),NUTS(1000,.8),2000)
summarize(ch)
#Turing.setadbackend(:zygote)
#ch = sample(foo(collect(1:100)),NUTS(1000,.8),2000)
#summary(ch)
sleep(1)