Closed vvasil3v closed 5 months ago
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
Hello, I am trying to create a chatbot with csv data like:
here is the code:
`$dataset = Rubix\ML\Datasets\Labeled::fromIterator(new Rubix\ML\Extractors\CSV(dirname(FILE).'/training.csv',true));
I have this error:
am i missing something or it will not work like that ?
thank you