Skip to content

Commit f744089

Browse files
committed
get rid of some template stuff
more
1 parent c36fc9f commit f744089

File tree

4 files changed

+26
-57
lines changed

4 files changed

+26
-57
lines changed

Project.toml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
name = "MLJExampleInterface"
2-
uuid = "33837fe5-dbff-4c9e-8c2f-c5612fe2b8b6"
3-
authors = ["Anthony D. Blaom <[email protected]>"]
1+
name = "MLJText"
2+
uuid = "5e27fcf9-6bac-46ba-8580-b5712f3d6387"
3+
authors = ["Chris Alexander, Anthony D. Blaom <[email protected]>"]
44
version = "0.1.0"
55

66
[deps]
7-
Example = "7876af07-990d-54b4-ab0e-23690620f79a"
87
MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
98
ScientificTypesBase = "30f210dd-8aff-4c5f-94ba-8e64358c1161"
9+
TextAnalysis = "a2db99b7-8b79-58f8-94bf-bbc811eef33d"
10+
11+
[compat]
12+
MLJModelInterface = "1.1.1"
13+
ScientificTypesBase = "1"
14+
TextAnalysis = "0.7.3"
15+
julia = "1"
1016

1117
[extras]
1218
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"

README.md

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,8 @@
1-
# MLJExampleInterface.jl
1+
# MLJText.jl
22

3-
This repository is a template for creating repositories that contain
4-
glue code between packages providing machine learing algorithms, and
5-
the machine learning toolbox
6-
[MLJ](https://alan-turing-institute.github.io/MLJ.jl/dev/) - that is,
7-
for so-called *interface-only packages*.
8-
9-
## When to use this template
10-
11-
This template is intended for use when a package providing a machine
12-
learning model algorithm is not hosting the code that implements the
13-
MLJ model API, and a separate package for this purpose is to be
14-
created. This repo is itself a working implementation but should
15-
be used in conjunction with the more detailed [model implementation
16-
guidelines](https://alan-turing-institute.github.io/MLJ.jl/dev/adding_models_for_general_use/).
17-
18-
## How to use this template
19-
20-
1. Clone this repository or use it as a template if available from your organization.
21-
22-
2. Rename this repository, replacing the word "Example" with the name of the model-providing package.
23-
24-
1. Develop the contents of src/MLJExampleInterface.jl appropriately
25-
26-
2. Rename src/MLJExampleInterface.jl appropriately
27-
28-
3. Remove Example from Project.toml and instead add the model-providing package
29-
30-
3. **GENERATE A NEW UUID in Project.toml**
31-
32-
4. Replace every instance of "Example" in this README.md with the name of the model-providing package and adjust the organization name in the link.
33-
34-
5. Remove everything in this REAMDE.md except what is below the line you are currently reading &#128521;
35-
36-
37-
# MLJ.jl <--> Example.jl
38-
39-
Repository implementing the [MLJ](https://alan-turing-institute.github.io/MLJ.jl/dev/) model interface for models provided by
40-
[Example.jl](https://github.com/JuliaLang/Example.jl).
3+
An [MLJ](https://alan-turing-institute.github.io/MLJ.jl/dev/)
4+
extension providing tools and model for text analysis.
415

426
| Linux | Coverage |
437
| :------------ | :------- |
44-
| [![Build Status](https://github.com/JuliaAI/MLJExampleInterface.jl/workflows/CI/badge.svg)](https://github.com/JuliaAI/MLJExampleInterface.jl/actions) | [![Coverage](https://codecov.io/gh/JuliaAI/MLJExampleInterface.jl/branch/master/graph/badge.svg)](https://codecov.io/github/JuliaAI/MLJExampleInterface.jl?branch=master) |
8+
| [![Build Status](https://github.com/JuliaAI/MLJText.jl/workflows/CI/badge.svg)](https://github.com/JuliaAI/MLJText.jl/actions) | [![Coverage](https://codecov.io/gh/JuliaAI/MLJText.jl/branch/master/graph/badge.svg)](https://codecov.io/github/JuliaAI/MLJText.jl?branch=master) |

src/MLJExampleInterface.jl renamed to src/MLJText.jl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
module MLJExampleInterface
1+
module MLJText
22

3-
# Example.jl doesn't actually provide machine learning models, so we
4-
# provide a module below with the same name to furnish us with simple
5-
# constant probabilistic classification. Note that `Example.fit`
6-
# ignores the training features `Xmatrix`.
3+
# The following is just boostrap code to get a working template. You
4+
# will remove this and replace "import .TextAnalysis" with "import
5+
# TextAnalysis" and any other deps you need.
76

8-
module Example
7+
module TextAnalysis
98

109
function fit(Xmatrix::Matrix, yint::AbstractVector{<:Integer})
1110
classes = sort(unique(yint))
@@ -36,11 +35,11 @@ end # of module
3635

3736
### CONTINUATION OF TEMPLATE
3837

39-
import .Example # substitute model-providing package name here (no dot)
38+
import .TextAnalysis # substitute model-providing package name here (no dot)
4039
import MLJModelInterface
4140
import ScientificTypesBase
4241

43-
const PKG = "Example" # substitute model-providing package name
42+
const PKG = "TextAnalysis" # substitute model-providing package name
4443
const MMI = MLJModelInterface
4544
const STB = ScientificTypesBase
4645

@@ -66,7 +65,7 @@ function MMI.fit(::CoolProbabilisticClassifier, verbosity, X, y)
6665
decode = MMI.decoder(y[1]) # for decoding int repr.
6766
classes_seen = decode(sort(unique(yint))) # ordered by int repr.
6867

69-
Θ = Example.fit(Xmatrix, yint) # probability vector
68+
Θ = TextAnalysis.fit(Xmatrix, yint) # probability vector
7069
fitresult = (Θ, classes_seen)
7170
report = (n_classes_seen = length(classes_seen),)
7271
cache = nothing
@@ -79,7 +78,7 @@ function MMI.predict(::CoolProbabilisticClassifier, fitresult, Xnew)
7978
Xmatrix = MMI.matrix(Xnew)
8079

8180
Θ, classes_seen = fitresult
82-
prob_matrix = Example.predict(Xmatrix, Θ)
81+
prob_matrix = TextAnalysis.predict(Xmatrix, Θ)
8382

8483
# `classes_seen` is a categorical vector whose pool actually
8584
# includes *all* classes. The `UnivariateFinite` constructor
@@ -100,7 +99,7 @@ end
10099
MMI.metadata_pkg(CoolProbabilisticClassifier,
101100
name="$PKG",
102101
uuid="7876af07-990d-54b4-ab0e-23690620f79a",
103-
url="https://github.com/JuliaLang/Example.jl",
102+
url="https://github.com/JuliaLang/TextAnalysis.jl",
104103
is_pure_julia=true,
105104
license="MIT",
106105
is_wrapper=false

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using MLJExampleInterface # substitute for correct interface pkg name
1+
using MLJTextAnalysisInterface # substitute for correct interface pkg name
22
using Test
33
using MLJBase
44
import Distributions
@@ -10,7 +10,7 @@ rng = StableRNGs.StableRNG(123)
1010
p = 3
1111
nclasses = 5
1212
X, y = make_blobs(n, p, centers=nclasses, rng=rng);
13-
model = MLJExampleInterface.CoolProbabilisticClassifier()
13+
model = MLJTextAnalysisInterface.CoolProbabilisticClassifier()
1414
mach = machine(model, X, y)
1515
fit!(mach, rows=1:2, verbosity=0)
1616
yhat = predict(mach, rows=3)

0 commit comments

Comments
 (0)