Skip to content

Commit

Permalink
treatment, test included
Browse files Browse the repository at this point in the history
  • Loading branch information
PasoStudio73 committed Feb 24, 2025
1 parent 8267065 commit 8c357f7
Show file tree
Hide file tree
Showing 7 changed files with 1,205 additions and 296 deletions.
20 changes: 5 additions & 15 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
name = "SoleFeatures"
uuid = "3ceb4e54-d968-4e97-8c18-2deeb0d429fb"
authors = ["Patrik Cavina", "Federico Manzella", "Giovanni Pagliarini"]
version = "0.2.0"
version = "0.3.0"

[deps]
Catch22 = "acdeb78f-3d39-4310-8fdf-6d75c17c6d5a"
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
HypothesisTests = "09f84164-cd44-5f33-b23f-e6b0d136a0d5"
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MLBase = "f0e99cf1-93fa-52ec-9ecc-5026115318e0"
MultiData = "8cc5100c-b3d1-4f82-90cb-0ea93d317aba"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
SoleBase = "4475fa32-7023-44a0-aa70-4813b230e492"
SoleData = "123f1ae1-6307-4526-ab5b-aab3a92a2b8c"
SoleLogics = "b002da8f-3cb3-4d91-bbe3-2953433912b5"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

[compat]
Catch22 = "0.7"
CategoricalArrays = "0.10"
DataFrames = "1"
HypothesisTests = "0.10 - 0.11"
HypothesisTests = "0.11"
IterTools = "1"
MultiData = "0 - 0.1"
OrderedCollections = "1"
PyCall = "1"
Random = "1"
Reexport = "1"
Revise = "3"
SoleData = "0.16"
SoleBase = "0.13"
StatsBase = "0.30 - 0.34"
julia = "1"

Expand Down
183 changes: 99 additions & 84 deletions src/SoleFeatures.jl
Original file line number Diff line number Diff line change
@@ -1,96 +1,111 @@
__precompile__()
# __precompile__()
module SoleFeatures

using StatsBase
using MultiData
using SoleData
using Reexport
using SoleBase
using StatsBase, Catch22
using CategoricalArrays, DataFrames
using Random
using LinearAlgebra
using HypothesisTests
using IterTools
using PyCall
using MLBase
# using Pkg

# abstracts
export AbstractFeaturesSelector
export AbstractFilterBased
export AbstractWrapperBased
export AbstractEmbeddedBased
export AbstractLimiter
# structs
export VarianceThreshold
export VarianceRanking
export RandomRanking
export StatisticalAtLeastOnce
export StatisticalMajority
export PearsonCorRanking
export Chi2Ranking
export Chi2Threshold
export MutualInformationClassifRanking
export CompoundStatisticalAtLeastOnce
export CompoundStatisticalMajority
export CorrelationFilter
# main functions
export apply, buildbitmask, transform, transform!
# utils
export bm2var
include("utils/features_set.jl")
export mode_5, mode_10, embedding_dist, acf_timescale, acf_first_min, ami2, trev, outlier_timing_pos
export outlier_timing_neg, whiten_timescale, forecast_error, ami_timescale, high_fluctuation, stretch_decreasing
export stretch_high, entropy_pairs, rs_range, dfa, low_freq_power, centroid_freq, transition_variance, periodicity
export base_set, catch9, catch22_set, complete_set

@reexport using DataFrames
include("dataset/dataset_structs.jl")
export Feature

const req_py_pkgs = ["scipy", "scikit-learn", "skfeature"]
const fs = PyNULL()
const construct_w = PyNULL()
const lap_score = PyNULL()
const fisher_score = PyNULL()
function __init__()
include("dataset/prepare_dataset.jl")
export feature_selection_preprocess

pypkgs = getindex.(PyCall.Conda.parseconda(`list`, PyCall.Conda.ROOTENV), "name")
needinstall = !all(p -> in(p, pypkgs), req_py_pkgs)
# using MultiData
# using SoleData
# using Reexport
# using LinearAlgebra
# using HypothesisTests
# using IterTools
# using PyCall
# using MLBase
# # using Pkg

if (needinstall)
PyCall.Conda.pip_interop(true, PyCall.Conda.ROOTENV)
PyCall.Conda.add("scipy")
PyCall.Conda.add("scikit-learn")
PyCall.Conda.pip(
"install",
"git+https://github.com/jundongl/scikit-feature.git#egg=skfeature",
PyCall.Conda.ROOTENV
)
end
# # abstracts
# export AbstractFeaturesSelector
# export AbstractFilterBased
# export AbstractWrapperBased
# export AbstractEmbeddedBased
# export AbstractLimiter
# # structs
# export VarianceThreshold
# export VarianceRanking
# export RandomRanking
# export StatisticalAtLeastOnce
# export StatisticalMajority
# export PearsonCorRanking
# export Chi2Ranking
# export Chi2Threshold
# export MutualInformationClassifRanking
# export CompoundStatisticalAtLeastOnce
# export CompoundStatisticalMajority
# export CorrelationFilter
# # main functions
# export apply, buildbitmask, transform, transform!
# # utils
# export bm2var

copy!(fs, pyimport_conda("sklearn.feature_selection", "scikit-learn"))
copy!(construct_w, pyimport_conda("skfeature.utility.construct_W", "skfeature"))
copy!(lap_score, pyimport_conda(
"skfeature.function.similarity_based.lap_score",
"skfeature"
))
copy!(fisher_score, pyimport_conda(
"skfeature.function.similarity_based.fisher_score",
"skfeature"
))
end
# @reexport using DataFrames

include("interface.jl")
include("core.jl")
# Utils
include("utils/utils.jl")
# Filters
include("filters/limiter.jl")
include("filters/interface.jl")
include("filters/univariate/randomfilter.jl")
include("filters/univariate/statisticalfilter.jl")
include("filters/univariate/variancefilter.jl")
include("filters/univariate/chi2filter.jl")
include("filters/univariate/pearsoncorfilter.jl")
include("filters/univariate/mutualinformationclassif.jl")
include("filters/univariate/suplapscorefiler.jl")
include("filters/univariate/fisherscorefilter.jl")
include("filters/univariate/utils.jl")
include("filters/multivariate/correlationfilter.jl")
# Experimental
include("experimental/Experimental.jl")
import .Experimental
# const req_py_pkgs = ["scipy", "scikit-learn", "skfeature"]
# const fs = PyNULL()
# const construct_w = PyNULL()
# const lap_score = PyNULL()
# const fisher_score = PyNULL()
# function __init__()

# pypkgs = getindex.(PyCall.Conda.parseconda(`list`, PyCall.Conda.ROOTENV), "name")
# needinstall = !all(p -> in(p, pypkgs), req_py_pkgs)

# if (needinstall)
# PyCall.Conda.pip_interop(true, PyCall.Conda.ROOTENV)
# PyCall.Conda.add("scipy")
# PyCall.Conda.add("scikit-learn")
# PyCall.Conda.pip(
# "install",
# "git+https://github.com/jundongl/scikit-feature.git#egg=skfeature",
# PyCall.Conda.ROOTENV
# )
# end

# copy!(fs, pyimport_conda("sklearn.feature_selection", "scikit-learn"))
# copy!(construct_w, pyimport_conda("skfeature.utility.construct_W", "skfeature"))
# copy!(lap_score, pyimport_conda(
# "skfeature.function.similarity_based.lap_score",
# "skfeature"
# ))
# copy!(fisher_score, pyimport_conda(
# "skfeature.function.similarity_based.fisher_score",
# "skfeature"
# ))
# end

# include("interface.jl")
# include("core.jl")
# # Utils
# include("utils/utils.jl")
# # Filters
# include("filters/limiter.jl")
# include("filters/interface.jl")
# include("filters/univariate/randomfilter.jl")
# include("filters/univariate/statisticalfilter.jl")
# include("filters/univariate/variancefilter.jl")
# include("filters/univariate/chi2filter.jl")
# include("filters/univariate/pearsoncorfilter.jl")
# include("filters/univariate/mutualinformationclassif.jl")
# include("filters/univariate/suplapscorefiler.jl")
# include("filters/univariate/fisherscorefilter.jl")
# include("filters/univariate/utils.jl")
# include("filters/multivariate/correlationfilter.jl")
# # Experimental
# include("experimental/Experimental.jl")
# import .Experimental

end # module
Loading

0 comments on commit 8c357f7

Please sign in to comment.