def test_statsmodels_processmle(): estimator = utils.StatsmodelsSklearnLikeWrapper( ProcessMLE, dict(init=dict( exog_scale=np.ones( (len(utils.get_regression_model_trainer().y_train), 2)), exog_smooth=np.ones( (len(utils.get_regression_model_trainer().y_train), 2)), exog_noise=np.ones( (len(utils.get_regression_model_trainer().y_train), 2)), time=np.kron( np.ones( len(utils.get_regression_model_trainer().y_train) // 3), np.arange(3)), groups=np.kron( np.arange( len(utils.get_regression_model_trainer().y_train) // 3), np.ones(3))), fit=dict(maxiter=1))) _, __, estimator = utils.get_regression_model_trainer()(estimator) assembler = assemblers.ProcessMLEModelAssembler(estimator) actual = assembler.assemble() feature_weight_mul = [ ast.BinNumExpr(ast.FeatureRef(0), ast.NumVal(-0.0980302102110356), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(1), ast.NumVal(0.04863869398287732), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(2), ast.NumVal(0.009514054355147874), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(3), ast.NumVal(2.977113829322681), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(4), ast.NumVal(-2.6048073854474705), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(5), ast.NumVal(5.887987153279099), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(6), ast.NumVal(-0.008183580358672775), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(7), ast.NumVal(-0.996428929917054), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(8), ast.NumVal(0.1618353156581333), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(9), ast.NumVal(-0.009213049690188308), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(10), ast.NumVal(-0.3634816838591863), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(11), ast.NumVal(0.014700492832969888), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(12), ast.NumVal(-0.4384298738156768), ast.BinNumOpType.MUL), ] expected = assemblers.utils.apply_op_to_expressions( ast.BinNumOpType.ADD, ast.NumVal(0.0), *feature_weight_mul) assert utils.cmp_exprs(actual, expected)
def test_statsmodels_processmle(): estimator = utils.StatsmodelsSklearnLikeWrapper( ProcessMLE, dict(init=dict( exog_scale=np.ones( (len(utils.get_regression_model_trainer().y_train), 2)), exog_smooth=np.ones( (len(utils.get_regression_model_trainer().y_train), 2)), exog_noise=np.ones( (len(utils.get_regression_model_trainer().y_train), 2)), time=np.kron( np.ones( len(utils.get_regression_model_trainer().y_train) // 3), np.arange(3)), groups=np.kron( np.arange( len(utils.get_regression_model_trainer().y_train) // 3), np.ones(3))), fit=dict(maxiter=1))) _, __, estimator = utils.get_regression_model_trainer()(estimator) assembler = assemblers.ProcessMLEModelAssembler(estimator) actual = assembler.assemble() feature_weight_mul = [ ast.BinNumExpr(ast.FeatureRef(0), ast.NumVal(-0.0915126856), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(1), ast.NumVal(0.0455368812), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(2), ast.NumVal(-0.0092227692), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(3), ast.NumVal(2.8566616798), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(4), ast.NumVal(-2.1208777964), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(5), ast.NumVal(5.9725253309), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(6), ast.NumVal(-0.0061566965), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(7), ast.NumVal(-0.9414114075), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(8), ast.NumVal(0.1522429507), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(9), ast.NumVal(-0.0092123938), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(10), ast.NumVal(-0.3928508764), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(11), ast.NumVal(0.0134405151), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(12), ast.NumVal(-0.4364996490), ast.BinNumOpType.MUL), ] expected = assemblers.utils.apply_op_to_expressions( ast.BinNumOpType.ADD, ast.NumVal(0.0), *feature_weight_mul) assert utils.cmp_exprs(actual, expected)
def test_statsmodels_processmle(): estimator = utils.StatsmodelsSklearnLikeWrapper( ProcessMLE, dict(init=dict( exog_scale=np.ones( (len(utils.get_regression_model_trainer().y_train), 2)), exog_smooth=np.ones( (len(utils.get_regression_model_trainer().y_train), 2)), exog_noise=np.ones( (len(utils.get_regression_model_trainer().y_train), 2)), time=np.kron( np.ones( len(utils.get_regression_model_trainer().y_train) // 3), np.arange(3)), groups=np.kron( np.arange( len(utils.get_regression_model_trainer().y_train) // 3), np.ones(3))), fit=dict(maxiter=1))) _, __, estimator = utils.get_regression_model_trainer()(estimator) assembler = assemblers.ProcessMLEModelAssembler(estimator) actual = assembler.assemble() feature_weight_mul = [ ast.BinNumExpr(ast.FeatureRef(0), ast.NumVal(-0.0932673973), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(1), ast.NumVal(0.0480819091), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(2), ast.NumVal(-0.0063734439), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(3), ast.NumVal(2.7510656855), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(4), ast.NumVal(-3.0836268637), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(5), ast.NumVal(5.9605290000), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(6), ast.NumVal(-0.0077880716), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(7), ast.NumVal(-0.9685365627), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(8), ast.NumVal(0.1688777882), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(9), ast.NumVal(-0.0092446419), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(10), ast.NumVal(-0.3924930042), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(11), ast.NumVal(0.01506511708295605), ast.BinNumOpType.MUL), ast.BinNumExpr(ast.FeatureRef(12), ast.NumVal(-0.4177000096), ast.BinNumOpType.MUL), ] expected = assemblers.utils.apply_op_to_expressions( ast.BinNumOpType.ADD, ast.NumVal(0.0), *feature_weight_mul) assert utils.cmp_exprs(actual, expected)