Skip to content

Commit

Permalink
Merge 55a4cb2 into 973c4e1
Browse files Browse the repository at this point in the history
  • Loading branch information
glennmoy authored Feb 25, 2021
2 parents 973c4e1 + 55a4cb2 commit 9d3000f
Show file tree
Hide file tree
Showing 15 changed files with 326 additions and 326 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Transforms"
name = "FeatureTransforms"
uuid = "8fd68953-04b8-4117-ac19-158bf6de9782"
authors = ["Invenia Technical Computing Corporation"]
version = "0.1.1"
version = "0.1.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Transforms
# FeatureTransforms

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://invenia.github.io/Transforms.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://invenia.github.io/Transforms.jl/dev)
[![Build Status](https://travis-ci.com/invenia/Transforms.jl.svg?branch=master)](https://travis-ci.com/invenia/Transforms.jl)
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://invenia.github.io/FeatureTransforms.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://invenia.github.io/FeatureTransforms.jl/dev)
[![Build Status](https://travis-ci.com/invenia/FeatureTransforms.jl.svg?branch=master)](https://travis-ci.com/invenia/FeatureTransforms.jl)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)

Transforms.jl provides utilities for performing feature engineering in machine learning pipelines.
Transforms supports operations on `AbstractArrays` and [Tables](https://github.com/JuliaData/Tables.jl).
FeatureTransforms.jl provides utilities for performing feature engineering in machine learning pipelines.
FeatureTransforms supports operations on `AbstractArrays` and [Tables](https://github.com/JuliaData/Tables.jl).

## Installation
```julia
julia> using Pkg; Pkg.add("Transforms")
julia> using Pkg; Pkg.add("FeatureTransforms")
```

## Quickstart
Load in the dependencies and construct some toy data.
```julia
julia> using DataFrames, Transforms
julia> using DataFrames, FeatureTransforms

julia> df = DataFrame(:a=>[1, 2, 3, 4, 5], :b=>[5, 4, 3, 2, 1], :c=>[0, 1, 0, 1, 0])
5×3 DataFrame
Expand All @@ -36,11 +36,11 @@ Note that non-mutating transformations do not necessarily return the same type,
```julia
julia> p = Power(3);

julia> Transforms.apply(df, p; cols=[:a])
julia> FeatureTransforms.apply(df, p; cols=[:a])
1-element Array{Array{Int64,1},1}:
[1, 8, 27, 64, 125]

julia> Transforms.apply!(df, p; cols=[:a])
julia> FeatureTransforms.apply!(df, p; cols=[:a])
5×3 DataFrame
Row │ a b c
│ Int64 Int64 Int64
Expand All @@ -57,7 +57,7 @@ But users may append the output to their data if they so wish.
```julia
julia> lc = LinearCombination([1, -10]);

julia> Transforms.apply(df, lc; cols=[:b, :c])
julia> FeatureTransforms.apply(df, lc; cols=[:b, :c])
5-element Array{Int64,1}:
5
-6
Expand Down
2 changes: 1 addition & 1 deletion docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[Transforms]]
[[FeatureTransforms]]
path = ".."
uuid = "8fd68953-04b8-4117-ac19-158bf6de9782"
version = "0.1.0"
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Transforms = "8fd68953-04b8-4117-ac19-158bf6de9782"
FeatureTransforms = "8fd68953-04b8-4117-ac19-158bf6de9782"
12 changes: 6 additions & 6 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Transforms
using FeatureTransforms
using Documenter

makedocs(;
modules=[Transforms],
modules=[FeatureTransforms],
authors="Invenia Technical Computing Corporation",
repo="https://github.com/invenia/Transforms.jl/blob/{commit}{path}#L{line}",
sitename="Transforms.jl",
repo="https://github.com/invenia/FeatureTransforms.jl/blob/{commit}{path}#L{line}",
sitename="FeatureTransforms.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://invenia.github.io/Transforms.jl",
canonical="https://invenia.github.io/FeatureTransforms.jl",
assets=String[],
),
pages=[
Expand All @@ -19,7 +19,7 @@ makedocs(;
)

deploydocs(;
repo="github.com/invenia/Transforms.jl",
repo="github.com/invenia/FeatureTransforms.jl",
devbranch = "main",
push_preview = true,
)
6 changes: 3 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
```@meta
CurrentModule = Transforms
CurrentModule = FeatureTransforms
```

# Transforms
# FeatureTransforms

```@index
```

```@autodocs
Modules = [Transforms]
Modules = [FeatureTransforms]
```
2 changes: 1 addition & 1 deletion src/Transforms.jl → src/FeatureTransforms.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Transforms
module FeatureTransforms

using Dates: TimeType, Period, Day, hour
using Statistics: mean, std
Expand Down
2 changes: 1 addition & 1 deletion src/transformers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
Transform
Abstract supertype for all Transforms.
Abstract supertype for all feature Transforms.
"""
abstract type Transform end

Expand Down
70 changes: 35 additions & 35 deletions test/linear_combination.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
expected = [-1]

@testset "all inds" begin
@test Transforms.apply(x, lc) == expected
@test FeatureTransforms.apply(x, lc) == expected
@test lc(x) == expected
end

@testset "dims not supported" begin
@test_throws MethodError Transforms.apply(x, lc; dims=1)
@test_throws MethodError FeatureTransforms.apply(x, lc; dims=1)
end

@testset "dimension mismatch" begin
x = [1, 2, 3]
@test_throws DimensionMismatch Transforms.apply(x, lc)
@test_throws DimensionMismatch FeatureTransforms.apply(x, lc)
end

@testset "specified inds" begin
x = [1, 2, 3]
inds = [2, 3]
expected = [-1]

@test Transforms.apply(x, lc; inds=inds) == expected
@test FeatureTransforms.apply(x, lc; inds=inds) == expected
@test lc(x; inds=inds) == expected
end
end
Expand All @@ -36,44 +36,44 @@
expected = [0, 0, -2]

@testset "all inds" begin
@test Transforms.apply(M, lc) == expected
@test FeatureTransforms.apply(M, lc) == expected
@test lc(M) == expected
end

@testset "dims" begin
@testset "dims = :" begin
d = Colon()
@test_throws ArgumentError Transforms.apply(M, lc; dims=d)
@test_throws ArgumentError FeatureTransforms.apply(M, lc; dims=d)
end

@testset "dims = 1" begin
d = 1
@test Transforms.apply(M, lc; dims=d) == expected
@test FeatureTransforms.apply(M, lc; dims=d) == expected
@test lc(M; dims=d) == expected
end

@testset "dims = 2" begin
d = 2
# There are 3 rows so trying to apply along dim 2 without specifying inds
# won't work
@test_throws DimensionMismatch Transforms.apply(M, lc; dims=d)
@test_throws DimensionMismatch FeatureTransforms.apply(M, lc; dims=d)

@test Transforms.apply(M, lc; dims=d, inds=[2, 3]) == [-1, -3]
@test FeatureTransforms.apply(M, lc; dims=d, inds=[2, 3]) == [-1, -3]
@test lc(M; dims=d, inds=[1, 3]) == [-2, -4]
end
end

@testset "dimension mismatch" begin
M = [1 1 1; 2 2 2]
@test_throws DimensionMismatch Transforms.apply(M, lc)
@test_throws DimensionMismatch FeatureTransforms.apply(M, lc)
end

@testset "specified inds" begin
M = [1 1 5; 2 2 4]
inds = [2, 3]
expected = [-4, -2]

@test Transforms.apply(M, lc; inds=inds) == expected
@test FeatureTransforms.apply(M, lc; inds=inds) == expected
@test lc(M; inds=inds) == expected
end
end
Expand All @@ -83,40 +83,40 @@
expected = [-1, -1]

@testset "all inds" begin
@test Transforms.apply(A, lc) == expected
@test FeatureTransforms.apply(A, lc) == expected
@test lc(A) == expected
end

@testset "dims" begin
@testset "dims = :" begin
d = Colon()
@test_throws ArgumentError Transforms.apply(A, lc; dims=d)
@test_throws ArgumentError FeatureTransforms.apply(A, lc; dims=d)
end

@testset "dims = 1" begin
d = 1
@test Transforms.apply(A, lc; dims=d) == expected
@test FeatureTransforms.apply(A, lc; dims=d) == expected
@test lc(A; dims=d) == expected
end

@testset "dims = 2" begin
d = 2
@test Transforms.apply(A, lc; dims=d) == [-3, -3]
@test FeatureTransforms.apply(A, lc; dims=d) == [-3, -3]
@test lc(A; dims=d) == [-3, -3]
end
end

@testset "dimension mismatch" begin
A = AxisArray([1 2 3; 4 5 5], foo=["a", "b"], bar=["x", "y", "z"])
@test_throws DimensionMismatch Transforms.apply(A, lc)
@test_throws DimensionMismatch FeatureTransforms.apply(A, lc)
end

@testset "specified inds" begin
A = AxisArray([1 2 3; 4 5 5], foo=["a", "b"], bar=["x", "y", "z"])
inds = [1, 2]
expected = [-1, -1]

@test Transforms.apply(A, lc; inds=inds) == expected
@test FeatureTransforms.apply(A, lc; inds=inds) == expected
@test lc(A; inds=inds) == expected
end
end
Expand All @@ -126,40 +126,40 @@
expected = [-1, -1]

@testset "all inds" begin
@test Transforms.apply(A, lc) == expected
@test FeatureTransforms.apply(A, lc) == expected
@test lc(A) == expected
end

@testset "dims" begin
@testset "dims = :" begin
d = Colon()
@test_throws ArgumentError Transforms.apply(A, lc; dims=d)
@test_throws ArgumentError FeatureTransforms.apply(A, lc; dims=d)
end

@testset "dims = 1" begin
d = 1
@test Transforms.apply(A, lc; dims=d) == expected
@test FeatureTransforms.apply(A, lc; dims=d) == expected
@test lc(A; dims=d) == expected
end

@testset "dims = 2" begin
d = 2
@test Transforms.apply(A, lc; dims=d) == [-3, -3]
@test FeatureTransforms.apply(A, lc; dims=d) == [-3, -3]
@test lc(A; dims=d) == [-3, -3]
end
end

@testset "dimension mismatch" begin
A = KeyedArray([1 2 3; 4 5 6], foo=["a", "b"], bar=["x", "y", "z"])
@test_throws DimensionMismatch Transforms.apply(A, lc)
@test_throws DimensionMismatch FeatureTransforms.apply(A, lc)
end

@testset "specified inds" begin
A = KeyedArray([1 2 3; 4 5 5], foo=["a", "b"], bar=["x", "y", "z"])
inds = [1, 2]
expected = [-1, -1]

@test Transforms.apply(A, lc; inds=inds) == expected
@test FeatureTransforms.apply(A, lc; inds=inds) == expected
@test lc(A; inds=inds) == expected
end
end
Expand All @@ -169,33 +169,33 @@
expected = [-3, -3, -3]

@testset "all cols" begin
@test Transforms.apply(nt, lc) == expected
@test FeatureTransforms.apply(nt, lc) == expected
@test lc(nt) == expected
end

@testset "dims not supported" begin
@test_throws MethodError Transforms.apply(nt, lc; dims=1)
@test_throws MethodError FeatureTransforms.apply(nt, lc; dims=1)
end

@testset "dimension mismatch" begin
nt = (a = [1, 2, 3], b = [4, 5, 6], c = [1, 1, 1])
@test_throws DimensionMismatch Transforms.apply(nt, lc)
@test_throws DimensionMismatch FeatureTransforms.apply(nt, lc)
end

@testset "specified cols" begin
nt = (a = [1, 2, 3], b = [4, 5, 6], c = [1, 1, 1])
cols = [:a, :b]
expected = [-3, -3, -3]

@test Transforms.apply(nt, lc; cols=cols) == expected
@test FeatureTransforms.apply(nt, lc; cols=cols) == expected
@test lc(nt; cols=cols) == expected
end

@testset "single col" begin
lc_single = LinearCombination([-1])

@test Transforms.apply(nt, lc_single; cols=:a) == [-1, -2, -3]
@test Transforms.apply(nt, lc_single; cols=[:a]) == [-1, -2, -3]
@test FeatureTransforms.apply(nt, lc_single; cols=:a) == [-1, -2, -3]
@test FeatureTransforms.apply(nt, lc_single; cols=[:a]) == [-1, -2, -3]
@test lc_single(nt; cols=:a) == [-1, -2, -3]
end
end
Expand All @@ -205,33 +205,33 @@
expected = [-3, -3, -3]

@testset "all cols" begin
@test Transforms.apply(df, lc) == expected
@test FeatureTransforms.apply(df, lc) == expected
@test lc(df) == expected
end

@testset "dims not supported" begin
@test_throws MethodError Transforms.apply(df, lc; dims=1)
@test_throws MethodError FeatureTransforms.apply(df, lc; dims=1)
end

@testset "dimension mismatch" begin
df = DataFrame(:a => [1, 2, 3], :b => [4, 5, 6], :c => [1, 1, 1])
@test_throws DimensionMismatch Transforms.apply(df, lc)
@test_throws DimensionMismatch FeatureTransforms.apply(df, lc)
end

@testset "specified cols" begin
df = DataFrame(:a => [1, 2, 3], :b => [4, 5, 6], :c => [1, 1, 1])
cols = [:b, :c]
expected = [3, 4, 5]

@test Transforms.apply(df, lc; cols=cols) == expected
@test FeatureTransforms.apply(df, lc; cols=cols) == expected
@test lc(df; cols=cols) == expected
end

@testset "single col" begin
lc_single = LinearCombination([-1])

@test Transforms.apply(df, lc_single; cols=:a) == [-1, -2, -3]
@test Transforms.apply(df, lc_single; cols=[:a]) == [-1, -2, -3]
@test FeatureTransforms.apply(df, lc_single; cols=:a) == [-1, -2, -3]
@test FeatureTransforms.apply(df, lc_single; cols=[:a]) == [-1, -2, -3]
@test lc_single(df; cols=:a) == [-1, -2, -3]
end
end
Expand Down
Loading

0 comments on commit 9d3000f

Please sign in to comment.