Ticket #648: computeCD_good.patch

File computeCD_good.patch, 12.8 KB (added by gw.orange@…, 4 years ago)

Popravljena in pomoje najboljsa resitev s po 100 hardcodeanimi vrednostmi in aprokcimacijo za visje.

  • orange/orngStat.py

     
    18171817    return (f, k-1), (im, fdistdof) 
    18181818 
    18191819def compute_CD(avranks, N, alpha="0.05", type="nemenyi"): 
     1820    """Compute critical difference for Nemenyi or Bonferroni-Dunn test for average ranks. 
     1821 
     1822    Tables for 100 `q` values were precalculated using R function `qtukey()` with: 
     1823        qtukey(1 - alpha, 2:100, Inf) / sqrt(2) 
     1824        qtukey(1 - (alpha / 2:100), 2, Inf) / sqrt(2) 
     1825     
     1826    :param N: number of tested data sets 
     1827    :param alpha: alpha value for chosen test ("0.001", "0.01", "0.02", "0.05" or "0.1") 
     1828    :param type: chosen critical difference test type ("nemenyi" for Nemenyi two 
     1829        tailed test or bonferroni-dunn" for Bonferroni-Dunn test) 
     1830    :return: critical difference value 
    18201831    """ 
    1821     if type == "nemenyi": 
    1822         critical difference for Nemenyi two tailed test. 
    1823     if type == "bonferroni-dunn": 
    1824         critical difference for Bonferroni-Dunn test 
    1825     """ 
    1826  
     1832    d = { 
     1833        ("nemenyi", "0.001"): [ 
     1834            0, 0, 3.290527, 3.580402, 3.753891, 3.877599, 3.973468, 4.051548, 4.117291, 4.173985, 4.223766, 4.268097, 4.308025, 4.344324, 4.377582, 4.408256, 4.436707, 4.463228, 4.488057, 4.511391, 4.533394, 
     1835            4.554207, 4.573947, 4.592717, 4.610606, 4.627689, 4.644034, 4.659701, 4.674742, 4.689204, 4.703129, 4.716553, 4.729510, 4.742032, 4.754145, 4.765875, 4.777244, 4.788274, 4.798983, 4.809389, 4.819508, 
     1836            4.829356, 4.838945, 4.848289, 4.857400, 4.866289, 4.874965, 4.883440, 4.891721, 4.899816, 4.907735, 4.915483, 4.923069, 4.930499, 4.937778, 4.944912, 4.951908, 4.958770, 4.965503, 4.972112, 4.978601, 
     1837            4.984973, 4.991235, 4.997388, 5.003436, 5.009383, 5.015233, 5.020988, 5.026650, 5.032224, 5.037712, 5.043115, 5.048437, 5.053681, 5.058847, 5.063939, 5.068958, 5.073907, 5.078787, 5.083600, 5.088348, 
     1838            5.093032, 5.097655, 5.102218, 5.106722, 5.111169, 5.115560, 5.119896, 5.124179, 5.128411, 5.132591, 5.136722, 5.140805, 5.144840, 5.148829, 5.152773, 5.156672, 5.160528, 5.164342, 5.168114, 5.171845, 
     1839        ], 
     1840        ("nemenyi", "0.01"): [ 
     1841            0, 0, 2.575829, 2.913494, 3.113250, 3.254686, 3.363740, 3.452213, 3.526471, 3.590339, 3.646292, 3.696021, 3.740733, 3.781318, 3.818451, 3.852654, 3.884343, 3.913850, 3.941446, 3.967357, 3.991770, 
     1842            4.014842, 4.036710, 4.057487, 4.077275, 4.096161, 4.114220, 4.131519, 4.148118, 4.164069, 4.179420, 4.194212, 4.208484, 4.222269, 4.235598, 4.248501, 4.261002, 4.273125, 4.284891, 4.296320, 4.307430, 
     1843            4.318238, 4.328760, 4.339009, 4.349000, 4.358743, 4.368252, 4.377536, 4.386606, 4.395470, 4.404139, 4.412619, 4.420919, 4.429046, 4.437006, 4.444807, 4.452455, 4.459954, 4.467311, 4.474530, 4.481617, 
     1844            4.488576, 4.495412, 4.502128, 4.508729, 4.515219, 4.521600, 4.527877, 4.534052, 4.540130, 4.546112, 4.552002, 4.557802, 4.563515, 4.569144, 4.574690, 4.580157, 4.585546, 4.590859, 4.596099, 4.601268, 
     1845            4.606366, 4.611397, 4.616481, 4.621261, 4.626098, 4.630874, 4.635590, 4.640247, 4.644847, 4.649392, 4.653882, 4.658319, 4.662704, 4.667038, 4.671322, 4.675558, 4.679747, 4.683889, 4.687985, 4.692037, 
     1846        ], 
     1847        ("nemenyi", "0.02"): [ 
     1848            0, 0, 2.326348, 2.682329, 2.892169, 3.040408, 3.154516, 3.246966, 3.324478, 3.391084, 3.449389, 3.501174, 3.547705, 3.589917, 3.628519, 3.664061, 3.696975, 3.727610, 3.756253, 3.783136, 3.808458, 
     1849            3.832382, 3.855051, 3.876584, 3.897087, 3.916650, 3.935352, 3.953264, 3.970448, 3.986957, 4.002843, 4.018147, 4.032911, 4.047169, 4.060953, 4.074294, 4.087218, 4.099749, 4.111910, 4.123721, 4.135201, 
     1850            4.146368, 4.157237, 4.167823, 4.178141, 4.188203, 4.198022, 4.207607, 4.216970, 4.226121, 4.235068, 4.243820, 4.252385, 4.260771, 4.268985, 4.277033, 4.284922, 4.292658, 4.300246, 4.307692, 4.315001, 
     1851            4.322177, 4.329226, 4.336151, 4.342956, 4.349646, 4.356225, 4.362695, 4.369060, 4.375324, 4.381489, 4.387559, 4.393536, 4.399423, 4.405222, 4.410937, 4.416569, 4.422120, 4.427594, 4.432991, 4.438314, 
     1852            4.443566, 4.448747, 4.453859, 4.458905, 4.463886, 4.468804, 4.473659, 4.478455, 4.483191, 4.487869, 4.492492, 4.497060, 4.501574, 4.506034, 4.510444, 4.514804, 4.519115, 4.523377, 4.527593, 4.531763, 
     1853        ], 
     1854        ("nemenyi", "0.05"): [ 
     1855            0, 0, 1.959964, 2.343701, 2.569032, 2.727774, 2.849705, 2.948320, 3.030879, 3.101730, 3.163684, 3.218654, 3.268004, 3.312739, 3.353618, 3.391230, 3.426041, 3.458425, 3.488685, 3.517073, 3.543799, 
     1856            3.569040, 3.592946, 3.615646, 3.637252, 3.657861, 3.677556, 3.696413, 3.714498, 3.731869, 3.748578, 3.764672, 3.780193, 3.795179, 3.809664, 3.823680, 3.837254, 3.850413, 3.863181, 3.875579, 3.887627, 
     1857            3.899345, 3.910748, 3.921852, 3.932673, 3.943224, 3.953518, 3.963566, 3.973379, 3.982969, 3.992343, 4.001513, 4.010485, 4.019268, 4.027870, 4.036297, 4.044556, 4.052654, 4.060597, 4.068390, 4.076038, 
     1858            4.083547, 4.090921, 4.098166, 4.105284, 4.112282, 4.119161, 4.125927, 4.132583, 4.139131, 4.145576, 4.151921, 4.158168, 4.164321, 4.170381, 4.176352, 4.182237, 4.188037, 4.193755, 4.199393, 4.204953, 
     1859            4.210437, 4.215848, 4.221187, 4.226456, 4.231657, 4.236791, 4.241860, 4.246865, 4.251809, 4.256692, 4.261516, 4.266283, 4.270993, 4.275648, 4.280249, 4.284798, 4.289295, 4.293742, 4.298139, 4.302489, 
     1860        ], 
     1861        ("nemenyi", "0.1"): [ 
     1862            0, 0, 1.644854, 2.052293, 2.291341, 2.459516, 2.588521, 2.692732, 2.779884, 2.854606, 2.919889, 2.977768, 3.029694, 3.076733, 3.119693, 3.159199, 3.195743, 3.229723, 3.261461, 3.291224, 3.319233, 
     1863            3.345676, 3.370712, 3.394477, 3.417089, 3.438651, 3.459253, 3.478971, 3.497878, 3.516033, 3.533492, 3.550305, 3.566516, 3.582165, 3.597288, 3.611917, 3.626084, 3.639814, 3.653134, 3.666066, 3.678631, 
     1864            3.690848, 3.702736, 3.714312, 3.725590, 3.736584, 3.747310, 3.757778, 3.768000, 3.777987, 3.787750, 3.797297, 3.806638, 3.815781, 3.824735, 3.833505, 3.842101, 3.850527, 3.858791, 3.866898, 3.874853, 
     1865            3.882664, 3.890333, 3.897866, 3.905269, 3.912544, 3.919696, 3.926729, 3.933647, 3.940453, 3.947151, 3.953745, 3.960236, 3.966628, 3.972925, 3.979128, 3.985240, 3.991265, 3.997204, 4.003059, 4.008833, 
     1866            4.014528, 4.020146, 4.025690, 4.031160, 4.036558, 4.041888, 4.047149, 4.052345, 4.057475, 4.062543, 4.067549, 4.072496, 4.077383, 4.082213, 4.086987, 4.091705, 4.096371, 4.100983, 4.105545, 4.110056, 
     1867        ], 
     1868        ("bonferroni-dunn", "0.001"): [ 
     1869            0, 0, 3.290527, 3.480756, 3.587915, 3.662260, 3.719016, 3.764824, 3.803168, 3.836107, 3.864952, 3.890592, 3.913656, 3.934606, 3.953790, 3.971476, 3.987879, 4.003168, 4.017481, 4.030934, 4.043623, 
     1870            4.055627, 4.067016, 4.077848, 4.088174, 4.098038, 4.107480, 4.116532, 4.125226, 4.133588, 4.141642, 4.149410, 4.156910, 4.164161, 4.171177, 4.177974, 4.184564, 4.190959, 4.197171, 4.203209, 4.209082, 
     1871            4.214800, 4.220369, 4.225798, 4.231093, 4.236261, 4.241307, 4.246236, 4.251055, 4.255767, 4.260378, 4.264891, 4.269310, 4.273640, 4.277883, 4.282043, 4.286123, 4.290126, 4.294056, 4.297913, 4.301702, 
     1872            4.305423, 4.309081, 4.312676, 4.316211, 4.319688, 4.323108, 4.326474, 4.329787, 4.333048, 4.336260, 4.339423, 4.342540, 4.345610, 4.348637, 4.351620, 4.354562, 4.357463, 4.360324, 4.363146, 4.365931, 
     1873            4.368680, 4.371392, 4.374070, 4.376714, 4.379325, 4.381903, 4.384450, 4.386966, 4.389453, 4.391909, 4.394337, 4.396737, 4.399110, 4.401456, 4.403776, 4.406070, 4.408338, 4.410583, 4.412803, 4.415000, 
     1874        ], 
     1875        ("bonferroni-dunn", "0.01"): [ 
     1876            0, 0, 2.575829, 2.807034, 2.935199, 3.023341, 3.090232, 3.143980, 3.188815, 3.227218, 3.260767, 3.290527, 3.317247, 3.341479, 3.363635, 3.384036, 3.402933, 3.420527, 3.436982, 3.452433, 3.466993, 
     1877            3.480756, 3.493804, 3.506205, 3.518018, 3.529296, 3.540084, 3.550421, 3.560343, 3.569881, 3.579064, 3.587915, 3.596457, 3.604711, 3.612696, 3.620427, 3.627919, 3.635188, 3.642245, 3.649103, 3.655771, 
     1878            3.662260, 3.668579, 3.674736, 3.680740, 3.686597, 3.692315, 3.697899, 3.703356, 3.708691, 3.713910, 3.719016, 3.724016, 3.728913, 3.733711, 3.738413, 3.743025, 3.747548, 3.751987, 3.756344, 3.760622, 
     1879            3.764824, 3.768952, 3.773009, 3.776998, 3.780920, 3.784777, 3.788573, 3.792308, 3.795984, 3.799604, 3.803168, 3.806680, 3.810139, 3.813547, 3.816907, 3.820219, 3.823484, 3.826705, 3.829881, 3.833015, 
     1880            3.836107, 3.839158, 3.842170, 3.845143, 3.848079, 3.850978, 3.853841, 3.856669, 3.859463, 3.862224, 3.864952, 3.867648, 3.870313, 3.872948, 3.875553, 3.878128, 3.880676, 3.883195, 3.885687, 3.888153, 
     1881        ], 
     1882        ("bonferroni-dunn", "0.02"): [ 
     1883            0, 0, 2.326348, 2.575829, 2.713052, 2.807034, 2.878162, 2.935199, 2.982704, 3.023341, 3.058804, 3.090232, 3.118429, 3.143980, 3.167329, 3.188815, 3.208707, 3.227218, 3.244524, 3.260767, 3.276068, 
     1884            3.290527, 3.304229, 3.317247, 3.329646, 3.341479, 3.352795, 3.363635, 3.374038, 3.384036, 3.393659, 3.402933, 3.411881, 3.420527, 3.428887, 3.436982, 3.444825, 3.452433, 3.459818, 3.466993, 3.473969, 
     1885            3.480756, 3.487365, 3.493804, 3.500081, 3.506205, 3.512181, 3.518018, 3.523721, 3.529296, 3.534749, 3.540084, 3.545306, 3.550421, 3.555432, 3.560343, 3.565158, 3.569881, 3.574515, 3.579064, 3.583529, 
     1886            3.587915, 3.592223, 3.596457, 3.600619, 3.604711, 3.608736, 3.612696, 3.616592, 3.620427, 3.624202, 3.627919, 3.631581, 3.635188, 3.638742, 3.642245, 3.645698, 3.649103, 3.652460, 3.655771, 3.659037, 
     1887            3.662260, 3.665440, 3.668579, 3.671677, 3.674736, 3.677757, 3.680740, 3.683686, 3.686597, 3.689473, 3.692315, 3.695123, 3.697899, 3.700643, 3.703356, 3.706038, 3.708691, 3.711315, 3.713910, 3.716477, 
     1888        ], 
     1889        ("bonferroni-dunn", "0.05"): [ 
     1890            0, 0, 1.959964, 2.241403, 2.393980, 2.497705, 2.575829, 2.638257, 2.690110, 2.734369, 2.772921, 2.807034, 2.837597, 2.865260, 2.890512, 2.913726, 2.935199, 2.955167, 2.973820, 2.991316, 3.007787, 
     1891            3.023341, 3.038074, 3.052065, 3.065383, 3.078088, 3.090232, 3.101862, 3.113017, 3.123735, 3.134046, 3.143980, 3.153563, 3.162818, 3.171766, 3.180426, 3.188815, 3.196950, 3.204845, 3.212514, 3.219968, 
     1892            3.227218, 3.234277, 3.241152, 3.247854, 3.254389, 3.260767, 3.266995, 3.273078, 3.279024, 3.284839, 3.290527, 3.296094, 3.301545, 3.306885, 3.312118, 3.317247, 3.322278, 3.327213, 3.332056, 3.336810, 
     1893            3.341479, 3.346065, 3.350571, 3.354999, 3.359353, 3.363635, 3.367847, 3.371991, 3.376069, 3.380083, 3.384036, 3.387929, 3.391763, 3.395541, 3.399263, 3.402933, 3.406550, 3.410117, 3.413634, 3.417104, 
     1894            3.420527, 3.423904, 3.427237, 3.430527, 3.433775, 3.436982, 3.440148, 3.443276, 3.446365, 3.449417, 3.452433, 3.455413, 3.458358, 3.461269, 3.464147, 3.466993, 3.469806, 3.472589, 3.475341, 3.478063, 
     1895        ], 
     1896        ("bonferroni-dunn", "0.1"): [ 
     1897            0, 0, 1.644854, 1.959964, 2.128045, 2.241403, 2.326348, 2.393980, 2.449998, 2.497705, 2.539185, 2.575829, 2.608616, 2.638257, 2.665285, 2.690110, 2.713052, 2.734369, 2.754268, 2.772921, 2.790470, 
     1898            2.807034, 2.822714, 2.837597, 2.851757, 2.865260, 2.878162, 2.890512, 2.902353, 2.913726, 2.924665, 2.935199, 2.945359, 2.955167, 2.964647, 2.973820, 2.982704, 2.991316, 2.999672, 3.007787, 3.015672, 
     1899            3.023341, 3.030805, 3.038074, 3.045158, 3.052065, 3.058804, 3.065383, 3.071809, 3.078088, 3.084227, 3.090232, 3.096109, 3.101862, 3.107496, 3.113017, 3.118429, 3.123735, 3.128939, 3.134046, 3.139059, 
     1900            3.143980, 3.148814, 3.153563, 3.158230, 3.162818, 3.167329, 3.171766, 3.176131, 3.180426, 3.184653, 3.188815, 3.192914, 3.196950, 3.200927, 3.204845, 3.208707, 3.212514, 3.216267, 3.219968, 3.223618, 
     1901            3.227218, 3.230771, 3.234277, 3.237737, 3.241152, 3.244524, 3.247854, 3.251142, 3.254389, 3.257598, 3.260767, 3.263900, 3.266995, 3.270054, 3.273078, 3.276068, 3.279024, 3.281948, 3.284839, 3.287698, 
     1902        ] 
     1903    } 
     1904    q = d[(type, alpha)] 
     1905     
    18271906    k = len(avranks) 
    1828     
    1829     d = {} 
     1907    if k > len(q): 
     1908        qk = q[-1] + (k - len(q)) * 0.0045  # linear aproximation for higher values 
     1909    else: 
     1910        qk = q[k] 
    18301911 
    1831     d[("nemenyi", "0.05")] = [0, 0, 1.960, 2.343, 2.568, 2.728, 2.850, 2.949, 3.031, 3.102, 3.164 ] 
    1832     d[("nemenyi", "0.1")] = [0, 0, 1.645, 2.052, 2.291, 2.459, 2.589, 2.693, 2.780, 2.855, 2.920 ]     
    1833     d[("bonferroni-dunn", "0.05")] =  [0, 0, 1.960, 2.241, 2.394, 2.498, 2.576, 2.638, 2.690, 2.724, 2.773 ] 
    1834     d[("bonferroni-dunn", "0.1")] = [0, 0, 1.645, 1.960, 2.128, 2.241, 2.326, 2.394, 2.450, 2.498, 2.539 ] 
    1835  
    1836     q = d[(type, alpha)] 
    1837  
    1838     cd = q[k]*(k*(k+1)/(6.0*N))**0.5 
    1839  
     1912    cd = qk*(k*(k+1)/(6.0*N))**0.5 
    18401913    return cd 
    1841   
    18421914 
    18431915def graph_ranks(filename, avranks, names, cd=None, cdmethod=None, lowv=None, highv=None, width=6, textspace=1, reverse=False, **kwargs): 
    18441916    """