ClickHouse/dbms/tests/queries/0_stateless/00900_mytest.sql

48 lines
30 KiB
MySQL
Raw Normal View History

2019-01-22 21:07:05 +00:00
CREATE DATABASE IF NOT EXISTS test;
DROP TABLE IF EXISTS test.defaults;
CREATE TABLE IF NOT EXISTS test.defaults
(
param1 Float64,
param2 Float64,
target Float64,
predict1 Float64,
predict2 Float64
) ENGINE = Memory;
-- -- insert into test.defaults values (2.533, 0.543, 3.181), (1.999, 1.765, 0.470), (0.631, 2.580, -1.845), (-1.164, 0.889, 0.640), (2.110, 0.768, 2.519), (1.251, 0.483, 2.659), (-3.958, 1.299, -1.576), (-2.152, -1.316, 4.556), (3.269, 1.441, 1.753), (4.206, -1.635, 8.373), (-3.479, -0.544, 2.349), (4.006, 0.167, 4.670), (-4.478, 2.400, -4.039), (1.856, 0.256, 3.417), (1.470, 1.685, 0.366), (-4.052, 2.326, -3.678), (-0.971, -0.969, 4.453), (0.881, -1.848, 7.137), (-1.551, -1.766, 5.756), (-0.988, -0.945, 4.395), (-4.636, 1.074, -1.466), (-4.074, -1.486, 3.934), (0.754, 2.627, -1.877), (1.035, 0.889, 1.738), (3.707, -1.281, 7.415), (-2.215, 1.110, -0.327), (-2.965, -1.316, 4.150), (-3.581, 1.063, -0.917), (0.548, 0.343, 2.588), (3.023, -0.870, 6.251), (4.053, -1.441, 7.909), (-0.750, 0.639, 1.348), (-4.411, 1.636, -2.477), (1.786, 0.398, 3.096), (-2.514, 0.033, 1.676), (4.935, -0.840, 7.148), (1.075, -0.921, 5.380), (-3.418, 2.177, -3.063), (3.122, 1.883, 0.795), (-2.254, -1.389, 4.650), (-4.603, 2.909, -5.119), (-1.886, -1.220, 4.497), (-0.509, -1.498, 5.741), (2.192, 1.882, 0.332), (4.056, -1.108, 7.244), (-1.918, 0.230, 1.581), (4.867, 1.516, 2.401), (-0.993, -0.011, 2.526), (-0.757, -1.192, 5.006), (-4.161, 2.059, -3.198), (2.258, 1.157, 1.814), (-3.878, -0.052, 1.165), (1.915, 2.998, -2.038), (-2.164, 2.379, -2.841), (-0.114, -1.914, 6.772), (3.812, 2.138, 0.630), (-1.863, 1.508, -0.947), (-2.964, 0.398, 0.722), (-2.046, -0.193, 2.363), (-1.525, -0.836, 3.910), (-4.557, -0.582, 1.886), (1.031, -0.461, 4.437), (-0.802, 0.699, 1.201), (3.982, 2.084, 0.824), (-2.243, 2.726, -3.573), (-3.989, -0.803, 2.611), (4.900, 0.253, 4.944), (-1.208, -1.587, 5.571), (0.370, 2.579, -1.972), (2.824, 0.964, 2.484), (-1.290, -0.128, 2.611), (0.190, 2.058, -1.021), (4.058, 2.122, 0.784), (4.879, 0.945, 3.549), (1.119, 1.992, -0.424), (4.050, 2.005, 1.015), (-0.064, 1.485, -0.002), (-2.496, 0.456, 0.840), (-1.835, 1.586, -1.090), (0.603, 1.856, -0.411), (-3.062, -0.966, 3.401), (-3.351, 0.430, 0.465), (-2.724, -1.331, 4.299), (3.291, -1.027, 6.699), (-4.263, 0.785, -0.701), (-3.289, -0.886, 3.128), (4.627, 1.331, 2.651), (-0.618, 0.602, 1.486), (0.056, 1.778, -0.528), (4.823, 1.154, 3.103), (-3.983, 0.509, -0.010), (-4.474, -1.400, 3.563), (-3.782, 2.996, -4.883), (4.515, -0.656, 6.569), (1.269, 2.592, -1.549), (-1.710, -0.241, 2.627), (2.171, 1.453, 1.180), (-1.931, -1.845, 5.726), (1.767, -1.798, 7.480), (4.352, 2.369, 0.438), (-4.498, 2.611, -4.472), (0.067, 0.517, 2.000), (4.151, 0.624, 3.827), (0.409, -0.969, 5.142), (0.193, -1.713, 6.522), (-2.487, 2.827, -3.898), (-4.363, 2.011, -3.203), (-2.383, 2.554, -3.299), (-4.457, -0.958, 2.687), (3.342, -0.360, 5.392), (0.902, 2.978, -2.505), (4.073, -1.524, 8.084), (3.036, 1.672, 1.173), (2.169, -0.564, 5.213), (-4.780, 0.962, -1.313), (-1.815, 2.096, -2.100), (-1.445, 0.458, 1.362), (1.891, -1.437, 6.820), (1.942, -1.761, 7.493), (-4.613, -1.551, 3.795), (-3.472, -1.110, 3.485), (-2.026, 1.961, -1.935), (0.091, -0.961, 4.967), (3.902, -1.336, 7.622), (-3.483, -0.769, 2.796), (-0.066, -1.233, 5.433), (2.597, 2.789, -1.280), (-1.657, -1.842, 5.856), (0.232, -1.420, 5.957), (-3.321, 1.609, -1.879), (2.673, 2.781, -1.226), (0.869, 0.072, 3.291), (1.444, -1.271, 6.264), (1.190, 1.460, 0.675), (3.497, 0.870, 3.008), (-2.884, -1.303, 4.163), (3.620, 0.381, 4.047), (2.594, 0.247, 3.803), (-3.902, -1.315, 3.678), (-4.753, -1.005, 2.634), (0.881, 0.675, 2.091), (0.414, 2.071, -0.935), (3.458, -0.920, 6.568), (-2.986, -0.411, 2.329), (3.076, -1.960, 8.458), (2.951, 2.988, -1.501), (2.408, 1.301, 1.603), (4.725, 0.366, 4.631), (4.924, -1.762, 8.985), (3.719, 0.970, 2.920), (-0.295, 0.257, 2.340), (-4.607, 2.548, -4.400), (0.288, 1.953, -0.761), (-3.311, 0.844, -0.344), (3.679, -0.642, 6.123), (-2.310, -0.838, 3.522), (-4.397, -0.226, 1.254), (-4.366, -0.024, 0.864), (2.405, 1.458, 1.286), (-4.296, -1.071, 2.994), (0.452, -1.901, 7.028), (-0.214, -0.467, 3.827), (2.559, 1.547, 1.185), (0.990, 1.539, 0.417), (0.478, -0.089, 3.417), (-2.734, -1.007, 3.646), (3.483, 0.247, 4.247), (3.507, 2.727, -0.70
insert into test.defaults values (-3.273, -1.452, 4.267, 20.0, 40.0), (0.121, -0.615, 4.290, 20.0, 40.0), (-1.099, 2.755, -3.060, 20.0, 40.0), (1.090, 2.945, -2.346, 20.0, 40.0), (0.305, 2.179, -1.205, 20.0, 40.0), (-0.925, 0.702, 1.134, 20.0, 40.0), (3.178, -1.316, 7.221, 20.0, 40.0), (-2.756, -0.473, 2.569, 20.0, 40.0), (3.665, 2.303, 0.226, 20.0, 40.0), (1.662, 1.951, -0.070, 20.0, 40.0), (2.869, 0.593, 3.249, 20.0, 40.0), (0.818, -0.593, 4.594, 20.0, 40.0), (-1.917, 0.916, 0.209, 20.0, 40.0), (2.706, 1.523, 1.307, 20.0, 40.0), (0.219, 2.162, -1.214, 20.0, 40.0), (-4.510, 1.376, -2.007, 20.0, 40.0), (4.284, -0.515, 6.173, 20.0, 40.0), (-1.101, 2.810, -3.170, 20.0, 40.0), (-1.810, -1.117, 4.329, 20.0, 40.0), (0.055, 1.115, 0.797, 20.0, 40.0), (-2.178, 2.904, -3.898, 20.0, 40.0), (-3.494, -1.814, 4.882, 20.0, 40.0), (3.027, 0.476, 3.562, 20.0, 40.0), (-1.434, 1.151, -0.018, 20.0, 40.0), (1.180, 0.992, 1.606, 20.0, 40.0), (0.015, 0.971, 1.067, 20.0, 40.0), (-0.511, -0.875, 4.495, 20.0, 40.0), (0.961, 2.348, -1.216, 20.0, 40.0), (-2.279, 0.038, 1.785, 20.0, 40.0), (-1.568, -0.248, 2.712, 20.0, 40.0), (-0.496, 0.366, 2.020, 20.0, 40.0), (1.177, -1.401, 6.390, 20.0, 40.0), (2.882, -1.442, 7.325, 20.0, 40.0), (-1.066, 1.817, -1.167, 20.0, 40.0), (-2.144, 2.791, -3.655, 20.0, 40.0), (-4.370, 2.228, -3.642, 20.0, 40.0), (3.996, 2.775, -0.553, 20.0, 40.0), (0.289, 2.055, -0.965, 20.0, 40.0), (-0.588, -1.601, 5.908, 20.0, 40.0), (-1.801, 0.417, 1.265, 20.0, 40.0), (4.375, -1.499, 8.186, 20.0, 40.0), (-2.618, 0.038, 1.615, 20.0, 40.0), (3.616, -0.833, 6.475, 20.0, 40.0), (-4.045, -1.558, 4.094, 20.0, 40.0), (-3.962, 0.636, -0.253, 20.0, 40.0), (3.505, 2.625, -0.497, 20.0, 40.0), (3.029, -0.523, 5.560, 20.0, 40.0), (-3.520, -0.474, 2.188, 20.0, 40.0), (2.430, -1.469, 7.154, 20.0, 40.0), (1.547, -1.654, 7.082, 20.0, 40.0), (-1.370, 0.575, 1.165, 20.0, 40.0), (-1.869, -1.555, 5.176, 20.0, 40.0), (3.536, 2.841, -0.913, 20.0, 40.0), (-3.810, 1.220, -1.344, 20.0, 40.0), (-1.971, 1.462, -0.910, 20.0, 40.0), (-0.243, 0.167, 2.545, 20.0, 40.0), (-1.403, 2.645, -2.991, 20.0, 40.0), (0.532, -0.114, 3.494, 20.0, 40.0), (-1.678, 0.975, 0.212, 20.0, 40.0), (-0.656, 2.140, -1.609, 20.0, 40.0), (1.743, 2.631, -1.390, 20.0, 40.0), (2.586, 2.943, -1.593, 20.0, 40.0), (-0.512, 2.969, -3.195, 20.0, 40.0), (2.283, -0.100, 4.342, 20.0, 40.0), (-4.293, 0.872, -0.890, 20.0, 40.0), (3.411, 1.300, 2.106, 20.0, 40.0), (-0.281, 2.951, -3.042, 20.0, 40.0), (-4.442, 0.384, 0.012, 20.0, 40.0), (1.194, 1.746, 0.104, 20.0, 40.0), (-1.152, 1.862, -1.300, 20.0, 40.0), (1.362, -1.341, 6.363, 20.0, 40.0), (-4.488, 2.618, -4.481, 20.0, 40.0), (3.419, -0.564, 5.837, 20.0, 40.0), (-3.392, 0.396, 0.512, 20.0, 40.0), (-1.629, -0.909, 4.003, 20.0, 40.0), (4.447, -1.088, 7.399, 20.0, 40.0), (-1.232, 1.699, -1.014, 20.0, 40.0), (-1.286, -0.609, 3.575, 20.0, 40.0), (2.437, 2.796, -1.374, 20.0, 40.0), (-4.864, 1.989, -3.410, 20.0, 40.0), (-1.716, -1.399, 4.940, 20.0, 40.0), (-3.084, 1.858, -2.259, 20.0, 40.0), (2.828, -0.319, 5.053, 20.0, 40.0), (-1.226, 2.586, -2.786, 20.0, 40.0), (2.456, 0.092, 4.044, 20.0, 40.0), (-0.989, 2.375, -2.245, 20.0, 40.0), (3.268, 0.935, 2.765, 20.0, 40.0), (-4.128, -1.995, 4.927, 20.0, 40.0), (-1.083, 2.197, -1.935, 20.0, 40.0), (-3.471, -1.198, 3.660, 20.0, 40.0), (4.617, -1.136, 7.579, 20.0, 40.0), (2.054, -1.675, 7.378, 20.0, 40.0), (4.106, 2.326, 0.402, 20.0, 40.0), (1.558, 0.310, 3.158, 20.0, 40.0), (0.792, 0.900, 1.596, 20.0, 40.0), (-3.229, 0.300, 0.785, 20.0, 40.0), (3.787, -0.793, 6.479, 20.0, 40.0), (1.786, 2.288, -0.684, 20.0, 40.0), (2.643, 0.223, 3.875, 20.0, 40.0), (-3.592, 2.122, -3.040, 20.0, 40.0), (4.519, -1.760, 8.779, 20.0, 40.0), (3.221, 2.255, 0.101, 20.0, 40.0), (4.151, 1.788, 1.500, 20.0, 40.0), (-1.033, -1.195, 4.874, 20.0, 40.0), (-1.636, -1.037, 4.257, 20.0, 40.0), (-3.548, 1.911, -2.596, 20.0, 40.0), (4.829, -0.293, 6.001, 20.0, 40.0), (-4.684, -1.664, 3.986, 20.0, 40.0), (4.531, -0.503, 6.271, 20.0, 40.0), (-3.503, -1.606, 4.460, 20.0, 40.0), (-2.036, -1.522, 5.027, 20.0, 40.0), (-0.473, -0.617, 3.997, 20.0, 40.0),
-- insert into test.defaults values (-3.273, -1.452, 4.267, 20.0, 40.0), (0.121, -0.615, 4.290, 20.0, 40.0), (-1.099, 2.755, -3.060, 20.0, 40.0), (1.090, 2.945, -2.346, 20.0, 40.0), (0.305, 2.179, -1.205, 20.0, 40.0), (-0.925, 0.702, 1.134, 20.0, 40.0), (3.178, -1.316, 7.221, 20.0, 40.0), (-2.756, -0.473, 2.569, 20.0, 40.0), (3.665, 2.303, 0.226, 20.0, 40.0), (1.662, 1.951, -0.070, 20.0, 40.0), (2.869, 0.593, 3.249, 20.0, 40.0), (0.818, -0.593, 4.594, 20.0, 40.0), (-1.917, 0.916, 0.209, 20.0, 40.0), (2.706, 1.523, 1.307, 20.0, 40.0), (0.219, 2.162, -1.214, 20.0, 40.0), (-4.510, 1.376, -2.007, 20.0, 40.0), (4.284, -0.515, 6.173, 20.0, 40.0), (-1.101, 2.810, -3.170, 20.0, 40.0), (-1.810, -1.117, 4.329, 20.0, 40.0), (0.055, 1.115, 0.797, 20.0, 40.0), (-2.178, 2.904, -3.898, 20.0, 40.0), (-3.494, -1.814, 4.882, 20.0, 40.0), (3.027, 0.476, 3.562, 20.0, 40.0), (-1.434, 1.151, -0.018, 20.0, 40.0), (1.180, 0.992, 1.606, 20.0, 40.0), (0.015, 0.971, 1.067, 20.0, 40.0), (-0.511, -0.875, 4.495, 20.0, 40.0), (0.961, 2.348, -1.216, 20.0, 40.0), (-2.279, 0.038, 1.785, 20.0, 40.0), (-1.568, -0.248, 2.712, 20.0, 40.0), (-0.496, 0.366, 2.020, 20.0, 40.0), (1.177, -1.401, 6.390, 20.0, 40.0), (2.882, -1.442, 7.325, 20.0, 40.0), (-1.066, 1.817, -1.167, 20.0, 40.0), (-2.144, 2.791, -3.655, 20.0, 40.0), (-4.370, 2.228, -3.642, 20.0, 40.0), (3.996, 2.775, -0.553, 20.0, 40.0), (0.289, 2.055, -0.965, 20.0, 40.0), (-0.588, -1.601, 5.908, 20.0, 40.0), (-1.801, 0.417, 1.265, 20.0, 40.0), (4.375, -1.499, 8.186, 20.0, 40.0), (-2.618, 0.038, 1.615, 20.0, 40.0), (3.616, -0.833, 6.475, 20.0, 40.0), (-4.045, -1.558, 4.094, 20.0, 40.0), (-3.962, 0.636, -0.253, 20.0, 40.0), (3.505, 2.625, -0.497, 20.0, 40.0), (3.029, -0.523, 5.560, 20.0, 40.0), (-3.520, -0.474, 2.188, 20.0, 40.0), (2.430, -1.469, 7.154, 20.0, 40.0), (1.547, -1.654, 7.082, 20.0, 40.0), (-1.370, 0.575, 1.165, 20.0, 40.0), (-1.869, -1.555, 5.176, 20.0, 40.0), (3.536, 2.841, -0.913, 20.0, 40.0), (-3.810, 1.220, -1.344, 20.0, 40.0), (-1.971, 1.462, -0.910, 20.0, 40.0), (-0.243, 0.167, 2.545, 20.0, 40.0), (-1.403, 2.645, -2.991, 20.0, 40.0), (0.532, -0.114, 3.494, 20.0, 40.0), (-1.678, 0.975, 0.212, 20.0, 40.0), (-0.656, 2.140, -1.609, 20.0, 40.0), (1.743, 2.631, -1.390, 20.0, 40.0), (2.586, 2.943, -1.593, 20.0, 40.0), (-0.512, 2.969, -3.195, 20.0, 40.0), (2.283, -0.100, 4.342, 20.0, 40.0), (-4.293, 0.872, -0.890, 20.0, 40.0), (3.411, 1.300, 2.106, 20.0, 40.0), (-0.281, 2.951, -3.042, 20.0, 40.0), (-4.442, 0.384, 0.012, 20.0, 40.0), (1.194, 1.746, 0.104, 20.0, 40.0), (-1.152, 1.862, -1.300, 20.0, 40.0), (1.362, -1.341, 6.363, 20.0, 40.0), (-4.488, 2.618, -4.481, 20.0, 40.0), (3.419, -0.564, 5.837, 20.0, 40.0), (-3.392, 0.396, 0.512, 20.0, 40.0), (-1.629, -0.909, 4.003, 20.0, 40.0), (4.447, -1.088, 7.399, 20.0, 40.0), (-1.232, 1.699, -1.014, 20.0, 40.0), (-1.286, -0.609, 3.575, 20.0, 40.0), (2.437, 2.796, -1.374, 20.0, 40.0), (-4.864, 1.989, -3.410, 20.0, 40.0), (-1.716, -1.399, 4.940, 20.0, 40.0), (-3.084, 1.858, -2.259, 20.0, 40.0), (2.828, -0.319, 5.053, 20.0, 40.0), (-1.226, 2.586, -2.786, 20.0, 40.0), (2.456, 0.092, 4.044, 20.0, 40.0), (-0.989, 2.375, -2.245, 20.0, 40.0), (3.268, 0.935, 2.765, 20.0, 40.0), (-4.128, -1.995, 4.927, 20.0, 40.0), (-1.083, 2.197, -1.935, 20.0, 40.0), (-3.471, -1.198, 3.660, 20.0, 40.0), (4.617, -1.136, 7.579, 20.0, 40.0), (2.054, -1.675, 7.378, 20.0, 40.0), (4.106, 2.326, 0.402, 20.0, 40.0), (1.558, 0.310, 3.158, 20.0, 40.0), (0.792, 0.900, 1.596, 20.0, 40.0), (-3.229, 0.300, 0.785, 20.0, 40.0), (3.787, -0.793, 6.479, 20.0, 40.0), (1.786, 2.288, -0.684, 20.0, 40.0), (2.643, 0.223, 3.875, 20.0, 40.0), (-3.592, 2.122, -3.040, 20.0, 40.0), (4.519, -1.760, 8.779, 20.0, 40.0), (3.221, 2.255, 0.101, 20.0, 40.0), (4.151, 1.788, 1.500, 20.0, 40.0), (-1.033, -1.195, 4.874, 20.0, 40.0), (-1.636, -1.037, 4.257, 20.0, 40.0), (-3.548, 1.911, -2.596, 20.0, 40.0), (4.829, -0.293, 6.001, 20.0, 40.0), (-4.684, -1.664, 3.986, 20.0, 40.0), (4.531, -0.503, 6.271, 20.0, 40.0), (-3.503, -1.606, 4.460, 20.0, 40.0), (-2.036, -1.522, 5.027, 20.0, 40.0), (-0.473, -0.617, 3.997, 20.0, 40.0
--
DROP TABLE IF EXISTS test.model;
create table test.model engine = Memory as select LinearRegressionState(0.01)(target, param1, param2) as state from test.defaults;
-- -- select toTypeName(state) from test.model;
-- --
-- -- DROP TABLE IF EXISTS test.tests;
-- -- CREATE TABLE IF NOT EXISTS test.tests
-- -- (
-- -- predict1 Float64,
-- -- predict2 Float64,
-- -- state1 AggregateFunction(LinReg(0.01), Float64, Float64, Float64)
-- -- ) ENGINE = Memory;
-- -- insert into test.tests select 20.0, 40.0, LinRegState(0.01)(target, param1, param2) from test.defaults;
-- -- select evalLinReg(state1, predict1, predict2) from test.tests;
--
--
--
-- -- DROP TABLE IF EXISTS test.prediction;
-- -- CREATE TABLE IF NOT EXISTS test.prediction
-- -- (
-- -- predict1 Float64,
-- -- predict2 Float64
-- -- ) ENGINE = Memory;
--
--
-- -- insert into test.prediction values (20.0, 40.0);
--
-- -- select multiply(param1, param2) from test.defaults;
--
-- -- select evalLinReg(LinRegState(0.01)(target, param1, param2), 20.0, 40.0) from test.defaults;
select evalMLMethod(state, predict1, predict2) from test.model cross join test.defaults;
-- -- select evalLinReg(state, predict1, predict2) from test.model inner join (select * from test.tests) using state;
-- -- select evalLinReg(state1, predict1, predict2) from test.tests;
--
-- -- select negate(target) from test.defaults;