/* ----------------------------------------------------------------------- *//** * * @file GLM_proto.hpp * *//* ----------------------------------------------------------------------- */ #ifndef MADLIB_MODULES_GLM_GLM_PROTO_HPP #define MADLIB_MODULES_GLM_GLM_PROTO_HPP #include "family.hpp" #include "link.hpp" #include namespace madlib { namespace modules { namespace glm { // Use Eigen using namespace dbal; using namespace dbal::eigen_integration; template class GLMAccumulator : public DynamicStruct,Container> { public: typedef DynamicStruct Base; MADLIB_DYNAMIC_STRUCT_TYPEDEFS; typedef std::tuple tuple_type; GLMAccumulator(Init_type& inInitialization); void bind(ByteStream_type& inStream); GLMAccumulator& operator<<(const tuple_type& inTuple); template GLMAccumulator& operator<<(const GLMAccumulator& inOther); template GLMAccumulator& operator=(const GLMAccumulator& inOther); void apply(); void reset(); bool empty() const { return this->num_rows == 0; } uint64_type num_rows; bool_type terminated; double_type loglik; double_type dispersion; // to calculate loglik double_type dispersion_accum; // to accumulate the dispersion Matrix_type vcov; uint16_type num_coef; // number of variables ColumnVector_type beta; // coefficients ColumnVector_type grad; // accumulating value of gradient Matrix_type hessian; // accumulating expected value of Hessian }; // ------------------------------------------------------------------------ class GLMResult { public: template GLMResult( const GLMAccumulator& inState); template GLMResult& compute( const GLMAccumulator& inState); // native arrays returns to db without copying double loglik; MutableNativeColumnVector coef; MutableNativeColumnVector std_err; MutableNativeColumnVector z_stats; MutableNativeColumnVector p_values; uint64_t num_rows_processed; double dispersion; }; } // namespace glm } // namespace modules } // namespace madlib #endif // defined(MADLIB_MODULES_GLM_GLM_PROTO_HPP)