Skip to content

Commit

Permalink
Prepare for 0.1.0-beta release
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdalpino committed Sep 3, 2020
1 parent 05f8987 commit e8f5ed2
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 16 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
- Unreleased
- 0.1.0-beta
- Add Recursive Feature Eliminator feature selector
- Implement BM25 TF-IDF Transformer
- Add Delta TF-IDF Transformer
- Added Lambda function Transformer
- All objects implement Stringable interface
- All objects implement Stringable interface
- Added Gower nan-safe distance kernel
- Added ISRU and ISRLU activation functions
- Added Alpha Dropout hidden layer
- Added Model Orchestra meta-estimator
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"require": {
"php": ">=7.2",
"rubix/ml": "^0.1.0-rc3",
"rubix/ml": "^0.1.0",
"rubix/tensor": "^2.0.4",
"wamania/php-stemmer": "^2.0"
},
Expand Down
6 changes: 1 addition & 5 deletions docs/kernels/distance/gower.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ A robust distance kernel that measures a mix of categorical and continuous data
```php
use Rubix\ML\Kernels\Distance\Gower;

$kernel = new Gower(); // Continuous features between 0 and 1

$kernel = new Gower(2.0); // Between -1 and 1

$kernel = new Gower(1000.0); // Between 0 and 1000
$kernel = new Gower(2.0);
```

### References
Expand Down
2 changes: 1 addition & 1 deletion docs/transformers/bm25-transformer.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<span style="float:right;"><a href="https://github.com/RubixML/RubixML/blob/master/src/Transformers/TfIdfTransformer.php">[source]</a></span>
<span style="float:right;"><a href="https://github.com/RubixML/Extras/blob/master/src/Transformers/BM25Transformer.php">[source]</a></span>

# BM25 Transformer
BM25 is a term frequency weighting scheme that takes term frequency (TF) saturation and document length into account.
Expand Down
30 changes: 30 additions & 0 deletions docs/transformers/delta-tf-idf-transformer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<span style="float:right;"><a href="https://github.com/RubixML/Extras/blob/master/src/Transformers/DeltaTfIdfTransformer.php">[source]</a></span>

# Delta TF-IDF Transformer
A supervised TF-IDF (Term Frequency Inverse Document Frequency) Transformer that uses class labels to boost the TF-IDFs of terms by how informative they are. Terms that receive the highest boost are those whose concentration is primarily in one class whereas low weighted terms are more evenly distributed among the classes.

> **Note:** This transformer assumes that its input is made up of word frequency vectors such as those produced by [Word Count Vectorizer](word-count-vectorizer.md).
**Interfaces:** [Transformer](api.md#transformer), [Stateful](api.md#stateful), [Elastic](api.md#elastic)

**Data Type Compatibility:** Continuous only

## Parameters
This transformer does not have any parameters.

## Example
```php
use Rubix\ML\Transformers\DeltaTfIdfTransformer;

$transformer = new DeltaTfIdfTransformer();
```

## Additional Methods
Return the document frequencies calculated during fitting:
```php
public dfs() : ?array
```

### References
>- J. Martineau et al. (2009). Delta TFIDF: An Improved Feature Space for Sentiment Analysis.
>- S. Ghosh et al. (2018). Class Specific TF-IDF Boosting for Short-text Classification.
2 changes: 1 addition & 1 deletion docs/transformers/lambda-function.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<span style="float:right;"><a href="https://github.com/RubixML/RubixML/blob/master/src/Transformers/LambdaFunction.php">[source]</a></span>
<span style="float:right;"><a href="https://github.com/RubixML/Extras/blob/master/src/Transformers/LambdaFunction.php">[source]</a></span>

# Lambda Function
Run a stateless lambda function (*anonymous* function) over the samples. The lambda function receives the sample matrix as an argument and should return the transformed matrix.
Expand Down
2 changes: 1 addition & 1 deletion src/Kernels/Distance/Gower.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ public function compute(array $a, array $b) : float
*/
public function __toString() : string
{
return "Gower {range: {$this->range}}";
return "Gower (range: {$this->range})";
}
}
2 changes: 1 addition & 1 deletion src/ModelOrchestra.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,6 @@ protected function extractRegressor(Dataset $dataset) : array
*/
public function __toString() : string
{
return 'Model Orchestra {' . Params::stringify($this->params()) . '}';
return 'Model Orchestra (' . Params::stringify($this->params()) . ')';
}
}
2 changes: 1 addition & 1 deletion src/NeuralNet/ActivationFunctions/ISRLU.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ public function differentiate(Matrix $z, Matrix $computed) : Matrix
*/
public function __toString() : string
{
return "ISRLU {alpha: {$this->alpha}}";
return "ISRLU (alpha: {$this->alpha})";
}
}
2 changes: 1 addition & 1 deletion src/NeuralNet/ActivationFunctions/ISRU.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ public function differentiate(Matrix $z, Matrix $computed) : Matrix
*/
public function __toString() : string
{
return "ISRU {alpha: {$this->alpha}}";
return "ISRU (alpha: {$this->alpha})";
}
}
2 changes: 1 addition & 1 deletion src/NeuralNet/Layers/AlphaDropout.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,6 @@ public function saturate(int $value) : float
*/
public function __toString() : string
{
return "Alpha Dropout {ratio: {$this->ratio}}";
return "Alpha Dropout (ratio: {$this->ratio})";
}
}
12 changes: 11 additions & 1 deletion src/Transformers/DeltaTfIdfTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @package Rubix/ML
* @author Andrew DalPino
*/
class DeltaTfIdfTransformer implements Elastic
class DeltaTfIdfTransformer implements Transformer, Stateful, Elastic
{
/**
* The class specific term frequencies of each word i.e. the number of
Expand Down Expand Up @@ -102,6 +102,16 @@ public function fitted() : bool
return $this->idfs and $this->entropies;
}

/**
* Return the document frequencies calculated during fitting.
*
* @return int[]|null
*/
public function dfs() : ?array
{
return $this->dfs;
}

/**
* Fit the transformer to the dataset.
*
Expand Down

0 comments on commit e8f5ed2

Please sign in to comment.