2017-10-17 10:44:46 +00:00
|
|
|
#pragma once
|
|
|
|
#include <Functions/IFunction.h>
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class ExternalModels;
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2017-10-17 12:02:30 +00:00
|
|
|
/// Evaluate external model.
|
|
|
|
/// First argument - model name, the others - model arguments.
|
|
|
|
/// * for CatBoost model - float features first, then categorical
|
|
|
|
/// Result - Float64.
|
2017-10-17 10:43:42 +00:00
|
|
|
class FunctionModelEvaluate final : public IFunction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static constexpr auto name = "modelEvaluate";
|
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
static FunctionPtr create(const Context & context);
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
explicit FunctionModelEvaluate(const ExternalModels & models) : models(models) {}
|
2017-10-17 10:43:42 +00:00
|
|
|
|
|
|
|
String getName() const override { return name; }
|
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
bool isVariadic() const override { return true; }
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
size_t getNumberOfArguments() const override { return 0; }
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override;
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result) override;
|
2017-10-17 10:43:42 +00:00
|
|
|
|
2017-10-17 10:44:46 +00:00
|
|
|
private:
|
|
|
|
const ExternalModels & models;
|
2017-10-17 10:43:42 +00:00
|
|
|
};
|
2017-10-17 10:44:46 +00:00
|
|
|
|
|
|
|
}
|