Report-1/prep/prep.jl
2022-02-14 00:35:54 -07:00

69 lines
1.5 KiB
Julia

using DataFrames
using LinearAlgebra
using CSV
using DataFramesMeta
# using Plots
# using StatsPlots
using PlotlyJS
begin
df = CSV.read("compiled.csv", DataFrame)
df.box = df.bb_length .* df.bb_width .* df.bb_height
@eachrow! df begin
@newcol :Ix::Vector{Float64}
@newcol :Iy::Vector{Float64}
@newcol :Iz::Vector{Float64}
@newcol :Ibar::Vector{Float64}
I = [
:Ixx :Ixy :Ixz
:Iyx :Iyy :Iyz
:Izx :Izy :Izz
]
(:Ix, :Iy, :Iz) = eigvals(I)
:Ibar = :Ix^2 + :Iy^2 + :Iz^2 |> sqrt
end
# Convert material to scalar
begin
kv = Dict(reverse.(enumerate(Set(df.material_name))))
mats = [] |> Vector{Int}
for material in df.material_name
push!(mats, kv[material])
end
df.material_index = mats
end
# Remove columns not needed for analysis
# df = df[!, [:mass, :volume, :density, :area, :bb_volume, :Ibar, :material_index]]
# Remove outliers
df = df[df.box.<1e6, :]
df = df[df.mass.<1000, :]
end
# @df df cornerplot(cols(1:7), compact = true)
# plot(df.mass)
# histogram(df.mass)
# scatter(df.mass, df.Ibar)
features = [:mass, :volume, :density, :area, :box, :Ibar]
plot(df, dimensions = features, kind = "splom", Layout(title = "Raw Data"))
corner(df)
CSV.write("prepped.csv", df)
df = dataset(DataFrame, "iris")
features = [:sepal_width, :sepal_length, :petal_width, :petal_length]
plot(df, dimensions = features, color = :species, kind = "splom")