Skip to content

Commit

Permalink
Merge pull request #701 from JuliaAI/dev
Browse files Browse the repository at this point in the history
For a 0.19 release
  • Loading branch information
ablaom authored Dec 23, 2021
2 parents 4fe37eb + 7311060 commit a4cd41f
Show file tree
Hide file tree
Showing 54 changed files with 3,840 additions and 3,529 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- dev
- for-0-point-19-release
push:
branches:
- master
Expand Down
50 changes: 0 additions & 50 deletions .github/workflows/ci_nightly.yml

This file was deleted.

8 changes: 5 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name = "MLJBase"
uuid = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
authors = ["Anthony D. Blaom <[email protected]>"]
version = "0.18.26"
version = "0.19"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
CategoricalDistributions = "af321ab8-2d2e-40a6-b165-3d674595d28e"
ComputationalResources = "ed09eef8-17a6-5b46-8889-db040fac31e3"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Expand All @@ -29,6 +30,7 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[compat]
CategoricalArrays = "0.9, 0.10"
CategoricalDistributions = "0.1"
ComputationalResources = "0.3"
Distributions = "0.25.3"
InvertedIndices = "1"
Expand All @@ -39,8 +41,8 @@ OrderedCollections = "1.1"
Parameters = "0.12"
PrettyTables = "1"
ProgressMeter = "1.7.1"
ScientificTypes = "2.1"
StatisticalTraits = "2.1"
ScientificTypes = "3"
StatisticalTraits = "3"
StatsBase = "0.32, 0.33"
Tables = "0.2, 1.0"
julia = "1.3"
Expand Down
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ repository provides core functionality for MLJ, including:

- basic utilities for **manipulating data**

- an extension to
[Distributions.jl](https://github.com/JuliaStats/Distributions.jl)
called `UnivariateFinite` for randomly sampling *labeled*
categorical data

- a [small interface](https://alan-turing-institute.github.io/MLJ.jl/dev/evaluating_model_performance/#Custom-resampling-strategies-1) for **resampling strategies** and implementations, including `CV()`, `StratifiedCV` and `Holdout`

- methods for **performance evaluation**, based on those resampling strategies
Expand All @@ -59,9 +54,3 @@ repository provides core functionality for MLJ, including:
library, user-defined measures, as well as about forty natively
defined measures.


Previously MLJBase provided the model interface for integrating third
party machine learning models into MLJ. That role has now shifted to
the light-weight
[MLJModelInterface](https://github.com/JuliaAI/MLJModelInterface.jl)
package.
140 changes: 89 additions & 51 deletions src/MLJBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,46 @@ import Base: ==, precision, getindex, setindex!
import Base.+, Base.*

# Scitype
import ScientificTypes.ScientificTypesBase: TRAIT_FUNCTION_GIVEN_NAME
using ScientificTypes

# Traits for models and measures (which are being overloaded):
using StatisticalTraits

for trait in StatisticalTraits.TRAITS
eval(:(import StatisticalTraits.$trait))
end

import Base.instances # considered a trait for measures
import StatisticalTraits.snakecase
import StatisticalTraits.info

# Interface
using MLJModelInterface

# HACK: When https://github.com/JuliaAI/MLJModelInterface.jl/issues/124
# is resolved:
# Uncomment next line and delete "Hack Block"
# using MLJModelInterface
#####################
# Hack Block begins #
#####################
exported_names(m::Module) =
filter!(x -> Base.isexported(m, x),
Base.names(m; all=true, imported=true))
import MLJModelInterface
for name in exported_names(MLJModelInterface)
name in [:UnivariateFinite,
:augmented_transform,
:info] && continue
quote
import MLJModelInterface.$name
end |> eval
end
###################
# Hack Block ends #
###################

import MLJModelInterface: fit, update, update_data, transform,
inverse_transform, fitted_params, predict, predict_mode,
inverse_transform, fitted_params, predict, predict_mode,
predict_mean, predict_median, predict_joint,
evaluate, clean!, is_same_except,
save, restore, is_same_except, istransparent,
Expand Down Expand Up @@ -55,13 +80,13 @@ import StatsBase: fit!, mode, countmap
import Missings: levels
using Missings
import Distributions
using CategoricalDistributions
import Distributions: pdf, logpdf, sampler
const Dist = Distributions

# from Standard Library:
using Statistics, LinearAlgebra, Random, InteractiveUtils


# ===================================================================
## EXPORTS

Expand All @@ -73,9 +98,11 @@ using Statistics, LinearAlgebra, Random, InteractiveUtils

# traits for measures and models:
using StatisticalTraits

for trait in StatisticalTraits.TRAITS
eval(:(export $trait))
end

export implemented_methods # defined here and not in StatisticalTraits

export UnivariateFinite
Expand All @@ -88,7 +115,7 @@ export @mlj_model, metadata_pkg, metadata_model

# model api
export fit, update, update_data, transform, inverse_transform,
fitted_params, predict, predict_mode, predict_mean,
fitted_params, predict, predict_mode, predict_mean,
predict_median, predict_joint,
evaluate, clean!, training_losses

Expand All @@ -103,9 +130,14 @@ export CPU1, CPUProcesses, CPUThreads
export Unknown, Known, Finite, Infinite,
OrderedFactor, Multiclass, Count, Continuous, Textual,
Binary, ColorImage, GrayImage, Image, Table
export scitype, scitype_union, elscitype, nonmissing, trait

export scitype, scitype_union, elscitype, nonmissing
export coerce, coerce!, autotype, schema, info

# re-exports from CategoricalDistributions:
export CategoricalUnivariateFiniteArray, UnivariateFiniteVector


# -------------------------------------------------------------------
# exports from this module, MLJBase

Expand All @@ -123,19 +155,16 @@ export partition, unpack, complement, restrict, corestrict

# utilities.jl:
export flat_values, recursive_setproperty!,
recursive_getproperty, pretty, unwind
recursive_getproperty, pretty, unwind

# show.jl
export HANDLE_GIVEN_ID, @more, @constant, @bind, color_on, color_off

# univariate_finite/
export average, UnivariateFiniteArray, UnivariateFiniteVector

# datasets.jl:
export load_boston, load_ames, load_iris, load_sunspots,
load_reduced_ames, load_crabs, load_smarket,
@load_boston, @load_ames, @load_iris, @load_sunspots,
@load_reduced_ames, @load_crabs, @load_smarket
load_reduced_ames, load_crabs, load_smarket,
@load_boston, @load_ames, @load_iris, @load_sunspots,
@load_reduced_ames, @load_crabs, @load_smarket

# sources.jl:
export source, Source, CallableReturning
Expand All @@ -150,14 +179,18 @@ export make_blobs, make_moons, make_circles, make_regression
export machines, sources, @from_network, @pipeline, Stack,
glb, @tuple, node, @node, sources, origins, return!,
nrows_at_source, machine, rebind!, nodes, freeze!, thaw!,
Node, AbstractNode
Node, AbstractNode, Pipeline,
ProbabilisticPipeline, DeterministicPipeline, UnsupervisedPipeline,
StaticPipeline, IntervalPipeline

export TransformedTargetModel

# aliases to the above, kept for backwards compatibility:
export DeterministicNetwork, ProbabilisticNetwork, UnsupervisedNetwork

# resampling.jl:
export ResamplingStrategy, Holdout, CV, StratifiedCV, TimeSeriesCV,
evaluate!, Resampler, PerformanceEvaluation
evaluate!, Resampler, PerformanceEvaluation

# -------------------------------------------------------------------
# exports from MLJBase specific to Measure (these may go in their
Expand Down Expand Up @@ -223,33 +256,33 @@ export TruePositive, TrueNegative, FalsePositive, FalseNegative,
# measures/finite.jl -- Finite{N} - multiclass generalizations of
# above OrderedFactor{2} measures (but order independent):
export MulticlassTruePositive, MulticlassTrueNegative, MulticlassFalsePositive,
MulticlassFalseNegative, MulticlassTruePositiveRate,
MulticlassTrueNegativeRate, MulticlassFalsePositiveRate,
MulticlassFalseNegativeRate, MulticlassFalseDiscoveryRate,
MulticlassPrecision, MulticlassNegativePredictiveValue, MulticlassFScore,
# standard synonyms
MTPR, MTNR, MFPR, MFNR, MFDR, MPPV,
MulticlassRecall, MulticlassSpecificity,
# instances and their synonyms
multiclass_truepositive, multiclass_truenegative,
multiclass_falsepositive,
multiclass_falsenegative, multiclass_true_positive,
multiclass_true_negative, multiclass_false_positive,
multiclass_false_negative, multiclass_truepositive_rate,
multiclass_truenegative_rate, multiclass_falsepositive_rate,
multiclass_true_positive_rate, multiclass_true_negative_rate,
multiclass_false_positive_rate, multiclass_falsenegative_rate,
multiclass_negativepredictive_value, multiclass_false_negative_rate,
multiclass_negative_predictive_value, multiclass_positivepredictive_value,
multiclass_positive_predictive_value, multiclass_tpr, multiclass_tnr,
multiclass_fpr, multiclass_fnr, multiclass_falsediscovery_rate,
multiclass_false_discovery_rate, multiclass_fdr, multiclass_npv,
multiclass_ppv, multiclass_recall, multiclass_sensitivity,
multiclass_hit_rate, multiclass_miss_rate, multiclass_specificity,
multiclass_selectivity, macro_f1score, micro_f1score,
multiclass_f1score, multiclass_fallout, multiclass_precision,
# averaging modes
no_avg, macro_avg, micro_avg
MulticlassFalseNegative, MulticlassTruePositiveRate,
MulticlassTrueNegativeRate, MulticlassFalsePositiveRate,
MulticlassFalseNegativeRate, MulticlassFalseDiscoveryRate,
MulticlassPrecision, MulticlassNegativePredictiveValue, MulticlassFScore,
# standard synonyms
MTPR, MTNR, MFPR, MFNR, MFDR, MPPV,
MulticlassRecall, MulticlassSpecificity,
# instances and their synonyms
multiclass_truepositive, multiclass_truenegative,
multiclass_falsepositive,
multiclass_falsenegative, multiclass_true_positive,
multiclass_true_negative, multiclass_false_positive,
multiclass_false_negative, multiclass_truepositive_rate,
multiclass_truenegative_rate, multiclass_falsepositive_rate,
multiclass_true_positive_rate, multiclass_true_negative_rate,
multiclass_false_positive_rate, multiclass_falsenegative_rate,
multiclass_negativepredictive_value, multiclass_false_negative_rate,
multiclass_negative_predictive_value, multiclass_positivepredictive_value,
multiclass_positive_predictive_value, multiclass_tpr, multiclass_tnr,
multiclass_fpr, multiclass_fnr, multiclass_falsediscovery_rate,
multiclass_false_discovery_rate, multiclass_fdr, multiclass_npv,
multiclass_ppv, multiclass_recall, multiclass_sensitivity,
multiclass_hit_rate, multiclass_miss_rate, multiclass_specificity,
multiclass_selectivity, macro_f1score, micro_f1score,
multiclass_f1score, multiclass_fallout, multiclass_precision,
# averaging modes
no_avg, macro_avg, micro_avg

# measures/loss_functions_interface.jl
export dwd_margin_loss, exp_loss, l1_hinge_loss, l2_hinge_loss, l2_margin_loss,
Expand All @@ -273,6 +306,7 @@ const MARGIN_LOSSES = [
:SmoothedL1HingeLoss,
:ZeroOneLoss
]

const DISTANCE_LOSSES = [
:HuberLoss,
:L1EpsilonInsLoss,
Expand All @@ -282,6 +316,7 @@ const DISTANCE_LOSSES = [
:PeriodicLoss,
:QuantileLoss
]

const WITH_PARAMETERS = [
:DWDMarginLoss,
:SmoothedL1HingeLoss,
Expand All @@ -291,6 +326,7 @@ const WITH_PARAMETERS = [
:LPDistLoss,
:QuantileLoss,
]

const LOSS_FUNCTIONS = vcat(MARGIN_LOSSES, DISTANCE_LOSSES)

for Loss in LOSS_FUNCTIONS
Expand All @@ -301,12 +337,20 @@ end
# re-export from Random, StatsBase, Statistics, Distributions,
# OrderedCollections, CategoricalArrays, InvertedIndices:
export pdf, sampler, mode, median, mean, shuffle!, categorical, shuffle,
levels, levels!, std, Not, support, logpdf, LittleDict
levels, levels!, std, Not, support, logpdf, LittleDict


# ===================================================================
## CONSTANTS

const PREDICT_OPERATIONS = (:predict,
:predict_mean,
:predict_mode,
:predict_median,
:predict_joint)

const OPERATIONS = (PREDICT_OPERATIONS..., :transform, :inverse_transform)

# the directory containing this file: (.../src/)
const MODULE_DIR = dirname(@__FILE__)

Expand Down Expand Up @@ -345,26 +389,20 @@ include("show.jl")
include("interface/data_utils.jl")
include("interface/model_api.jl")

include("univariate_finite/types.jl")
include("univariate_finite/methods.jl")
include("univariate_finite/arrays.jl")

include("sources.jl")
include("machines.jl")

include("composition/abstract_types.jl")
include("composition/learning_networks/nodes.jl")
include("composition/learning_networks/inspection.jl")
include("composition/learning_networks/machines.jl")
@static if VERSION v"1.3.0-"
include("composition/learning_networks/arrows.jl")
end

include("composition/models/methods.jl")
include("composition/models/from_network.jl")
include("composition/models/inspection.jl")
include("composition/models/deprecated.jl")
include("composition/models/pipelines.jl")
include("composition/models/_wrapped_function.jl")
include("composition/models/transformed_target_model.jl")

include("operations.jl")
include("resampling.jl")
Expand Down
Loading

0 comments on commit a4cd41f

Please sign in to comment.