Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create chatbot with questions and answers #329

Closed
vvasil3v opened this issue Apr 13, 2024 · 0 comments
Closed

create chatbot with questions and answers #329

vvasil3v opened this issue Apr 13, 2024 · 0 comments

Comments

@vvasil3v
Copy link

vvasil3v commented Apr 13, 2024

Hello,
I am trying to create a chatbot with csv data like:

Question,Answer
"What is the capital of {{country}}?","Paris"
"How many planets are there in our solar system?","Eight"
"What is the square root of {{number}}?","{{sqrt(number)}}"

here is the code:

`$dataset = Rubix\ML\Datasets\Labeled::fromIterator(new Rubix\ML\Extractors\CSV(dirname(FILE).'/training.csv',true));

    [$training, $testing] = $dataset->stratifiedSplit(1); 
    $estimator = new \Rubix\ML\Classifiers\KNearestNeighbors(5, true);
    $estimator->train($training);

    $user_question = 'What is the capital of France?';

    $parameters = extract_parameters($user_question);
    $predicted_answer = $estimator->predict([$user_question]);
    $final_answer = replace_placeholders($predicted_answer[0], $parameters);

    echo "Answer: $final_answer\n";`

I have this error:

Uncaught Rubix\ML\Exceptions\InvalidArgumentException: K Nearest Neighbors (k: 5, weighted: false, kernel: Euclidean) is incompatible with categorical data types. in /content/controller/vendor/rubix/ml/src/Specifications/SamplesAreCompatibleWithEstimator.php:68 Stack trace: #0 /content/controller/vendor/rubix/ml/src/Specifications/SpecificationChain.php(43): Rubix\ML\Specifications\SamplesAreCompatibleWithEstimator->check() #1 /content/controller/vendor/rubix/ml/src/Classifiers/KNearestNeighbors.php(186): Rubix\ML\Specifications\SpecificationChain->check() #2 /content/controller/vendor/rubix/ml/src/Classifiers/KNearestNeighbors.php(171): Rubix\ML\Classifiers\KNearestNeighbors->partial(Object(Rubix\ML\Datasets\Labeled)) #3 Rubix\ML\Classifiers\KNearestNeighbors->train(Object(Rubix\ML\Datasets\Labeled)) #4

am i missing something or it will not work like that ?

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant