I’m trying to extract the product price for different sentences using https://rubixml.com/, but it always returns 260, the first label I give to it
<?php
include_once '../vendor/autoload.php';
use RubixMLDatasetsLabeled;
use RubixMLDatasetsUnlabeled;
use RubixMLClassifiersKNearestNeighbors;
use RubixMLTransformersWordCountVectorizer;
use RubixMLTransformersTfIdfTransformer;
use RubixMLPipeline;
use RubixMLExtractorsCSV;
$samples= ['The price is 260','The cost is 500','This shirt costs 300','The value of this item is 450','Sold for 150 dolars'];
$labels = ['260', '500', '300', '450', '150'];
$dataset = new Labeled($samples, $labels);
// genrate the model
$pipeline = new Pipeline([
new WordCountVectorizer(100),
new TfIdfTransformer(),
], new KNearestNeighbors(3));
// training with dataset
$pipeline->train($dataset);
// analize new frace
$new = Unlabeled::build([
['Price: 1200'],
]);
// Predict
$predictions = $pipeline->predict($new);
var_dump($predictions);
I have changed the values for the KNearestNeighbors, provide larger inputs for train dataset, change the Vectorizer. But nothing changes.