├── .ipynb_checkpoints └── Untitled (1)-checkpoint.ipynb ├── Untitled (1).ipynb ├── done.txt ├── empty.txt ├── failed.txt ├── question_new.json ├── questions.json ├── readme.md └── src ├── GMM ├── GMM.ipynb ├── GMM.py ├── data │ ├── EmuSamples.mat │ ├── Samples.mat │ ├── Test1.csv │ ├── Test2.csv │ ├── TestLabels.csv │ ├── TestSamples.csv │ ├── Train1.csv │ ├── Train2.csv │ ├── TrainLabels.csv │ └── TrainSamples.csv ├── data_helper.py ├── pictures │ └── mnist_res.png └── readme.md ├── LMSE ├── data │ ├── Samples.mat │ ├── TestLabels.csv │ ├── TestSamples.csv │ ├── TrainLabels.csv │ └── TrainSamples.csv ├── data_helper.py ├── lsme.py ├── pictures │ └── lsme_res.png └── readme.md ├── common_functions ├── activation_functions.py └── loss_functions.py ├── k-means ├── data │ ├── ClusterSamples.csv │ ├── SampleLabels.csv │ └── iris.data ├── data_helper.py ├── kMeans.py ├── pictures │ ├── mnist.png │ └── sample.png └── readme.md ├── knn ├── data │ ├── ClusterSamples.csv │ ├── SampleLabels.csv │ └── iris.data ├── data_helper.py ├── filels │ └── myplot.jpg ├── knn.py ├── readme.md └── test_kMenas.py ├── mnist_classify ├── GMM.py ├── KNN.py ├── NB.py ├── SVM.py ├── best_result │ └── DNN+BN0.992 │ │ ├── acc.png │ │ ├── best_model.pkl │ │ └── loss.png ├── data │ ├── TrainLabels.csv │ ├── TrainSamples.csv │ ├── test_data │ │ ├── Result.csv │ │ └── TestSamples.csv │ ├── train_data │ │ ├── TrainLabels │ │ └── TrainSamples │ └── valid_data │ │ ├── ValidLabels │ │ └── ValidSamples ├── dataHelper.py ├── main.py ├── models.py ├── myutils.py ├── plot_result.py ├── readme.md └── result │ ├── acc.png │ ├── acc_dict.pkl │ ├── best_model.pkl │ ├── loss.png │ └── loss_dict.pkl └── perceptron ├── data ├── Samples.mat ├── TestLabels.csv ├── TestSamples.csv ├── TrainLabels.csv └── TrainSamples.csv ├── data_helper.py ├── perceptron.py ├── pictures ├── perceptron_batch.png ├── perceptron_rule.png └── perceptron_single.png └── readme.md /.ipynb_checkpoints/Untitled (1)-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 7, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import json" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 8, 15 | "metadata": { 16 | "scrolled": true 17 | }, 18 | "outputs": [ 19 | { 20 | "name": "stdout", 21 | "output_type": "stream", 22 | "text": [ 23 | "Finished: []\n" 24 | ] 25 | }, 26 | { 27 | "ename": "UnicodeDecodeError", 28 | "evalue": "'ascii' codec can't decode byte 0xe8 in position 14: ordinal not in range(128)", 29 | "output_type": "error", 30 | "traceback": [ 31 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 32 | "\u001b[0;31mUnicodeDecodeError\u001b[0m Traceback (most recent call last)", 33 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'questions.json'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mfin\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'question_new.json'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'a'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mfout\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 15\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mline\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mfin\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 16\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mjson\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mloads\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstrip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 17\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'pid'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstart_id\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mend_id\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'pid'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mdone_cached\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 34 | "\u001b[0;32m~/anaconda3/lib/python3.6/encodings/ascii.py\u001b[0m in \u001b[0;36mdecode\u001b[0;34m(self, input, final)\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0;32mclass\u001b[0m \u001b[0mIncrementalDecoder\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcodecs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mIncrementalDecoder\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mdecode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfinal\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mcodecs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mascii_decode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0merrors\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;32mclass\u001b[0m \u001b[0mStreamWriter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mCodec\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mcodecs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mStreamWriter\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 35 | "\u001b[0;31mUnicodeDecodeError\u001b[0m: 'ascii' codec can't decode byte 0xe8 in position 14: ordinal not in range(128)" 36 | ] 37 | } 38 | ], 39 | "source": [ 40 | "done_cached = []\n", 41 | "with open('done.txt') as f:\n", 42 | " for line in f:\n", 43 | " done_cached.append(line.strip())\n", 44 | "print('Finished:', done_cached)\n", 45 | "\n", 46 | "done = open('done.txt', 'a', buffering=1) # 记录成功填写的数据ID\n", 47 | "failed = open('failed.txt', 'w', buffering=1) # 记录填写事变的数据ID\n", 48 | "empty = open('empty.txt', 'w', buffering=1) # 记录答案为空的数据ID\n", 49 | "\n", 50 | "start_id = 12001\n", 51 | "end_id = 13500\n", 52 | "try:\n", 53 | " with open('questions.json') as fin, open('question_new.json', 'a') as fout:\n", 54 | " for line in fin:\n", 55 | " data = json.loads(line.strip())\n", 56 | " if data['pid'] in range(start_id, end_id+1) and str(data['pid']) not in done_cached:\n", 57 | " print('ID : %d\\nQuestion : %s'%(data['pid'], data['question']))\n", 58 | " for idx, s in enumerate(data['answer_sentence']):\n", 59 | " print('Sentence %d : %s\\n' % (idx, s))\n", 60 | " answer = input()\n", 61 | " if answer == '':\n", 62 | " empty.write(str(data['pid'])+'\\n')\n", 63 | " print('Empty answer!\\n')\n", 64 | " else:\n", 65 | " data['answer'] = answer\n", 66 | " try:\n", 67 | " fout.write(json.dumps(data, ensure_ascii=False)+'\\n')\n", 68 | " print('Done with answer:%s, ID:%s\\n' % (answer, data['pid']))\n", 69 | " done.write(str(data['pid'])+'\\n')\n", 70 | " except Exception as e:\n", 71 | " print(e)\n", 72 | " failed.write(str(data['pid'])+'\\n')\n", 73 | "except KeyboardInterrupt:\n", 74 | " done.close()\n", 75 | " failed.close()\n", 76 | " empty.close()" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": null, 82 | "metadata": {}, 83 | "outputs": [], 84 | "source": [ 85 | "answer = input()\n", 86 | "print(type(answer), answer)" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": null, 92 | "metadata": {}, 93 | "outputs": [], 94 | "source": [ 95 | "file = 'done.txt'\n", 96 | "with open(file) as fin:\n", 97 | " print(fin.read())" 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": null, 103 | "metadata": {}, 104 | "outputs": [], 105 | "source": [ 106 | "done_cached" 107 | ] 108 | }, 109 | { 110 | "cell_type": "code", 111 | "execution_count": null, 112 | "metadata": {}, 113 | "outputs": [], 114 | "source": [] 115 | } 116 | ], 117 | "metadata": { 118 | "kernelspec": { 119 | "display_name": "Python 3", 120 | "language": "python", 121 | "name": "python3" 122 | }, 123 | "language_info": { 124 | "codemirror_mode": { 125 | "name": "ipython", 126 | "version": 3 127 | }, 128 | "file_extension": ".py", 129 | "mimetype": "text/x-python", 130 | "name": "python", 131 | "nbconvert_exporter": "python", 132 | "pygments_lexer": "ipython3", 133 | "version": "3.6.4" 134 | } 135 | }, 136 | "nbformat": 4, 137 | "nbformat_minor": 2 138 | } 139 | -------------------------------------------------------------------------------- /Untitled (1).ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 9, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "U: \n[[-0.50808988 0.75840491 0.40824829]\n [-0.57477696 0.05444977 -0.81649658]\n [-0.64146404 -0.64950536 0.40824829]]\nnew X: \n[[-4.66490277 -0.26835694 2.04124145]\n [-4.22349998 -1.73071699 2.85773803]\n [-5.10630557 1.19400311 1.22474487]\n [-4.86496402 -2.38022235 3.26598632]\n [-4.46484153 1.84350847 0.81649658]]\na: \n[-4.66490277 -0.26835694 2.04124145]\n5.099019513592785\n" 13 | ] 14 | } 15 | ], 16 | "source": [ 17 | "import numpy as np\n", 18 | "import numpy.linalg as lg\n", 19 | "\n", 20 | "X = np.array([\n", 21 | " [3, 1, 4],\n", 22 | " [2, 0, 5],\n", 23 | " [4, 2, 3],\n", 24 | " [2, 0, 6],\n", 25 | " [4, 2, 2]\n", 26 | "])\n", 27 | "A = np.array([\n", 28 | " [2, 0, 1, 7],\n", 29 | " [2, 0, 1, 8],\n", 30 | " [2, 0, 1, 9]\n", 31 | "])\n", 32 | "U, _, _ = lg.svd(A)\n", 33 | "print(\"U: \")\n", 34 | "print(U)\n", 35 | "new_X = X.dot(U)\n", 36 | "print(\"new X: \")\n", 37 | "print(new_X)\n", 38 | "print(\"a: \")\n", 39 | "a = np.mean(new_X, 0)\n", 40 | "print(a)\n", 41 | "print(lg.norm(a))" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 11, 47 | "metadata": { 48 | "scrolled": true 49 | }, 50 | "outputs": [ 51 | { 52 | "name": "stdout", 53 | "output_type": "stream", 54 | "text": [ 55 | "0.3112781244591327\n" 56 | ] 57 | } 58 | ], 59 | "source": [ 60 | "import math\n", 61 | "res = - (0.5 * math.log(2/3, 2) + 1/4 * math.log(1/3, 2))\n", 62 | "print(1- res)" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": null, 68 | "metadata": { 69 | "scrolled": true 70 | }, 71 | "outputs": [ 72 | { 73 | "name": "stdout", 74 | "output_type": "stream", 75 | "text": [ 76 | "0.3112781244591327\n" 77 | ] 78 | } 79 | ], 80 | "source": [ 81 | "\n" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": null, 87 | "metadata": {}, 88 | "outputs": [], 89 | "source": [ 90 | "" 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": null, 96 | "metadata": {}, 97 | "outputs": [], 98 | "source": [ 99 | "" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": null, 105 | "metadata": {}, 106 | "outputs": [], 107 | "source": [ 108 | "" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": null, 114 | "metadata": {}, 115 | "outputs": [], 116 | "source": [] 117 | } 118 | ], 119 | "metadata": { 120 | "kernelspec": { 121 | "display_name": "Python 3", 122 | "language": "python", 123 | "name": "python3" 124 | } 125 | }, 126 | "nbformat": 4, 127 | "nbformat_minor": 2 128 | } 129 | -------------------------------------------------------------------------------- /done.txt: -------------------------------------------------------------------------------- 1 | 12001 2 | 12002 3 | 12003 4 | 12004 5 | 12005 6 | 12006 7 | 12007 8 | 12008 9 | 12009 10 | 12010 11 | 12011 12 | 12012 13 | 12013 14 | 12014 15 | 12015 16 | 12016 17 | 12017 18 | 12018 19 | 12019 20 | 12021 21 | 12022 22 | 12023 23 | 12024 24 | 12025 25 | 12026 26 | 12027 27 | 12028 28 | 12029 29 | 12030 30 | 12031 31 | 12032 32 | 12033 33 | 12034 34 | 12035 35 | 12036 36 | 12037 37 | 12038 38 | 12039 39 | 12040 40 | 12041 41 | 12042 42 | 12043 43 | 12044 44 | 12045 45 | 12046 46 | 12047 47 | 12048 48 | 12049 49 | 12050 50 | 12051 51 | 12052 52 | 12053 53 | 12054 54 | 12055 55 | 12056 56 | 12057 57 | 12058 58 | 12059 59 | 12060 60 | 12061 61 | 12062 62 | 12063 63 | 12064 64 | 12065 65 | 12066 66 | 12067 67 | 12068 68 | 12069 69 | 12070 70 | 12071 71 | 12072 72 | 12073 73 | 12074 74 | 12075 75 | 12076 76 | 12077 77 | 12078 78 | 12079 79 | 12080 80 | 12081 81 | 12082 82 | 12083 83 | 12084 84 | 12085 85 | 12086 86 | 12087 87 | 12088 88 | 12089 89 | 12090 90 | 12091 91 | 12092 92 | 12093 93 | 12094 94 | 12095 95 | 12096 96 | 12097 97 | 12098 98 | 12099 99 | 12100 100 | 12101 101 | 12102 102 | 12103 103 | 12104 104 | 12105 105 | 12106 106 | 12107 107 | 12108 108 | 12109 109 | 12110 110 | 12111 111 | 12112 112 | 12113 113 | 12114 114 | 12115 115 | 12116 116 | 12117 117 | 12118 118 | 12119 119 | 12120 120 | 12121 121 | 12122 122 | 12123 123 | 12124 124 | 12125 125 | 12126 126 | 12127 127 | 12128 128 | 12129 129 | 12130 130 | 12131 131 | 12132 132 | 12133 133 | 12134 134 | 12135 135 | 12136 136 | 12137 137 | 12138 138 | 12139 139 | 12140 140 | 12141 141 | 12142 142 | 12143 143 | 12144 144 | 12145 145 | 12146 146 | 12147 147 | 12148 148 | 12149 149 | 12150 150 | 12151 151 | 12152 152 | 12153 153 | 12154 154 | -------------------------------------------------------------------------------- /empty.txt: -------------------------------------------------------------------------------- 1 | 12020 2 | -------------------------------------------------------------------------------- /failed.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /question_new.json: -------------------------------------------------------------------------------- 1 | {"question": "阴守忍者采用什么视频格式?", "pid": 12001, "answer_sentence": ["视频格式: 采用WMV9 640x480 23.98fps 的视频编码"], "answer": "WMV9"} 2 | {"question": "Seraphim是什么意思?", "pid": 12002, "answer_sentence": ["Seraphim,神最亲近的御使,在希伯来语中代表着”燃烧”和”蛇”的意思,在古代是被形容成在天界中飞翔,似神的有机体,犹太教和基督教中,他是直接和神沟通的角色,是个纯粹只有光及思考的灵体。"], "answer": "Seraphim,神最亲近的御使,在希伯来语中代表着”燃烧”和”蛇”的意思,在古代是被形容成在天界中飞翔,似神的有机体,犹太教和基督教中,他是直接和神沟通的角色,是个纯粹只有光及思考的灵体。"} 3 | {"question": "王婧凭2006年获得什么奖项?", "pid": 12003, "answer_sentence": ["2006年凭借《呼兰河》《杀宫》中的出色表现获得上海第十六届白玉兰新人配演奖。"], "answer": "上海第十六届白玉兰新人配演奖"} 4 | {"question": "雧的以谁为偏旁部首?", "pid": 12004, "answer_sentence": ["雧(jí)部首为隹,部外笔画有20画,总笔画有28画。"], "answer": "隹"} 5 | {"question": "钛在地壳中含量排第几?", "pid": 12005, "answer_sentence": ["地球表面十公里厚的地层中,含钛达千分之六,比铜多61倍,在地壳中的含量排第十位(地壳中元素排行:氧、硅、铝、铁、钙、钠、钾、镁、氢、钛)。"], "answer": "第十"} 6 | {"question": "秦时明月根据哪本小说而来?", "pid": 12006, "answer_sentence": ["中国第一部大型玄幻武侠CG/3D(电脑三维动画)动漫连续剧,灵感来源于温世仁原著小说【详见本词条第一义项】。"], "answer": "温世仁原著小说"} 7 | {"question": "死神来了在哪里连载?", "pid": 12007, "answer_sentence": ["目前正连载于集英社旗下的《周刊少年JUMP》。"], "answer": "集英社"} 8 | {"question": "《三国志》有传但是有纪吗?", "pid": 12008, "answer_sentence": ["均只有传,没有纪。"], "answer": "均只有传,没有纪。"} 9 | {"question": "舒庆春1922年接受了什么仪式的洗礼?", "pid": 12009, "answer_sentence": ["1922年接受基督教受洗仪式成为基督徒。"], "answer": "基督教受洗仪式"} 10 | {"question": "画对称轴的时候需要超出图形吗?", "pid": 12010, "answer_sentence": ["而且画对称轴是超出图形的,避免和图形的高混淆。"], "answer": "是"} 11 | {"question": "刘爽2006年至今在哪所学校就读博士研究生?", "pid": 12011, "answer_sentence": ["2006年9月-至今,北京大学考古文博学院科技考古专业,在职博士研究生;"], "answer": "北京大学考古文博学院"} 12 | {"question": "《巴尔扎克和小裁缝》什么时候上映的?", "pid": 12012, "answer_sentence": ["年代2002"], "answer": "2002"} 13 | {"question": "1660年克伦威尔时候谁重返了英国?", "pid": 12013, "answer_sentence": ["1660年克伦威尔死后查理二世重返英国,詹姆斯随同他一起回到英国。"], "answer": "查理二世"} 14 | {"question": "淮南王这个称号在哪些史书中可以查到?", "pid": 12014, "answer_sentence": ["今查《二十五史》、《资政通鉴》 、《辞海》及有关野史对历代淮南王进行考证,并就有关历史予以整理,以窥其发展轨迹。"], "answer": "《二十五史》、《资政通鉴》 、《辞海》及有关野史"} 15 | {"question": "蔡襄皇右三年回朝修注了什么书?", "pid": 12015, "answer_sentence": ["皇右三年(1051年),蔡襄回朝修《起居注》,参加政事。"], "answer": "《起居注》"} 16 | {"question": "50年代初新文艺工作者改用什么乐器伴奏演唱?", "pid": 12016, "answer_sentence": ["20世纪50年代初,新文艺工作者对凤阳花鼓加以改革,增加采用了一些新的表现手法,剔除了小锣,专用小鼓伴奏演唱,同时根据击鼓用的鼓条特征,将其改称为\"双条鼓\"。"], "answer": "双条鼓"} 17 | {"question": "吴迪1998年培训出了多少个分公司总经理", "pid": 12017, "answer_sentence": ["1998年亲自培训出三十位分公司总经理,团队遍布全国各大中小城市,并获得财务自由;"], "answer": "三十位"} 18 | {"question": "林心如1998年参演什么电视剧而走红?", "pid": 12018, "answer_sentence": ["1993年,林心如以兼职广告模特开始演艺生涯;1994年因与郭富城合作拍广告而正式踏入演艺圈;1998年因参演电视剧《还珠格格》而走红,之后相继参演《半生缘》、《男才女貌》、《美人心计》等影视剧。"], "answer": "《还珠格格》"} 19 | {"question": "向阳小学“九五以来”以什么为办学宗旨?", "pid": 12019, "answer_sentence": ["“九五”以前,向阳小学是一所名不见经传的普通学校,“九五”以来,向阳小学以“科学管理、全面育人”为办学宗旨,以“教育科研”为办学特色,全面构想,合理规划,在短短的五年中,向阳小学迅速崛起,成为市区小有名气的科研特色学校。"], "answer": "科学管理、全面育人"} 20 | {"question": "布欧的好友是谁?", "pid": 12021, "answer_sentence": ["好友:撒旦先生"], "answer": "撒旦先生"} 21 | {"question": "御方堂由哪个学会发起的?", "pid": 12022, "answer_sentence": ["御方堂是由世界中医药学会联合会策划发起的,国内知名中医专家和留学归国学者共同创立的特色中医门诊。"], "answer": "世界中医药学会"} 22 | {"question": "东海年平均水温多少度?", "pid": 12023, "answer_sentence": ["因东海位于亚热带,年平均水温20℃—24℃,年温差7℃—9℃。"], "answer": "20℃—24℃"} 23 | {"question": "《哥斯拉》的电影概念来自哪儿?", "pid": 12024, "answer_sentence": ["《哥斯拉》《哥斯拉》系列电影可以说是日本最长寿的系列影片之一了,他诞生与1954年,电影的概念来源于美国的《金刚》,《金刚》在日本热卖之后,东宝公司就搞了这样一只更大更凶猛的怪兽登上银幕,哥斯拉在银幕上肆意破坏的镜头也和日本战后的心态有着微妙的重合,因此上映后大受欢迎,以至于这个银幕形象存活了50年,加上这部终极战役在内一共28部电影纪录了哥斯拉的辉煌,这其中也包括98年好莱坞版本的《哥斯拉》。"], "answer": "美国的《金刚》"} 24 | {"question": "1960年重庆南开中学被评为什么?", "pid": 12025, "answer_sentence": ["1960年被评为全国百面红旗,傅震垣校长代表学校出席了全国教育系统群英会。"], "answer": "全国百面红旗"} 25 | {"question": "闽中话以什么为代表?", "pid": 12026, "answer_sentence": ["闽中话,以永安话为代表;"], "answer": "永安话"} 26 | {"question": "市中区有多少企业?", "pid": 12027, "answer_sentence": ["市中区有乡以上独立核算工业企业60多家,重点行业有机械、冶金、食品、化工、印刷、塑料等。"], "answer": "60"} 27 | {"question": "伟大的反义词是什么?", "pid": 12028, "answer_sentence": ["反义词:微小 渺小"], "answer": "微小 渺小"} 28 | {"question": "龙门河原称为什么?", "pid": 12029, "answer_sentence": ["原称北插溪,后因靠近龙门圩而得名,又因在海康港入海,别称海康河。"], "answer": "北插溪"} 29 | {"question": "puzzle quest由哪个厂商制作?", "pid": 12030, "answer_sentence": ["制作厂商: Infinite Int.代理发行: D3 PUBLISHER INC."], "answer": "Infinite Int."} 30 | {"question": "ERP阶段的管理系统中增加了哪些功能?", "pid": 12031, "answer_sentence": ["进入ERP阶段後,以计算机为核心的企业级的管理系统更为成熟,系统增加了包括财务预测、生产能力、调整资源调度等方面的功能。"], "answer": "财务预测、生产能力、调整资源调度等方面的功能"} 31 | {"question": "谷氨酸的结构式怎么写?", "pid": 12032, "answer_sentence": ["结构式:HOOCCHNH2(CH2)2COONa"], "answer": "HOOCCHNH2(CH2)2COONa"} 32 | {"question": "第三仗时黄帝联络哪些人对付炎帝?", "pid": 12033, "answer_sentence": ["可是到第三仗的时候,黄帝联络了原先与自己在一起的西北部的许多部落,一同对付炎帝;而且正当作战的时候,又天降大雨,使炎帝的火攻失去了威力,因此,炎帝战败被俘。"], "answer": "原先与自己在一起的西北部的许多部落"} 33 | {"question": "第3次复刊《新思潮》的是谁?", "pid": 12034, "answer_sentence": ["1913芥川龙之介在与久米正雄、菊池宽等先后两次复刊《新思潮》,成为第3次和第4次复刊的《新思潮》杂志同人。"], "answer": "芥川龙之介在与久米正雄、菊池宽等"} 34 | {"question": "狭义的农学是什么意思?", "pid": 12035, "answer_sentence": ["狭义:是指研究农作物生产的科学,即研究作物尤其是大田作物生产理论和生产技术。"], "answer": "狭义:是指研究农作物生产的科学,即研究作物尤其是大田作物生产理论和生产技术。"} 35 | {"question": "曲剧1933年流传到哪里?", "pid": 12036, "answer_sentence": ["1933年,流传到河南中部周口和东部开封一带。"], "answer": "河南中部周口和东部开封一带"} 36 | {"question": "黄山站什么时候建的?", "pid": 12037, "answer_sentence": ["黄山站,原名屯溪站,站址在安徽省黄山市屯溪区黄山东路,建于1981年,目前京福高铁黄山新火车站正在建设中。"], "answer": "1981年"} 37 | {"question": "李逍遥是第几代掌门人?", "pid": 12038, "answer_sentence": ["蜀山仙剑派第二十七代掌门李逍遥(道号一贫)执掌期间,折剑山庄庄主欧阳英四弟子姜承,因为魔族蚩尤后裔,被诬杀害同门而遭到排挤,远离武林,改名“姜世离”,并于覆天顶创立净天教,称“魔君”。"], "answer": "第二十七代"} 38 | {"question": "1900年的5月27日中国发生了什么?", "pid": 12039, "answer_sentence": ["1900年——中国爆发义和团运动。"], "answer": "中国爆发义和团运动"} 39 | {"question": "魔幻1+1由哪些成员组成?", "pid": 12040, "answer_sentence": ["成员包括:吴冠达 布莱恩 小凯"], "answer": "吴冠达 布莱恩 小凯"} 40 | {"question": "寂寞选自哪篇文章?", "pid": 12041, "answer_sentence": ["《寂寞》选自《瓦尔登湖》,以下是中文版本。"], "answer": "《瓦尔登湖》"} 41 | {"question": "雍正五年孝贤纯皇后嫁给了谁?", "pid": 12042, "answer_sentence": ["雍正五年(1727年),七月十八日奉旨与皇四子弘历成婚,为嫡福晋。"], "answer": "皇四子弘历"} 42 | {"question": "1954年由谁组成了辽宁足球队首批球员?", "pid": 12043, "answer_sentence": ["1954年11月辽宁省建立后陆续调入的孙连章、曲光新、于清成、张洪伦、李旭川、金智荣、曹玉海、盖增圣、王立维、慕厚仁、刘茂凯、王有成、孙凤玉等成为了辽宁足球队的首批足球运动员。"], "answer": "孙连章、曲光新、于清成、张洪伦、李旭川、金智荣、曹玉海、盖增圣、王立维、慕厚仁、刘茂凯、王有成、孙凤玉等"} 43 | {"question": "2011年亚洲台同步播出了什么节目?", "pid": 12044, "answer_sentence": ["另外,亚洲台将会同步播出亚视的《十二点半新闻》、《六点钟新闻》以及《夜间新闻》。"], "answer": "《十二点半新闻》、《六点钟新闻》以及《夜间新闻》"} 44 | {"question": "后人为刘伶醉建立了什么?", "pid": 12045, "answer_sentence": ["后人还为他建立了《酒德亭》。"], "answer": "《酒德亭》"} 45 | {"question": "676至679年间狄仁杰任什么职位?", "pid": 12046, "answer_sentence": ["唐高宗仪凤年间(676—679年),狄仁杰升任大理丞,他刚正廉明,执法不阿,兢兢业业,一年中判决了大量的积压案件,涉及1.7万人,无冤诉者,一时名声大振,成为朝野推崇备至的断案如神、摘奸除恶的大法官。"], "answer": "大理丞"} 46 | {"question": "天柱山原山中建有什么建筑?", "pid": 12047, "answer_sentence": ["原山中建有玉帝庙、关帝庙、龙王庙、水阁凉亭、石凳仙床等建筑。"], "answer": "玉帝庙、关帝庙、龙王庙、水阁凉亭、石凳仙床等建筑"} 47 | {"question": "厦深铁路形成了哪个地区的骨干铁路线?", "pid": 12048, "answer_sentence": ["这条铁路将贯通整个东南沿海快速铁路通道,形成我国东南沿海地区骨干铁路线。"], "answer": "我国东南沿海地区"} 48 | {"question": "1953年谁改编了天仙配?", "pid": 12049, "answer_sentence": ["1953年5月,陆洪非根据胡玉庭口述本改编。"], "answer": "陆洪非"} 49 | {"question": "于大宝2008年在哪个比赛中首次登场亮相?", "pid": 12050, "answer_sentence": ["2008年2月4日,于大宝第一次在葡萄牙联赛中正式登场亮相。"], "answer": "葡萄牙联赛"} 50 | {"question": "独行侠点击D代表什么意思?", "pid": 12051, "answer_sentence": ["D 扔掉武器"], "answer": "扔掉武器"} 51 | {"question": "字汇的释义有几个?", "pid": 12052, "answer_sentence": ["字汇释义有二,一指字典一类的工具书;二指词汇、词语。"], "answer": "一指字典一类的工具书;二指词汇、词语"} 52 | {"question": "阴陵泉治疗时刺入几寸即可?", "pid": 12053, "answer_sentence": ["刺法:1.直刺1.0~2.0寸,局部酸胀,针感可向下扩散;"], "answer": "1.0~2.0寸"} 53 | {"question": "我国与比利时何时正式建交?", "pid": 12054, "answer_sentence": ["1971年10月25日,我国与比利时建立外交关系。"], "answer": "1971年10月25日"} 54 | {"question": "动画版灌篮高中中晴子知道流川枫没有感情吗?", "pid": 12055, "answer_sentence": ["在动画版中,晴子明白到流川对自己没有感情,并渐渐习惯这个状况。"], "answer": "明白"} 55 | {"question": "1993年值1999年陈晓在哪所学校任研究室博士后?", "pid": 12056, "answer_sentence": ["1998.3-1999.4 以色列Ben-Gurion大学化学系界面化学研究室博士后。"], "answer": "以色列Ben-Gurion大学"} 56 | {"question": "1945年哪个政府对日宣战", "pid": 12057, "answer_sentence": ["1945年8月8日,苏联政府对日宣战,随即出兵我国东北, 对日本关东军发起全面进攻。"], "answer": "苏联政府"} 57 | {"question": "迪沃克·奥里吉何时担当替补时帮助里尔夺得了一球的胜利?", "pid": 12058, "answer_sentence": ["而在4月12日里尔对阵瓦朗谢讷的比赛中替补出场,帮助里尔打入了致胜一球。"], "answer": "4月12日"} 58 | {"question": "《灵枢经》中对州都是怎么记载的?", "pid": 12059, "answer_sentence": ["《灵枢经》曰:‘肾上连肺,故将两藏,膀胱是孤府。"], "answer": "肾上连肺,故将两藏,膀胱是孤府"} 59 | {"question": "西沟村完成一池三改的农户有多少户?", "pid": 12060, "answer_sentence": ["全村建有沼气池农户20户;已完成\"一池三改\"(改厨、改厕、改厩)的农户20户。"], "answer": "20"} 60 | {"question": "1958年哪两个乡合并了?", "pid": 12061, "answer_sentence": ["1958年4月,将兴隆、胜利两个乡合并为兴隆乡。"], "answer": "兴隆、胜利"} 61 | {"question": "哪年国务院对邮政局实施大部制改革?", "pid": 12062, "answer_sentence": ["2008年9月,国务院实施大部制机构改革。"], "answer": "2008年9月"} 62 | {"question": "2011年越淘越开心改为哪几个主持人主持?", "pid": 12063, "answer_sentence": ["自2011年1月1日更换杨乐乐、李慧玲、柯豆主持节目"], "answer": "杨乐乐、李慧玲、柯豆"} 63 | {"question": "内地神雕侠侣中的林朝英由谁饰演?", "pid": 12064, "answer_sentence": ["1976年 香港佳视《神雕侠侣》丁樱饰 林朝英 1983年 香港无线《神雕侠侣》关菊英饰 林朝英 1992年 香港无线《中神通王重阳》梁艺龄饰 林朝英 1995年 香港无线《神雕侠侣》冯晓文饰 林朝英 2006年 内地《神雕侠侣》于婷饰 林朝英"], "answer": "于婷"} 64 | {"question": "常用的磁性镀层的成分都有哪些?", "pid": 12065, "answer_sentence": ["常用的硬磁合金是Cu-Ni-Fe合金 或Fe-Cr-Co合金;常用的磁性镀层的成分是Ni、Co、P。"], "answer": "Ni、Co、P"} 65 | {"question": "光绪七年从谁的手里收复了伊犁?", "pid": 12066, "answer_sentence": ["1881年(光绪七年)从俄罗斯手中收复伊犁。"], "answer": "俄罗斯"} 66 | {"question": "1991年许志安发行了什么专辑?", "pid": 12067, "answer_sentence": ["1991年,一张名为《Break And Reform Collection》(许志安突破与改进)的专辑使ANDY在形象与演绎上都让人耳目一新,他突破了乖巧斯文的形象,取而代之的是非常前卫的打扮;长工方面也有明显的长进。"], "answer": "《Break And Reform Collection》"} 67 | {"question": "50年代初毛泽东拜访了哪个国家?", "pid": 12068, "answer_sentence": ["50年代初,毛泽东率领中国代表团访问前苏联。"], "answer": "前苏联"} 68 | {"question": "1996年郑中基发行的第一张专辑叫什么?", "pid": 12069, "answer_sentence": ["1996年,郑中基发行第一张个人国语专辑《左右为难》并发表个人第一首创作曲《像一首歌》[2]。"], "answer": "《左右为难》"} 69 | {"question": "大芭专攻什么方面?", "pid": 12070, "answer_sentence": ["大芭比纯纯专攻戏剧;小芭比小蕙则从舞蹈专科学校毕业。"], "answer": "戏剧"} 70 | {"question": "1854年哪条条约到时间?", "pid": 12071, "answer_sentence": ["1854年,《南京条约》届满十二年。"], "answer": "《南京条约》"} 71 | {"question": "原定于1967年的什么测试没能执行?", "pid": 12072, "answer_sentence": ["原定于1967年1月27日进行的“拔除插头”测试(即\"Plugs-out\" test),因火警在收回连接阿波罗-土星的电源线前经以发生,故此测试从未真正执行。"], "answer": "“拔除插头”测试"} 72 | {"question": "肯尼亚东北省的首府是哪里?", "pid": 12073, "answer_sentence": ["肯尼亚东北省:肯尼亚8省之一,首府加里萨。"], "answer": "加里萨"} 73 | {"question": "梅洛习惯用哪个脚?", "pid": 12074, "answer_sentence": ["惯用脚:右脚"], "answer": "右脚"} 74 | {"question": "田中千绘哪年获得了金马奖最佳新演员的提名?", "pid": 12075, "answer_sentence": ["2008年 第45届金马奖“最佳新演员”提名。"], "answer": "2008年"} 75 | {"question": "大阪钢巴足球俱乐部2005年获得了J联赛的什么名次?", "pid": 12076, "answer_sentence": ["2005年获得了J联赛的冠军以及日本联赛杯的亚军,2006年获得天皇杯的冠军。"], "answer": "J联赛的冠军以及日本联赛杯的亚军"} 76 | {"question": "朱厚照在位多少年?", "pid": 12077, "answer_sentence": ["在位16年、病死。"], "answer": "16"} 77 | {"question": "朱江现任什么职位?", "pid": 12078, "answer_sentence": ["现任重庆西永微电子产业园区开发有限公司副总经理,兼任中国通信学会重庆分会理事。", "现任重庆西永微电子产业园区开发有限公司副总经理,兼任中国通信学会重庆分会理事。"], "answer": "重庆西永微电子产业园区开发有限公司副总经理"} 78 | {"question": "蕨麻的花果期有多长?", "pid": 12079, "answer_sentence": ["花果期5-9月。"], "answer": "5-9月"} 79 | {"question": "辽宁宏运足球俱乐部2011年在哪个比赛中排名第三?", "pid": 12080, "answer_sentence": ["俱乐部在2011年中国足球超级联赛最终排名第三,获得代表中国俱乐部参加次年亚洲冠军联赛附加赛的资格。"], "answer": "中国足球超级联赛"} 80 | {"question": "广德公主的丈夫怎么死的?", "pid": 12081, "answer_sentence": ["广德公主是唐宣宗11个女儿之一,招驸马极具曲折情节,后其夫死于黄巢起义,闻讯后殉夫。"], "answer": "黄巢起义"} 81 | {"question": "大学这部电影有多长?", "pid": 12082, "answer_sentence": ["片长: 2时8分52秒"], "answer": "2时8分52秒"} 82 | {"question": "穆勒2014年入围了什么参赛名单?", "pid": 12083, "answer_sentence": ["2014年6月2日,入围德国国家队23人参赛名单,代表国家队征战2014年巴西世界杯。"], "answer": "德国国家队23人参赛名单"} 83 | {"question": "长乐公主名什么?", "pid": 12084, "answer_sentence": ["长乐公主(489-525年)名元锳,北魏孝文帝元宏最小的女儿,母为孝文文昭皇后高照容。"], "answer": "元锳"} 84 | {"question": "1965年吉林队获得了什么名次?", "pid": 12085, "answer_sentence": ["1965年,吉林队获得甲级联盟战冠军。"], "answer": "甲级联盟战冠军"} 85 | {"question": "jump prison是什么意思?", "pid": 12086, "answer_sentence": ["jump prison 越狱"], "answer": "越狱"} 86 | {"question": "霍比特人:五军之战哪年上映的?", "pid": 12087, "answer_sentence": ["上映日期:2014年暑期?"], "answer": "2014年暑期"} 87 | {"question": "计算器是什么应用版本的?", "pid": 12088, "answer_sentence": ["应用版本: 1.5.0.0"], "answer": "1.5.0.0"} 88 | {"question": "2007年张孝全与哪位女主合作影视作品?", "pid": 12089, "answer_sentence": ["2007年,张孝全与郭碧婷在《沉睡的青春》中演对手戏[3]。"], "answer": "郭碧婷"} 89 | {"question": "水木清华这部电视剧什么时候播出的?", "pid": 12090, "answer_sentence": ["电视剧将于2013年12月4日在央视8套电视剧频道每日上午8点30播出。"], "answer": "2013年12月4日"} 90 | {"question": "摩羯座每年哪天经过上中天?", "pid": 12091, "answer_sentence": ["每年8月8日子夜摩羯座中心经过上中天。"], "answer": "8月8日"} 91 | {"question": "郑成功这首歌曲收录于哪张专辑?", "pid": 12092, "answer_sentence": ["词曲作者都是后弦,收录于专辑《东方不败》。"], "answer": "《东方不败》"} 92 | {"question": "陈瑞钿哪年去世的?", "pid": 12093, "answer_sentence": ["1997年9月3日不幸病逝,享年84岁。"], "answer": "1997年9月3日"} 93 | {"question": "华盖寺一共有多少塑像?", "pid": 12094, "answer_sentence": ["共有塑像60身,其中60厘米以上塑像44身,13厘米以下的袖珍雕塑13个(指无量殿真武大帝背屏上的悬塑),还有福禄寿三星的三个精美头像。"], "answer": "60"} 94 | {"question": "冰雪奇缘采用了什么电脑技术?", "pid": 12095, "answer_sentence": ["《冰雪奇缘》与《长发公主》类似,采用电脑合成影像(Computer-generated imagery,CGI)与传统手绘动画制成出独特的风格。"], "answer": "电脑合成影像"} 95 | {"question": "完的偏旁部首怎么写?", "pid": 12096, "answer_sentence": ["部首:宀"], "answer": "宀"} 96 | {"question": "巴巴在线是以什么方式为用户提供娱乐服务的?", "pid": 12097, "answer_sentence": ["巴巴在线是一家以互联网方式向用户提供影视、动漫、游戏、综艺、体育等宽频娱乐内容服务的综合性多媒体宽带娱乐门户网站。", "巴巴在线是一家以互联网方式向用户提供影视、动漫、游戏、综艺、体育等宽频娱乐内容服务的综合性多媒体宽带娱乐门户网站。"], "answer": "互联网"} 97 | {"question": "四象是指什么?", "pid": 12098, "answer_sentence": ["“二十八宿”按照东西南北四个方向划分为四大组,产生“四象”:东方苍龙,西方白虎,南方朱雀,北方玄武。"], "answer": "东方苍龙,西方白虎,南方朱雀,北方玄武"} 98 | {"question": "王小艾负责分管什么工作?", "pid": 12099, "answer_sentence": ["王小艾:分管武装、文教、卫生、新农合、广播电视、食品药品安全工作;"], "answer": "武装、文教、卫生、新农合、广播电视、食品药品安全工作"} 99 | {"question": "智希暗恋的人是谁?", "pid": 12100, "answer_sentence": ["智希暗恋的前辈兼图书会委员长绫瀬纱雪(あやせ さゆき)向其推荐了一本书,于是智希来到了坐落于商业街边的旧书店“风铃堂”。"], "answer": "长绫瀬纱雪"} 100 | {"question": "2006年斯图里奇参加了什么比赛?", "pid": 12101, "answer_sentence": ["2006年,16岁的斯图里奇参加了英格兰青年足总杯,作为球队最年轻的球员,他打入四球,帮助曼城杀入决赛。"], "answer": "英格兰青年足总杯"} 101 | {"question": "粤信广场附近有哪些银行?", "pid": 12102, "answer_sentence": ["银行:中国银行、工商银行、农业银行、建设银行、农村信用社"], "answer": "中国银行、工商银行、农业银行、建设银行、农村信用社"} 102 | {"question": "30岁时项允杰有哪些头衔?", "pid": 12103, "answer_sentence": ["30岁,项允杰有许多头衔:最佳形象先生,危机贺军翔处理专家,80后企业巨子,黄金单身汉等。"], "answer": "最佳形象先生,危机贺军翔处理专家,80后企业巨子,黄金单身汉等"} 103 | {"question": "弟子科技大学的学校网址是什么?", "pid": 12104, "answer_sentence": ["学校网址:http://www.uestc.edu.cn"], "answer": "http://www.uestc.edu.cn"} 104 | {"question": "大大怪变身后叫什么名?", "pid": 12105, "answer_sentence": ["变身后叫开心机车侠,对应红色机械石,代表勇气,机车原型是一辆拖车。"], "answer": "开心机车侠"} 105 | {"question": "钟楼哪年奉旨重建?", "pid": 12106, "answer_sentence": ["清乾隆十年(1745年)重建,十二年后竣工。"], "answer": "1745年"} 106 | {"question": "1988年刘晓华考入哪所院系?", "pid": 12107, "answer_sentence": ["1986年任宁夏书画院创作员,1988年考入中央美术学院版画系。"], "answer": "中央美术学院版画系"} 107 | {"question": "岛出自哪本书?", "pid": 12108, "answer_sentence": ["岛(cv 柿原彻也) 出自今年(2010)7月新番《滑头鬼之孙》 是清十字怪奇侦探团的一员(被团长清继要求被迫加入)。", "出自今年(2010)7月新番《滑头鬼之孙》 是清十字怪奇侦探团的一员(被团长清继要求被迫加入)。"], "answer": "《滑头鬼之孙》"} 108 | {"question": "刘筱筱2014年改用什么艺名?", "pid": 12109, "answer_sentence": ["2014年4月8日,刘筱筱正式启用艺名刘小小。"], "answer": "刘小小"} 109 | {"question": "广州富力足球俱乐部的主队服是什么样的?", "pid": 12110, "answer_sentence": ["主队服:蓝色球衣,白色球裤,蓝色球袜"], "answer": "蓝色球衣,白色球裤,蓝色球袜"} 110 | {"question": "卢卡斯最经典的职业瞬间发生在什么时间?", "pid": 12111, "answer_sentence": ["卢卡斯最为波特兰人津津乐道的职业瞬间,发生在1977年总决赛第二场,他的外号“The Enforcer”正是在那次冠军系列赛中得到的。"], "answer": "1977年"} 111 | {"question": "白胸苦恶鸟指名亚种何时会彻夜鸣叫?", "pid": 12112, "answer_sentence": ["发情期和繁殖期常彻夜鸣叫,鸣声似“苦恶、苦恶”,单调重复,清晰嘹亮。"], "answer": "发情期和繁殖期"} 112 | {"question": "布兰妮购买的劳力士手表值多少英镑?", "pid": 12113, "answer_sentence": ["“小甜甜”布兰妮曾为其夫购买过一块价值65000英镑的劳力士手表,合人民币约80万元。"], "answer": "65000"} 113 | {"question": "广州华商职业学院的校徽的整体是什么样子的?", "pid": 12114, "answer_sentence": ["校徽整体外圆内方,由传统元素配以庄重雅致的古典红融广州华商职业学院校徽合而成,流露出浓郁厚重的文化气息,象征了活力,干劲及灵活性,准确体现“职院”身份。"], "answer": "外圆内方"} 114 | {"question": "0是有理数吗?", "pid": 12115, "answer_sentence": ["也是有理数。"], "answer": "是"} 115 | {"question": "普救寺年平均气温多少度?", "pid": 12116, "answer_sentence": ["年平均气温13.8℃。[2]"], "answer": "13.8℃"} 116 | {"question": "哪年发售秀逗魔导士第一集?", "pid": 12117, "answer_sentence": ["1990年 这一年发售文库第一集《SLAYERS!"], "answer": "1990年"} 117 | {"question": "哪一年编号1772的上游型蒸汽机车停止生产?", "pid": 12118, "answer_sentence": ["至1999年编号1772的最后一台上游型蒸汽机车出厂后最终停产,累计制造了1769辆。"], "answer": "1999"} 118 | {"question": "黑炭原名叫什么?", "pid": 12119, "answer_sentence": ["黑炭:原名郑叹,因某时间回到过去被焦氏一家人收养,在几度经历中习得摩斯密电码以及强壮的身体,同时拥有不低的智商以及高超的配合能力和学习能力。"], "answer": "郑叹"} 119 | {"question": "克劳福德2002年取得了什么成绩?", "pid": 12120, "answer_sentence": ["2002年全美室内田径赛200米冠军;"], "answer": "全美室内田径赛200米冠军"} 120 | {"question": "歌剧魅影属于什么级别?", "pid": 12121, "answer_sentence": ["Argentina:13 / Australia:M / USA:R / France:-12 / UK:18 / West Germany:16 / Singapore:M18"], "answer": "Argentina:13 / Australia:M / USA:R / France:-12 / UK:18 / West Germany:16 / Singapore:M18"} 121 | {"question": "郑俊弘是什么星座的?", "pid": 12122, "answer_sentence": ["星座:天蝎座"], "answer": "天蝎座"} 122 | {"question": "白星的ISBN编码是多少?", "pid": 12123, "answer_sentence": ["ISBN:9787801489630"], "answer": "9787801489630"} 123 | {"question": "森林泰山影片放映后全球票房达到多少美元?", "pid": 12124, "answer_sentence": ["森林王乔治是美国儿童极为喜爱的卡通英雄,影片巧妙地保留了动画风格,片中有着很多动听的歌曲 影片在当年的全球票房收入达到了一亿七千万美元,同时也捧红了饰演乔治的男演员布兰登·费瑟,使他一跃跻身为好莱坞当红小生的行列。"], "answer": "一亿七千万美元"} 124 | {"question": "奥果韦河的经纬度是多少?", "pid": 12125, "answer_sentence": ["流域位于东经9°~14°29′,北纬2°16′~南纬2°46′之间。"], "answer": "东经9°~14°29′,北纬2°16′~南纬2°46′"} 125 | {"question": "超级要塞的造价有多少?", "pid": 12126, "answer_sentence": ["造价:6300"], "answer": "6300"} 126 | {"question": "核芯显卡支持什么技术?", "pid": 12127, "answer_sentence": ["核芯显卡可支持DX10、SM4.0、OpenGL2.0、以及全高清Full HD MPEG2/H.264/VC-1格式解码等技术,即将加入的性能动态调节更可大幅提升核芯显卡的处理能力,令其完全满足于普通用户的需求。"], "answer": "DX10、SM4.0、OpenGL2.0、以及全高清Full HD MPEG2/H.264/VC-1格式解码等技术"} 127 | {"question": "1828年维勒发现了什么破除了有机物由生命力产生的迷信?", "pid": 12128, "answer_sentence": ["1828年德意志化学家维勒从无机物氰酸铵制得尿素,从而破除了有机物只能由生命力产生的迷信,明确了这两类物质都是由化学力结合而成。"], "answer": "尿素"} 128 | {"question": "2012年讲谈社宣布对飙速宅男做些什么改变?", "pid": 12129, "answer_sentence": ["2012年12月24日,讲谈社正式宣布了《飚速宅男》将TV动画化的消息。"], "answer": "TV动画化"} 129 | {"question": "1992年将大足石刻中的哪些造型列入世界文化遗产?", "pid": 12130, "answer_sentence": ["1999年12月1日在摩洛哥历史文化名城马拉喀什举行的联合国教科文组织世界遗产委员会第23届会议上表决通过,将大足石刻中的北山、宝顶山、南山、石篆山、石门山五处摩崖造像,正式列入世界文化遗产,进入《世界遗产名录》的神圣殿堂。"], "answer": "北山、宝顶山、南山、石篆山、石门山五处摩崖造像"} 130 | {"question": "老君山的经纬度是多少?", "pid": 12131, "answer_sentence": ["老君山景区位于东经99度78分,北纬26度65分,地址在云南省丽江市玉龙纳西族自治县,老君山位于丽江市玉龙县与剑川、兰坪等县交界处,属横断山系云岭主脉,金沙江环其左,澜沧江绕其右。"], "answer": "东经99度78分,北纬26度65分"} 131 | {"question": "2014年哪个国家的民众开始练习裸体瑜伽?", "pid": 12132, "answer_sentence": ["2014年3月19日,美国纽约,民众练习裸体瑜伽。"], "answer": "美国"} 132 | {"question": "亚由的三围是多少?", "pid": 12133, "answer_sentence": ["三围:B80 W52 H79"], "answer": "B80 W52 H79"} 133 | {"question": "大筒木舍人继承了谁的血统?", "pid": 12134, "answer_sentence": ["继承了大筒木血脉的、六道仙人的血统持有者。"], "answer": "六道仙人"} 134 | {"question": "阿炳40岁时与谁同居?", "pid": 12135, "answer_sentence": ["40岁时,与寡妇催弟同居。"], "answer": "寡妇催弟"} 135 | {"question": "《他》是由谁所作的诗歌?", "pid": 12136, "answer_sentence": ["《他》是著名作家席慕容所作诗歌作品。"], "answer": "席慕容"} 136 | {"question": "10月31日是什么节日?", "pid": 12137, "answer_sentence": ["10月31日 万圣节(Halloween)"], "answer": "万圣节"} 137 | {"question": "流体力学主要研究流体的哪些状态?", "pid": 12138, "answer_sentence": ["流体力学是力学的一个重要分支,它主要研究流体本身的静止状态和运动状态,以及流体和固体界壁间有相对运动时的相互作用和流动的规律。"], "answer": "静止状态和运动状态"} 138 | {"question": "2006年大桥村的种植业与总收入的比例是多少?", "pid": 12139, "answer_sentence": ["该村2006年农村经济总收入52.4万元,其中:种植业收入12.5万元,占总收入的23.8%;畜牧业收入23.2万元,占总收入的44.2%(其中,年内出栏肉猪130头,肉牛20头,肉羊40头);林业收入0.5万元,占总收入的%;工资性收入16.2万元,农民人均纯收入2817元,农民收入以畜牧等为主。"], "answer": "23.8%"} 139 | {"question": "香港大球场是何时翻新的?", "pid": 12140, "answer_sentence": ["翻新日期:1994年"], "answer": "1994"} 140 | {"question": "朱骏1999年放弃国外工作回国后组建了的社区叫什么?", "pid": 12141, "answer_sentence": ["1999年,放弃国外的工作,回到上海,同年组建了虚拟社区GameNow;"], "answer": "GameNow"} 141 | {"question": "巨蟹座占全天面积的比例是多少?", "pid": 12142, "answer_sentence": ["黄道十二星座之一,面积505.87平方度,占全天面积的1.226%。"], "answer": "1.226%"} 142 | {"question": "新型中药学校讲什么价值观融入教育体系?", "pid": 12143, "answer_sentence": ["校园文化建设突出中医药特色,把中医药文化核心价值观“仁、和、精、诚”融入德育教育体系,强调以人为本、医乃仁术、调和致中、大医精诚等中医核心理念,提高学生的道德修养,促进学生职业素质的提高。"], "answer": "仁、和、精、诚"} 143 | {"question": "在武当七侠中谁最稚气软弱?", "pid": 12144, "answer_sentence": ["武当七侠,各人性格不同,宋远桥慈和、俞莲舟严肃、俞岱岩精练、张松溪机智、张翠山懦雅、莫声谷刚直,最稚气软弱的是排六的殷梨亭。"], "answer": "殷梨亭"} 144 | {"question": "1978年的哪本书籍获得拉尔夫·肖奖?", "pid": 12145, "answer_sentence": ["1978年出版的《图书馆服务的测量与评价》获拉尔夫·肖奖。"], "answer": "《图书馆服务的测量与评价》"} 145 | {"question": "以东方朔偷桃为图表达了什么愿望?", "pid": 12146, "answer_sentence": ["以东方朔偷桃为图,表达了人们祈盼健康长命的良好愿望。"], "answer": "健康长命"} 146 | {"question": "1979年将西街公社改为什么名字?", "pid": 12147, "answer_sentence": ["1977年建西街公社,1979年改西街街道。"], "answer": "西街街道"} 147 | {"question": "哪年《幸运52》改版?", "pid": 12148, "answer_sentence": ["2001年7月《幸运52》改版"], "answer": "2001"} 148 | {"question": "甘夫人的体力如何?", "pid": 12149, "answer_sentence": ["甘夫人势力:蜀 称号:昭烈皇后 体力:1.5阴阳鱼 珠联璧合:刘备 【淑慎】——当你回复1点体力时,你可以令一名与你势力相同的其他角色摸一张牌。", "体力:1.5阴阳鱼"], "answer": "1.5"} 149 | {"question": "克里夫市1月平均气温是多少度?", "pid": 12150, "answer_sentence": ["1月平均气温-3℃,7月平均22℃。"], "answer": "-3℃"} 150 | {"question": "淄博五中的前身是由谁创立的?", "pid": 12151, "answer_sentence": ["山东省淄博第五中学是一所具有光荣发展历史和优良办学传统的历史名校,前身是1942年中国共产党为培养抗日军政干部和建国人才而创立的,为纪念抗日民族英雄马耀南烈士而命名为“耀南中学”,迄今已走过七十一年辉煌灿烂的发展历程,是山东省首批办好的重点中学,省级规范化学校、省级文明单位、全省依法治校示范学校和省级绿色学校,现有64个教学班,在校生3700余人,教职工290人。"], "answer": "中国共产党"} 151 | {"question": "2010年的金融创新高峰论坛在哪里举行?", "pid": 12152, "answer_sentence": ["2010年10月22日,由《IT经理世界》主办的金融创新高峰论坛在北京香格里拉饭店举行,宜信凭借创新的P2P模式获得了“金融服务最佳创新奖”,与招商银行、光大银行一同分享了本届论坛的三个奖项。"], "answer": "北京香格里拉饭店"} 152 | {"question": "柬埔寨哪年举行了自1972年以来的首次多党选举?", "pid": 12153, "answer_sentence": ["根据柬埔寨问题巴黎和平协定的规定,1993年5月23-28日在柬埔寨全国举行了自1972年以来的首次多党选举。"], "answer": "1993"} 153 | {"question": "瘦果被什么包着?", "pid": 12154, "answer_sentence": ["瘦果为宿存黄褐色苞片所包,果皮坚脆,表面具细网纹。"], "answer": "宿存黄褐色苞片"} 154 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Machine Learning 2 | 个人在学习机器学习过程中总结归纳的一些基本算法和学习资源,欢迎大家一起分享交流! 3 | 4 | 5 | ## algorithm 6 | 7 | 8 | 9 | 10 | 11 | ## resources 12 | [1] 李航《统计学方法》,据说是面试宝典 13 | 14 | [2] 《模式识别》,个人感觉这本书将算法的思路原理讲的很清晰 15 | 16 | [3] 台大李宏毅教授的《机器学习》,很好的中文学习视频 17 | 18 | [4] 周志华《机器学习》,西瓜书很好,不过需要很强的数学功底 19 | 20 | [3] [个人知乎专栏机器学习学习总结](https://zhuanlan.zhihu.com/c_1027878794350264320) 21 | 22 | [4] [Basic Machine Learning and Deep Learning github](https://github.com/wepe/MachineLearning) -------------------------------------------------------------------------------- /src/GMM/GMM.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": { 7 | "collapsed": false 8 | }, 9 | "outputs": [ 10 | { 11 | "name": "stdout", 12 | "output_type": "stream", 13 | "text": [ 14 | "Using matplotlib backend: TkAgg\n", 15 | "Populating the interactive namespace from numpy and matplotlib\n" 16 | ] 17 | } 18 | ], 19 | "source": [ 20 | "import numpy as np\n", 21 | "import matplotlib.pyplot as plt\n", 22 | "import copy as cp\n", 23 | "%pylab" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 2, 29 | "metadata": { 30 | "collapsed": true 31 | }, 32 | "outputs": [], 33 | "source": [ 34 | "x = np.linspace(0,1,10000)\n", 35 | "f = lambda x: x*f(x-1) if x > 1 else 1\n", 36 | "y = [1.0*f(10)/(f(6)*f(3))*np.power(i,6)*np.power(1-i,3) for i in x]" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 3, 42 | "metadata": { 43 | "collapsed": false 44 | }, 45 | "outputs": [], 46 | "source": [ 47 | "#第一列记录所属的类别,第二列是持续时间,第三列是与下次的时间间隔\n", 48 | "data = np.array([[3.600, 79], [1.800, 54], [3.333, 74], [2.283, 62], [4.533, 85], [2.883, 55], [4.700, 88], [3.600, 85],\n", 49 | " [1.950, 51], [4.350, 85], [1.833, 54], [3.917, 84], [4.200, 78], [1.750, 47], [4.700, 83], [2.167, 52],\n", 50 | " [1.750,62],[4.800,84],[1.600,52],[4.250,79],[1.800,51],[1.750,47],[3.450,78],[3.067,69],\n", 51 | " [4.533,74],[3.600,83],[1.967,55],[4.083,76],[3.850,78],[4.433,79],[4.300,73],[4.467,77],\n", 52 | " [3.367,66],[4.033,80],[3.833,74],[2.017,52],[1.867,48],[4.833,80],[1.833,59],[4.783,90],\n", 53 | " [4.350,80],[1.883,58],[4.567,84],[1.750,58],[4.533,73],[3.317,83],[3.833,64],[2.100,53],\n", 54 | " [4.633,82],[2.000,59],[4.800,75],[4.716,90],[1.833,54],[4.833,80],[1.733,54],[4.883,83],\n", 55 | " [3.717,71],[1.667,64],[4.567,77],[4.317,81],[2.233,59],[4.500,84],[1.750,48],[4.800,82],\n", 56 | " [1.817,60],[4.400,92],[4.167,78],[4.700,78],[2.067,65],[4.700,73],[4.033,82],[1.967,56],\n", 57 | " [4.500,79],[4.000,71],[1.983,62],[5.067,76],[2.017,60],[4.567,78],[3.883,76],[3.600,83],\n", 58 | " [4.133,75],[4.333,82],[4.100,70],[2.633,65],[4.067,73],[4.933,88],[3.950,76],[4.517,80],\n", 59 | " [2.167,48],[4.000,86],[2.200,60],[4.333,90],[1.867,50],[4.817,78],[1.833,63],[4.300,72],\n", 60 | " [4.667,84],[3.750,75],[1.867,51],[4.900,82],[2.483,62],[4.367,88],[2.100,49],[4.500,83],\n", 61 | " [4.050,81],[1.867,47],[4.700,84],[1.783,52],[4.850,86],[3.683,81],[4.733,75],[2.300,59],\n", 62 | " [4.900,89],[4.417,79],[1.700,59],[4.633,81],[2.317,50],[4.600,85],[1.817,59],[4.417,87],\n", 63 | " [2.617,53],[4.067,69],[4.250,77],[1.967,56],[4.600,88],[3.767,81],[1.917,45],[4.500,82],\n", 64 | " [2.267,55],[4.650,90],[1.867,45],[4.167,83],[2.800,56],[4.333,89],[1.833,46],[4.383,82],\n", 65 | " [1.883,51],[4.933,86],[2.033,53],[3.733,79],[4.233,81],[2.233,60],[4.533,82],[4.817,77],\n", 66 | " [4.333,76],[1.983,59],[4.633,80],[2.017,49],[5.100,96],[1.800,53],[5.033,77],[4.000,77],\n", 67 | " [2.400,65],[4.600,81],[3.567,71],[4.000,70],[4.500,81],[4.083,93],[1.800,53],[3.967,89],\n", 68 | " [2.200,45],[4.150,86],[2.000,58],[3.833,78],[3.500,66],[4.583,76],[2.367,63],[5.000,88],\n", 69 | " [1.933,52],[4.617,93],[1.917,49],[2.083,57],[4.583,77],[3.333,68],[4.167,81],[4.333,81],\n", 70 | " [4.500,73],[2.417,50],[4.000,85],[4.167,74],[1.883,55],[4.583,77],[4.250,83],[3.767,83],\n", 71 | " [2.033,51],[4.433,78],[4.083,84],[1.833,46],[4.417,83],[2.183,55],[4.800,81],[1.833,57],\n", 72 | " [4.800,76],[4.100,84],[3.966,77],[4.233,81],[3.500,87],[4.366,77],[2.250,51],[4.667,78],\n", 73 | " [2.100,60],[4.350,82],[4.133,91],[1.867,53],[4.600,78],[1.783,46],[4.367,77],[3.850,84],\n", 74 | " [1.933,49],[4.500,83],[2.383,71],[4.700,80],[1.867,49],[3.833,75],[3.417,64],[4.233,76],\n", 75 | " [2.400,53],[4.800,94],[2.000,55],[4.150,76],[1.867,50],[4.267,82],[1.750,54],[4.483,75],\n", 76 | " [4.000,78],[4.117,79],[4.083,78],[4.267,78],[3.917,70],[4.550,79],[4.083,70],[2.417,54],\n", 77 | " [4.183,86],[2.217,50],[4.450,90],[1.883,54],[1.850,54],[4.283,77],[3.950,79],[2.333,64],\n", 78 | " [4.150,75],[2.350,47],[4.933,86],[2.900,63],[4.583,85],[3.833,82],[2.083,57],[4.367,82],\n", 79 | " [2.133,67],[4.350,74],[2.200,54],[4.450,83],[3.567,73],[4.500,73],[4.150,88],[3.817,80],\n", 80 | " [3.917,71],[4.450,83],[2.000,56],[4.283,79],[4.767,78],[4.533,84],[1.850,58],[4.250,83],\n", 81 | " [1.983,43],[2.250,60],[4.750,75],[4.117,81],[2.150,46],[4.417,90],[1.817,46],[4.467,74]])\n", 82 | "\n" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": 10, 88 | "metadata": { 89 | "collapsed": false 90 | }, 91 | "outputs": [], 92 | "source": [ 93 | "# 计算概率密度,\n", 94 | "# 参数皆为array类型,过程中参数不变\n", 95 | "def gaussian(x,mean,cov):\n", 96 | " \n", 97 | " dim = np.shape(cov)[0] # 维度\n", 98 | " #之所以加入单位矩阵是为了防止行列式为0的情况\n", 99 | " covdet = np.linalg.det(cov+np.eye(dim)*0.01) #协方差矩阵的行列式\n", 100 | " covinv = np.linalg.inv(cov+np.eye(dim)*0.01) #协方差矩阵的逆\n", 101 | " xdiff = x - mean\n", 102 | " #概率密度\n", 103 | " prob = 1.0/np.power(2*np.pi,1.0*dim/2)/np.sqrt(np.abs(covdet))*np.exp(-1.0/2*np.dot(np.dot(xdiff,covinv),xdiff))\n", 104 | " return prob\n", 105 | "\n", 106 | "\n", 107 | "#获取初始协方差矩阵\n", 108 | "def getconvs(data, K):\n", 109 | " convs = [0]*K\n", 110 | " for i in range(K):\n", 111 | " # 初始的协方差矩阵源自于原始数据的协方差矩阵,且每个簇的初始协方差矩阵相同\n", 112 | " convs[i] = np.cov(data.T) \n", 113 | " return convs\n", 114 | "\n", 115 | "\n", 116 | "def isdistinct(means, criter=0.03): #检测初始中心点是否靠得过近\n", 117 | " K = len(means)\n", 118 | " for i in range(K):\n", 119 | " for j in range(i+1,K):\n", 120 | " if criter > np.linalg.norm(means[i]-means[j]):\n", 121 | " return 0 \n", 122 | " return True\n", 123 | "\n", 124 | "\n", 125 | "#获取初始聚簇中心\n", 126 | "def getmeans(data, K, criter):\n", 127 | " means = [0]*K\n", 128 | " dim = np.shape(data)[1]\n", 129 | " minmax = [] #各个维度的极大极小值\n", 130 | " for i in range(dim):\n", 131 | " minmax.append(np.array([min(data[:,i]),max(data[:,i])]))\n", 132 | " \n", 133 | " while True:\n", 134 | " #生成初始点的坐标\n", 135 | " for i in range(K):\n", 136 | " means[i] = []\n", 137 | " for j in range(dim):\n", 138 | " means[i].append(np.random.random()*(minmax[j][1]-minmax[j][0])+minmax[j][0]) \n", 139 | " means[i] = np.array(means[i])\n", 140 | " \n", 141 | " if isdistinct(means,criter):\n", 142 | " break \n", 143 | " return means\n", 144 | "\n", 145 | "# k-means算法的实现函数。\n", 146 | "# 用K-means算法输出的聚类中心,作为高斯混合模型的输入\n", 147 | "def kmeans(data, K):\n", 148 | " N = np.shape(data)[0] # 样本数目\n", 149 | " dim = np.shape(data)[1] #维度\n", 150 | "\n", 151 | " means = getmeans(data,K,criter=15)\n", 152 | " means_old = [np.zeros(dim) for k in range(K)]\n", 153 | "\n", 154 | "\n", 155 | " while np.sum([np.linalg.norm(means_old[k]-means[k]) for k in range(K)]) > 0.01:\n", 156 | " \n", 157 | " means_old = cp.deepcopy(means)\n", 158 | " \n", 159 | " numlog = [0]*K\n", 160 | " sumlog = [np.zeros(dim) for k in range(K)]\n", 161 | " for n in range(N):\n", 162 | " distlog = [np.linalg.norm(data[n]-means[k]) for k in range(K)]\n", 163 | " toK = distlog.index(np.min(distlog))\n", 164 | " \n", 165 | " numlog[toK] += 1\n", 166 | " sumlog[toK] += data[n]\n", 167 | " \n", 168 | " for k in range(K):\n", 169 | " means[k] = 1.0/numlog[k]*sumlog[k]\n", 170 | " return means\n", 171 | "\n", 172 | "#对程序结果进行可视化,注意这里的K只能取2,否则该函数运行出错\n", 173 | "def visualresult(data,gammas,K):\n", 174 | " N = np.shape(data)[0]#样本数目\n", 175 | " dim = np.shape(data)[1] #维度\n", 176 | " \n", 177 | " minmax = [] #各个维度的极大极小值\n", 178 | " xy = []\n", 179 | " n=200\n", 180 | " for i in range(dim):\n", 181 | " delta = 0.05*(np.max(data[:,i])-np.min(data[:,i]))\n", 182 | " xy.append(np.linspace(np.min(data[:,i])-delta,np.max(data[:,i])+delta,n))\n", 183 | " xx,yy = np.meshgrid(xy[0], xy[1])\n", 184 | " zz = np.zeros((n,n))\n", 185 | " for i in range(n):\n", 186 | " for j in range(n):\n", 187 | " zz[i][j] = np.sum(gaussian(np.array([xx[i][j],yy[i][j]]),means[k],convs[k]) for k in range(K))\n", 188 | " gci = plt.imshow(zz,origin='lower',alpha = 0.8) # 选项origin='lower' 防止tuixan图像颠倒\n", 189 | " plt.xticks([0,len(xy[0])-1],[xy[0][0],xy[0][-1]])\n", 190 | " plt.yticks([0,len(xy[1])-1],[xy[1][0],xy[1][-1]])\n", 191 | "\n", 192 | " for i in range(N):\n", 193 | " if gammas[i][0] >0.5:\n", 194 | " plt.plot((data[i][0]-np.min(data[:,0]))/(xy[0][1]-xy[0][0]),(data[i][1]-np.min(data[:,1]))/(xy[1][1]-xy[1][0]),'r.')\n", 195 | " else:\n", 196 | " plt.plot((data[i][0]-np.min(data[:,0]))/(xy[0][1]-xy[0][0]),(data[i][1]-np.min(data[:,1]))/(xy[1][1]-xy[1][0]),'k.')\n", 197 | " \n", 198 | " deltax = xy[0][1]-xy[0][0]\n", 199 | " deltay = xy[1][1]-xy[1][0]\n", 200 | "\n", 201 | " plt.plot((means[0][0]-xy[0][0])/deltax,(means[0][1]-xy[1][0])/deltay,'*r',markersize=15)\n", 202 | " plt.plot((means[1][0]-xy[0][0])/deltax,(means[1][1]-xy[1][0])/deltay,'*k',markersize=15)\n", 203 | "\n", 204 | " plt.title(u'高斯混合模型图',{'fontname':'STFangsong','fontsize':18})" 205 | ] 206 | }, 207 | { 208 | "cell_type": "code", 209 | "execution_count": 7, 210 | "metadata": { 211 | "collapsed": false, 212 | "scrolled": false 213 | }, 214 | "outputs": [ 215 | { 216 | "name": "stdout", 217 | "output_type": "stream", 218 | "text": [ 219 | "[array([ 4.15510416, 78.58089181]), array([ 2.51043237, 59.64340588])]\n", 220 | "-1248.72568103\n", 221 | "====================\n", 222 | "[array([ 4.28167913, 79.93571468]), array([ 2.33212635, 57.73968927])]\n", 223 | "-1195.11771979\n", 224 | "====================\n", 225 | "[array([ 4.32566238, 80.39272358]), array([ 2.18105751, 56.08797096])]\n", 226 | "-1160.33078441\n", 227 | "====================\n", 228 | "[array([ 4.31994298, 80.35355281]), array([ 2.10777052, 55.21487955])]\n", 229 | "-1144.99281154\n", 230 | "====================\n", 231 | "[array([ 4.30418632, 80.14670418]), array([ 2.06479471, 54.77495491])]\n", 232 | "-1135.24769842\n", 233 | "====================\n", 234 | "[array([ 4.29392336, 80.01380331]), array([ 2.04252868, 54.55248998])]\n", 235 | "-1131.33107397\n", 236 | "====================\n", 237 | "[array([ 4.29096459, 79.98340028]), array([ 2.03797434, 54.49546439])]\n", 238 | "-1130.99134442\n", 239 | "====================\n", 240 | "[array([ 4.29039684, 79.97705707]), array([ 2.03727491, 54.48740767])]\n", 241 | "-1130.96278176\n", 242 | "====================\n", 243 | "[array([ 4.29029464, 79.97587903]), array([ 2.03715549, 54.48609618])]\n", 244 | "-1130.95859821\n", 245 | "====================\n", 246 | "[array([ 4.29027651, 79.97566892]), array([ 2.03713448, 54.48586746])]\n", 247 | "-1130.95788221\n", 248 | "====================\n", 249 | "[array([ 4.2902733 , 79.97563167]), array([ 2.03713076, 54.48582706])]\n", 250 | "-1130.95775616\n", 251 | "====================\n", 252 | "[array([ 4.29027273, 79.97562507]), array([ 2.0371301, 54.4858199])]\n", 253 | "-1130.95773386\n", 254 | "====================\n" 255 | ] 256 | } 257 | ], 258 | "source": [ 259 | "\n", 260 | "N = np.shape(data)[0]#样本数目\n", 261 | "dim = np.shape(data)[1] #维度\n", 262 | "K = 2 # 聚簇的个数\n", 263 | "\n", 264 | "means = kmeans(data,K)\n", 265 | "\n", 266 | "convs = getconvs(data,K)\n", 267 | "\n", 268 | "pis = [1.0/K]*K\n", 269 | "gammas = [np.zeros(K) for i in range(N)] #*N 注意不能用 *N,否则N个array只指向一个地址\n", 270 | "\n", 271 | "loglikelyhood = 0\n", 272 | "oldloglikelyhood = 1\n", 273 | "\n", 274 | "while np.abs(loglikelyhood - oldloglikelyhood)> 0.0001:\n", 275 | " oldloglikelyhood = loglikelyhood\n", 276 | "\n", 277 | " \n", 278 | " # E_step\n", 279 | " for n in range(N):\n", 280 | " respons = [pis[k]*gaussian(data[n],means[k],convs[k]) for k in range(K)]\n", 281 | " \n", 282 | " sumrespons = np.sum(respons)\n", 283 | " for k in range(K):\n", 284 | " gammas[n][k] = respons[k]/sumrespons\n", 285 | "\n", 286 | " # M_step\n", 287 | " for k in range(K):\n", 288 | " nk = np.sum([gammas[n][k] for n in range(N)])\n", 289 | " means[k] = 1.0/nk * np.sum([gammas[n][k]*data[n] for n in range(N)],axis=0)\n", 290 | " \n", 291 | " xdiffs = data - means[k]\n", 292 | " convs[k] = 1.0/nk * np.sum([gammas[n][k]*xdiffs[n].reshape(dim,1)*xdiffs[n] for n in range(N)],axis=0)\n", 293 | " pis[k] = 1.0*nk/N\n", 294 | " \n", 295 | " # 计算似然函数值\n", 296 | " loglikelyhood =np.sum( [np.log(np.sum([pis[k]*gaussian(data[n],means[k],convs[k]) for k in range(K)])) for n in range(N) ])\n", 297 | " #print means\n", 298 | " #print loglikelyhood\n", 299 | " #print '=='*10\n", 300 | "\n", 301 | " \n", 302 | "\n", 303 | " " 304 | ] 305 | }, 306 | { 307 | "cell_type": "code", 308 | "execution_count": null, 309 | "metadata": { 310 | "collapsed": true 311 | }, 312 | "outputs": [], 313 | "source": [] 314 | } 315 | ], 316 | "metadata": { 317 | "kernelspec": { 318 | "display_name": "Python 2", 319 | "language": "python", 320 | "name": "python2" 321 | }, 322 | "language_info": { 323 | "codemirror_mode": { 324 | "name": "ipython", 325 | "version": 2 326 | }, 327 | "file_extension": ".py", 328 | "mimetype": "text/x-python", 329 | "name": "python", 330 | "nbconvert_exporter": "python", 331 | "pygments_lexer": "ipython2", 332 | "version": "2.7.9" 333 | } 334 | }, 335 | "nbformat": 4, 336 | "nbformat_minor": 0 337 | } 338 | -------------------------------------------------------------------------------- /src/GMM/GMM.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import numpy as np 3 | import copy 4 | from data_helper import load_samples_data, load_samples_test_data, load_mnist_data 5 | 6 | 7 | def gaussian(data, mean, cov): 8 | """ 9 | 计算高维高斯函数概率密度. 10 | :param data: 样本数据 11 | :param mean: 均值 12 | :param cov: 协方差 13 | :return: 14 | """ 15 | dim = np.shape(cov)[0] # 计算维度 16 | covdet = np.linalg.det(cov) # 计算|cov| 17 | covinv = np.linalg.inv(cov) # 计算cov的逆 18 | if covdet == 0: # 以防行列式为0 19 | covdet = np.linalg.det(cov+np.eye(dim)*0.01) 20 | covinv = np.linalg.inv(cov+np.eye(dim)*0.01) 21 | m = data - mean 22 | z = -0.5 * np.dot(np.dot(m, covinv), m) # 计算exp()里的值 23 | return 1.0/(np.power(np.power(2*np.pi, dim)*abs(covdet), 0.5))*np.exp(z) # 返回概率密度值1234567891011 24 | 25 | 26 | def isdistance(means, criterion=0.03): 27 | """ 28 | 用于判断初始聚类簇中的means是否距离离得比较近 29 | :param means: 初始聚类簇means集合 30 | :param criterion: 31 | :return: 32 | """ 33 | K = len(means) 34 | for i in range(K): 35 | for j in range(i+1, K): 36 | if criterion > np.linalg.norm(means[i]-means[j]): 37 | return False 38 | return True 39 | 40 | 41 | def getInitialMeans(data, K, criterion): 42 | """ 43 | 获取最初的聚类中心. 44 | :param data: 数据集合 45 | :param K: 46 | :param criterion: 47 | :return: 48 | """ 49 | dim = data.shape[1] # 数据的维度 50 | means = [[] for k in range(K)] # 存储均值 51 | minmax = [] # 存储每一维的最大最小值 52 | for i in range(dim): 53 | minmax.append(np.array([min(data[:, i]), max(data[:, i])])) 54 | minmax = np.array(minmax) 55 | 56 | # 随机产生means 57 | while True: 58 | for i in range(K): 59 | means[i] = [] 60 | for j in range(dim): 61 | means[i].append(np.random.random()*(minmax[i][1]-minmax[i][0])+minmax[i][0]) 62 | means[i] = np.array(means[i]) 63 | # judge 64 | if isdistance(means, criterion): 65 | break 66 | return means 67 | 68 | 69 | def kmeans(data, K): 70 | """ 71 | k-means cluster. 72 | 估计大约几个样本属于一个GMM. 73 | :param data: 样本数据集 74 | :param K: K个类别 75 | :return: 76 | """ 77 | N = data.shape[0] # 样本数量 78 | dim = data.shape[1] # 样本维度 79 | # 初始化聚类中心点 80 | means = getInitialMeans(data, K, 15) 81 | 82 | means_old = [np.zeros(dim) for k in range(K)] 83 | # 收敛条件 84 | while np.sum([np.linalg.norm(means_old[k] - means[k]) for k in range(K)]) > 0.01: 85 | means_old = copy.deepcopy(means) 86 | numlog = [0] * K # 存储属于某类的个数 87 | sumlog = [np.zeros(dim) for k in range(K)] # 存储属于某类的样本均值 88 | 89 | # E步 90 | for i in range(N): 91 | dislog = [np.linalg.norm(data[i]-means[k]) for k in range(K)] 92 | tok = dislog.index(np.min(dislog)) 93 | numlog[tok] += 1 # 属于该类的样本数量加1 94 | sumlog[tok] += data[i] # 存储属于该类的样本取值 95 | 96 | # M步 97 | for k in range(K): 98 | means[k] = 1.0 / (numlog[k] + 1.) * sumlog[k] 99 | return means 100 | 101 | 102 | def GMM(data, K): 103 | """ 104 | GMM Models. 105 | :param data: 数据集合 106 | :param K: K 107 | :return: 108 | """ 109 | N = data.shape[0] 110 | dim = data.shape[1] 111 | means = kmeans(data, K) 112 | convs = [0] * K 113 | # 初始方差等于整体data的方差 114 | for i in range(K): 115 | convs[i] = np.cov(data.T) 116 | pis = [1.0/K] * K 117 | gammas = [np.zeros(K) for i in range(N)] 118 | loglikelyhood = 0 119 | oldloglikelyhood = 1 120 | 121 | while np.abs(loglikelyhood - oldloglikelyhood) > 0.0001: 122 | oldloglikelyhood = loglikelyhood 123 | 124 | # E步 125 | for i in range(N): 126 | res = [pis[k] * gaussian(data[i], means[k], convs[k]) for k in range(K)] 127 | sumres = np.sum(res) 128 | for k in range(K): # gamma表示第n个样本属于第k个混合高斯的概率 129 | gammas[i][k] = res[k] / sumres 130 | 131 | # M步 132 | for k in range(K): 133 | Nk = np.sum([gammas[n][k] for n in range(N)]) # N[k] 表示N个样本中有多少属于第k个高斯 134 | 135 | pis[k] = 1.0 * Nk/N 136 | means[k] = (1.0/Nk) * np.sum([gammas[n][k] * data[n] for n in range(N)], axis=0) 137 | xdiffs = data - means[k] 138 | convs[k] = (1.0/Nk)*np.sum([gammas[n][k] * xdiffs[n].reshape(dim, 1) * xdiffs[n] for n in range(N)], axis=0) 139 | # 计算最大似然函数 140 | loglikelyhood = np.sum( 141 | [np.log(np.sum([pis[k] * gaussian(data[n], means[k], convs[k]) for k in range(K)])) for n in range(N)]) 142 | 143 | print("current pi: ", pis, " means: ", means, " convs: ", convs, ' loglikelyhood: ', loglikelyhood) 144 | return pis, means, convs 145 | 146 | 147 | def GMM_prob(data, pis, means, convs): 148 | """ 149 | calc the GMM prob of the sample data. 150 | :param data: 151 | :param pis: 152 | :param means: 153 | :param convs: 154 | :return: 155 | """ 156 | K = len(pis) 157 | probs = [pis[i]*gaussian(data, means[i], convs[i]) for i in range(K)] 158 | return np.sum(probs) 159 | 160 | 161 | def experiment1(): 162 | """ 163 | 1. 使用训练样本估计GMM参数(2个GMM) 164 | 2. 构造区分两类的GMM分类器 165 | :return: 166 | """ 167 | # train GMM1 and GMM2 168 | K = 2 169 | train_data1, train_data2 = load_samples_data() 170 | print("for Train1 data: ") 171 | pis1, means1, convs1 = GMM(train_data1, K) 172 | print("train1 data, pi: ", pis1, " means: ", means1, " convs: ", convs1) 173 | 174 | print("*"*100) 175 | 176 | print("for Train2 data: ") 177 | pis2, means2, convs2 = GMM(train_data2, K) 178 | print("train2 data, pi: ", pis2, " means: ", means2, " convs: ", convs2) 179 | 180 | # test the GMM classifier 181 | test_data1, test_data2 = load_samples_test_data() 182 | count_1 = 0 183 | for data in test_data1: 184 | if GMM_prob(data, pis1, means1, convs1) > GMM_prob(data, pis2, means2, convs2): 185 | count_1 += 1 186 | 187 | count_2 = 0 188 | for data in test_data2: 189 | if GMM_prob(data, pis2, means2, convs2) > GMM_prob(data, pis1, means1, convs1): 190 | count_2 += 1 191 | 192 | print("count1: ", count_1) 193 | print("count2: ", count_2) 194 | 195 | 196 | def experiment2(): 197 | """ 198 | GMM分类mnist. 199 | --------- 200 | 1. 对每一个类别训练一个GMM. 201 | 2. 对于一个样本,判断这个样本属于哪个GMM的概率大就属于哪个类别. 202 | :return: 203 | """ 204 | # 设置GMM中的K值 205 | K = 3 206 | # 将数据分为C类 207 | datas = {} 208 | train_datas, train_labels = load_mnist_data(filename='data/TrainSamples.csv', 209 | label_filename='data/TrainLabels.csv') 210 | for idx, j in enumerate(train_labels): 211 | if j not in datas.keys(): 212 | datas[j] = [] 213 | datas[j].append(train_datas[idx]) 214 | 215 | # train C GMM 216 | print("train C GMM....") 217 | params = {} 218 | for c in datas.keys(): 219 | pis, means, convs = GMM(np.array(datas[c], dtype='float64'), K) 220 | params[c] = (pis, means, convs) 221 | 222 | # test the test_data accuracy 223 | print("test the data acc.....") 224 | test_datas, test_labels = load_mnist_data(filename='data/TestSamples.csv', 225 | label_filename='data/TestLabels.csv') 226 | count = 0 227 | for idx, test_data in enumerate(test_datas): 228 | target = test_labels[idx] 229 | max_prob = 0. 230 | max_c = 0 231 | for c in params.keys(): 232 | pis, means, convs = params[c] 233 | prob = GMM_prob(test_data, pis, means, convs) 234 | if prob > max_prob: 235 | max_prob = prob 236 | max_c = c 237 | if target == max_c: 238 | count += 1 239 | print("test accuracy is:{} / {} = {} ".format(count, len(test_datas), count / (len(test_datas) + 0.))) 240 | 241 | 242 | if __name__ == "__main__": 243 | experiment2() 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | -------------------------------------------------------------------------------- /src/GMM/data/EmuSamples.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/GMM/data/EmuSamples.mat -------------------------------------------------------------------------------- /src/GMM/data/Samples.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/GMM/data/Samples.mat -------------------------------------------------------------------------------- /src/GMM/data/Test1.csv: -------------------------------------------------------------------------------- 1 | 8.8649,9.2649 2 | 11.249,13.982 3 | 8.2251,8.6018 4 | 8.4195,8.6136 5 | 1.1264,-0.11897 6 | 2.9819,1.4747 7 | 0.63443,0.67101 8 | 10.932,13.629 9 | 0.51969,1.3805 10 | -2.5963,-1.5433 11 | 7.3224,5.7792 12 | 10.984,10.927 13 | 11.239,12.775 14 | 1.4037,1.2776 15 | 0.98913,1.2281 16 | 1.5018,0.43845 17 | 1.3241,-0.59642 18 | 0.54173,1.1483 19 | 1.5438,1.02 20 | -0.14756,-0.53927 21 | -0.53554,0.61162 22 | 2.5148,0.94003 23 | 0.40588,1.1739 24 | -1.08,-0.12649 25 | -1.1398,-1.4379 26 | 3.0761,0.10132 27 | 11.466,13.847 28 | 10.549,9.4775 29 | 10.975,10.324 30 | 10.657,12.085 31 | -1.9752,-0.37425 32 | -0.61996,0.22622 33 | 8.9417,8.1727 34 | -2.517,-0.15057 35 | 2.8972,1.8137 36 | 1.2547,0.54749 37 | 0.62157,0.35604 38 | -2.4483,-1.7858 39 | 9.0003,10.512 40 | -1.3456,-0.19023 41 | -1.1843,1.2102 42 | 10.774,8.5216 43 | 9.1475,10.747 44 | 1.9493,0.035965 45 | -0.75989,0.8765 46 | 0.54672,0.74615 47 | -1.1648,-0.81664 48 | 0.98438,1.098 49 | -0.48054,0.015349 50 | 9.4613,9.9158 51 | 11.634,13.056 52 | 8.0688,8.1219 53 | 2.3146,1.0701 54 | -0.78393,1.1434 55 | -0.92808,-0.99831 56 | 9.9477,10.358 57 | 13.446,13.604 58 | -0.88472,-0.68023 59 | 1.027,-0.13192 60 | -1.5568,-0.32249 61 | -0.92562,-0.99461 62 | 10.105,6.3707 63 | 11.136,11.235 64 | 0.43593,-0.34779 65 | -2.693,-0.75433 66 | 9.2471,8.5245 67 | -0.94011,-0.72326 68 | 2.9873,1.893 69 | 11.178,9.7884 70 | 2.2137,1.5589 71 | -0.78012,1.175 72 | -4.3714,-1.013 73 | 2.7924,0.49297 74 | 1.8108,0.25956 75 | 1.7804,2.0474 76 | 11.54,11.557 77 | 11.107,9.1171 78 | 10.382,6.7798 79 | 9.5505,8.6503 80 | 0.92576,1.1348 81 | 0.59582,0.73913 82 | 3.049,1.4895 83 | -1.2348,2.0596 84 | 0.82278,-0.28956 85 | 3.2814,1.1478 86 | 0.036446,-0.66058 87 | 7.8999,9.1034 88 | 11.065,13.892 89 | 9.9037,10.195 90 | -2.0612,-0.51023 91 | 8.4466,7.3737 92 | 7.5143,6.6159 93 | 10.066,12.335 94 | 12.909,14.299 95 | 8.5941,7.9191 96 | 0.66379,0.15121 97 | 0.10708,-0.28314 98 | 9.7608,10.501 99 | -2.5456,-0.70191 100 | 1.1057,-0.61079 101 | -5.1224,-1.588 102 | 9.9991,9.2975 103 | 9.6136,9.4774 104 | -0.85742,-0.56738 105 | -1.4946,-0.83841 106 | 9.9977,8.2265 107 | 2.5482,-0.082562 108 | 8.1917,6.6457 109 | -1.4258,-0.50626 110 | 10.713,11.714 111 | -0.18138,-0.57546 112 | 10.16,7.8249 113 | -0.27583,0.007025 114 | 1.8988,1.5625 115 | 3.4783,0.24723 116 | -0.52621,-0.14944 117 | 0.25036,-0.64247 118 | -4.9631,-0.3828 119 | 3.4257,1.6374 120 | 1.6317,0.55545 121 | 8.5972,8.3276 122 | -0.57171,1.3348 123 | 3.3809,-0.15751 124 | -3.5274,-3.1463 125 | 1.3078,0.30751 126 | -0.48323,-0.097753 127 | 1.3374,0.52981 128 | 11.651,11.95 129 | 11.781,11.7 130 | 10.308,10.463 131 | 1.3679,1.297 132 | -2.4251,-0.19515 133 | 7.0228,8.6154 134 | 0.25978,-0.19729 135 | 8.0179,6.2827 136 | 9.5453,10.142 137 | 0.53732,0.2989 138 | 0.31131,0.29227 139 | 11.611,9.619 140 | 12.276,10.576 141 | -0.9125,0.1078 142 | 10.38,12.246 143 | 8.6486,9.2066 144 | 9.1485,8.8689 145 | -2.2285,-0.47525 146 | 9.7225,10.166 147 | -2.6644,0.22154 148 | 0.15804,0.81095 149 | 12.917,12.717 150 | 9.3746,5.1463 151 | -0.39691,-0.66245 152 | 0.89998,-1.1801 153 | 10.345,10.194 154 | -0.7326,-0.082663 155 | -1.1724,-0.54211 156 | 0.029584,-0.34016 157 | 12.53,11.877 158 | 1.7342,0.015032 159 | 8.8275,7.7928 160 | 11.892,10.698 161 | 2.1111,0.38718 162 | -1.6399,-0.42906 163 | -0.30148,-1.1122 164 | -2.2778,0.48817 165 | -1.1238,-0.58744 166 | -4.9583,-1.2958 167 | 0.41755,0.60856 168 | 1.3532,-1.1048 169 | 0.48178,0.10315 170 | 0.7922,1.1213 171 | 10.611,8.725 172 | 2.0278,-0.60708 173 | -0.41963,0.80034 174 | 1.1987,-0.91942 175 | 11.518,11.664 176 | 8.9425,8.7853 177 | 12.462,13.168 178 | 11.061,12.716 179 | -1.3162,-1.1486 180 | -0.01073,0.93408 181 | 10.989,8.7617 182 | -0.48039,0.45034 183 | 13.911,14.557 184 | 0.015403,1.2147 185 | -0.36643,-0.12918 186 | -0.41089,-0.67534 187 | -0.75154,0.65479 188 | -1.2364,-1.2932 189 | -0.78856,0.15026 190 | 11.445,9.8688 191 | 0.059445,-0.62995 192 | 11.71,11.78 193 | 2.0037,1.5791 194 | 10.196,11.048 195 | 0.38962,1.2615 196 | 2.144,0.51025 197 | 10.971,10.5 198 | 11.182,11.947 199 | 10.81,10.582 200 | -1.7969,-0.58581 201 | -0.91626,-1.2894 202 | -0.82475,-0.38538 203 | 2.8649,2.0735 204 | 1.4365,0.57657 205 | -1.2092,-1.0716 206 | 10.316,7.0517 207 | 9.4081,8.8326 208 | 10.614,10.148 209 | 10.755,9.5084 210 | 2.5004,1.1629 211 | 1.6146,0.20625 212 | -0.72503,-0.32215 213 | -1.9858,-0.55852 214 | 10.79,8.525 215 | -1.2818,0.51579 216 | -0.62974,0.99725 217 | 2.3818,0.63452 218 | -1.6437,-1.353 219 | -0.39555,-2.0398 220 | 2.0967,0.76615 221 | -0.29139,-0.48363 222 | -2.4906,-0.23157 223 | 9.7825,12.563 224 | 10.854,13.09 225 | 8.4444,7.9962 226 | 8.6201,9.0882 227 | -3.2167,-1.1843 228 | 10.234,10.68 229 | 0.81343,0.67613 230 | 8.7198,7.7557 231 | 9.0661,10.439 232 | -0.64991,0.059583 233 | 1.2564,1.3126 234 | 11.808,10.953 235 | 12.027,13.97 236 | 0.11952,-0.66682 237 | 11.42,9.5358 238 | 0.84168,-0.16381 239 | 0.61706,-0.17321 240 | 11.324,9.5352 241 | -0.95662,0.85361 242 | 8.5391,10.838 243 | 0.19967,-0.51781 244 | 8.0018,5.9719 245 | 0.89023,-0.24475 246 | 2.6407,0.54173 247 | 2.8164,0.13422 248 | -0.11156,-0.36766 249 | 10.221,9.032 250 | 8.0697,4.5593 251 | -0.35007,0.41689 252 | 9.315,13.082 253 | 1.3545,0.59385 254 | 1.3167,-0.024418 255 | -0.78458,-0.32475 256 | 9.7956,9.658 257 | 8.5628,10.288 258 | 1.1959,0.12932 259 | 9.1653,8.08 260 | 1.7803,0.22883 261 | -0.66216,-0.57398 262 | 3.6454,1.8939 263 | 3.5648,2.1152 264 | 11.244,11.425 265 | -0.062117,-0.6297 266 | 1.45,0.4668 267 | 2.8962,2.2718 268 | 8.3232,9.2982 269 | 10.375,10.797 270 | 3.1597,0.47564 271 | -1.4427,-1.2402 272 | 9.3593,9.6148 273 | 10.456,10.413 274 | 10.444,11.321 275 | 2.2995,0.56544 276 | 0.24704,-0.74217 277 | 11.954,11.715 278 | -0.93401,-0.31706 279 | 0.37879,0.69 280 | -1.2502,-1.1035 281 | -0.047139,-0.15358 282 | 10.198,11.903 283 | -1.0622,-1.3026 284 | 8.7242,9.9241 285 | -0.95088,0.34972 286 | 0.50594,-0.085124 287 | -2.2467,-1.0332 288 | 2.0638,-1.0716 289 | 1.9378,0.0044115 290 | -0.15006,0.90016 291 | 10.909,10.963 292 | -1.2746,-2.4533 293 | 9.3045,10.078 294 | -1.9396,-1.2905 295 | -0.58494,0.34308 296 | 3.0388,0.56839 297 | 11.587,13.263 298 | 10.713,11.561 299 | 8.0037,8.853 300 | 9.1023,11.857 301 | 10.869,11.524 302 | 1.1229,0.62106 303 | 0.40051,-0.23303 304 | 1.6059,0.89585 305 | 1.5829,1.0521 306 | -1.2266,-0.41043 307 | -0.99478,0.59842 308 | 11.33,11.561 309 | -1.0433,-0.77696 310 | -1.7069,0.38789 311 | 11.098,12.001 312 | 9.0689,6.8857 313 | 0.32745,0.84347 314 | 11.942,10.882 315 | 8.879,6.7268 316 | 9.4897,9.1324 317 | 1.0752,-1.4756 318 | 2.1388,1.5715 319 | -2.6397,-0.14479 320 | 10.573,9.9315 321 | 1.9339,0.90929 322 | -0.82771,-0.95587 323 | 1.3121,0.45904 324 | -2.1446,-0.27245 325 | 10.942,11.411 326 | 9.8575,10.735 327 | -2.5694,-1.6007 328 | 0.95599,1.283 329 | 3.3975,1.5752 330 | -1.7282,-1.3337 331 | 0.9142,0.63354 332 | 2.4401,1.7105 333 | 0.19348,1.168 334 | 12.28,14.746 335 | -1.0904,-0.6794 336 | -2.5858,0.09042 337 | 0.30952,-0.64219 338 | -0.80825,-0.39581 339 | 1.7048,0.78087 340 | 9.4883,9.74 341 | -1.2066,-1.4817 342 | 9.2599,11.423 343 | -0.56779,0.24884 344 | -0.89877,-0.59552 345 | -2.0233,0.28487 346 | -1.3689,-0.64005 347 | 1.4963,0.080568 348 | -1.7216,-1.7366 349 | -4.1958,-1.9871 350 | 11.14,9.2837 351 | 10.105,8.3873 352 | 9.3512,9.5977 353 | 2.3244,1.5496 354 | 11.125,6.3263 355 | 1.3723,0.75013 356 | 0.030338,-0.23569 357 | 1.8264,0.91811 358 | -2.0108,1.2919 359 | 10.382,9.4415 360 | -4.1872,-2.528 361 | -1.6833,-1.9736 362 | -0.68108,-0.7007 363 | 0.56109,0.50055 364 | -0.41923,-0.61563 365 | 1.7385,1.1678 366 | -0.040318,-0.13913 367 | -0.83684,-0.70044 368 | 1.365,0.54762 369 | -0.26478,0.35364 370 | -3.0324,-0.60832 371 | 0.8119,1.3713 372 | -2.8607,-1.5543 373 | -0.77505,0.57019 374 | -1.0489,-0.018074 375 | 1.7175,0.15192 376 | 0.27768,-0.5676 377 | 2.2959,0.40634 378 | 0.40509,-1.3458 379 | -0.41002,-1.4566 380 | 10.003,10.001 381 | 0.84831,0.57944 382 | 1.3714,1.6437 383 | 10.719,12.305 384 | -1.6246,-1.0567 385 | -1.4727,-2.6044 386 | 13.344,14.799 387 | 9.5254,9.9158 388 | -0.49913,-0.9268 389 | 9.2946,9.9324 390 | -1.3547,0.17663 391 | 8.3999,6.822 392 | 10.106,12.07 393 | -0.45312,1.5963 394 | -1.1372,-0.7055 395 | -2.4188,0.11388 396 | 6.611,9.0108 397 | 10.199,9.723 398 | 8.7469,8.9913 399 | -0.34343,-0.71646 400 | -0.53076,-1.0147 401 | 8.5367,8.2381 402 | 1.603,1.1023 403 | 10.32,8.793 404 | 1.6329,0.28218 405 | 11.054,10.693 406 | -0.48584,0.0081015 407 | 0.89703,0.4825 408 | 8.1611,8.7571 409 | 8.4774,6.7827 410 | 0.28258,0.22742 411 | -5.3428,-1.8125 412 | 10.921,7.1012 413 | -2.0667,-0.42513 414 | 0.58992,0.24668 415 | 11.013,11.17 416 | 9.929,12.566 417 | 2.4557,0.89529 418 | 10.857,10.529 419 | -1.1362,-0.67705 420 | -0.40885,-0.31452 421 | 9.444,10.501 422 | 11.682,13.164 423 | 9.5595,7.1283 424 | -1.1505,-0.39676 425 | 0.21475,-0.58978 426 | -0.52916,-0.6533 427 | 8.7746,8.5221 428 | 7.6782,6.5015 429 | 0.41163,-0.7772 430 | 8.0315,9.6608 431 | 11.858,12.02 432 | 9.0699,6.824 433 | -0.46704,-0.24933 434 | -0.42196,0.14468 435 | 2.2759,1.3063 436 | -2.994,-0.56152 437 | 8.68,8.2079 438 | -0.99092,0.67667 439 | 7.2856,4.4035 440 | -0.65419,-0.92223 441 | -0.015616,0.54813 442 | 0.2371,0.31447 443 | -2.2204,-0.41368 444 | 1.2572,0.96866 445 | 10.148,5.9457 446 | 11.186,10.569 447 | 9.3572,11.484 448 | -1.6694,-1.0587 449 | 8.6755,6.9831 450 | 9.6666,12.089 451 | -1.1031,-0.74418 452 | 3.1133,0.75763 453 | -0.65778,-0.39886 454 | 8.1326,7.6516 455 | -0.37015,0.91442 456 | -3.2867,-0.64522 457 | -0.21077,-1.0972 458 | 0.76825,0.49618 459 | -2.1733,-1.4545 460 | -0.7405,0.071444 461 | -0.27272,-0.83216 462 | -1.6567,-0.15536 463 | 11.52,15.102 464 | 1.5982,1.1921 465 | -2.732,-1.986 466 | 2.4702,-0.027343 467 | -0.95069,-1.1872 468 | 10.674,12.375 469 | 10.424,9.2215 470 | 1.056,0.38923 471 | 3.5817,-0.39342 472 | 12.206,12.013 473 | -1.0457,-0.4063 474 | 11,13.697 475 | 11.683,14.6 476 | 9.9602,8.6645 477 | 9.638,6.8926 478 | 9.3394,9.3502 479 | 10.783,10.045 480 | 10.73,10.106 481 | 8.2055,7.4727 482 | -0.46989,0.24668 483 | 8.2087,7.7711 484 | 12.309,9.5502 485 | 9.6189,8.9292 486 | 10.928,10.611 487 | 0.36382,-0.34498 488 | 1.1407,0.63781 489 | -0.072136,-0.51734 490 | -0.20327,-1.7556 491 | 10.563,14.887 492 | 9.6402,7.4497 493 | 9.5213,11.262 494 | -0.75247,0.41383 495 | -0.76819,-0.31696 496 | -1.4354,0.70076 497 | 0.56412,0.58213 498 | 11.461,10.897 499 | 0.45928,-0.24575 500 | 2.2475,1.5362 501 | 1.9172,-0.64015 502 | 1.1617,0.091992 503 | 0.50433,-0.72069 504 | -0.99133,-0.48731 505 | 10.721,11.919 506 | 9.3279,12.597 507 | -0.98434,-0.10032 508 | -0.93903,0.13526 509 | 1.3309,0.39815 510 | 1.6059,0.078048 511 | -3.5131,-0.85105 512 | -1.4694,-0.95411 513 | 11.156,12.418 514 | 11.171,14.056 515 | 2.6643,0.019684 516 | 9.6759,10.169 517 | -0.94457,-0.37196 518 | 0.70843,1.4116 519 | 1.2757,0.066177 520 | 9.3106,9.2311 521 | 0.80892,0.40637 522 | 9.4959,10.825 523 | 1.2816,0.69852 524 | 1.7048,-0.34499 525 | 2.9136,0.62342 526 | 0.42359,0.55261 527 | -0.78329,-0.10365 528 | 10.078,9.4195 529 | 1.1799,1.0316 530 | 0.56163,-1.1847 531 | -6.2382,-1.863 532 | 2.6737,2.2334 533 | 0.19491,0.58696 534 | -1.7565,0.13974 535 | -0.52928,0.93948 536 | -0.25321,-1.0038 537 | 0.9101,-0.2894 538 | -1.8308,-0.73535 539 | 10.826,13.314 540 | -0.53652,-0.43135 541 | 8.7371,9.1586 542 | 0.46789,1.1172 543 | 11.742,9.6782 544 | 1.1122,-0.10268 545 | 10.611,12.166 546 | 10.53,11.474 547 | 10.697,8.7516 548 | -0.073601,-0.16876 549 | -0.24795,-0.85314 550 | -1.9222,-1.0068 551 | 2.469,0.68656 552 | 8.2637,9.159 553 | 9.1853,12.452 554 | -2.3208,0.054816 555 | 9.4396,9.1731 556 | -0.12116,-0.12076 557 | 13.075,11.6 558 | 7.9784,7.5607 559 | 10.263,10.379 560 | 1.2122,0.68082 561 | -0.3222,0.20374 562 | 0.093964,0.53349 563 | 3.5896,2.3664 564 | 0.58499,-0.4564 565 | -1.763,0.28705 566 | -0.12293,0.29995 567 | 1.6824,0.43904 568 | -0.7505,-1.2494 569 | -2.2061,-1.0585 570 | -0.93066,-0.24114 571 | 0.79897,1.4529 572 | -1.5737,-0.082446 573 | 12.118,12.71 574 | -1.6352,-1.1802 575 | 0.1388,1.326 576 | 11.303,13.611 577 | 0.13707,-0.38809 578 | -0.28624,0.48784 579 | -0.66878,1.7104 580 | -1.606,-0.73281 581 | 10.533,10.06 582 | 1.1044,-0.27452 583 | 11.293,9.376 584 | -0.90345,-1.3285 585 | 8.9555,5.6934 586 | 0.78834,-0.59613 587 | -1.6469,-1.1238 588 | 3.47,-0.15794 589 | 0.3477,-0.65309 590 | 0.63645,0.60857 591 | -1.242,-0.28138 592 | -0.30588,-0.21642 593 | -1.1603,-0.23348 594 | -3.3211,-0.0028003 595 | 1.6456,0.5109 596 | 0.70771,0.59003 597 | 3.2659,-0.37532 598 | 9.8936,7.9209 599 | -0.97605,-1.2099 600 | 1.0455,1.3268 601 | 6.8692,7.2372 602 | -0.24706,-0.54485 603 | 7.8706,4.7922 604 | -0.39668,-0.28623 605 | 0.95151,1.5426 606 | 11.787,14.262 607 | 0.32515,-0.031308 608 | -1.0264,-0.62467 609 | -0.8361,-0.44166 610 | 10.638,7.5025 611 | 0.17169,1.5088 612 | 7.5432,10.617 613 | 10.164,8.3755 614 | -0.97502,-0.59988 615 | -2.4054,-0.93598 616 | -2.2532,0.049141 617 | 10.677,16.335 618 | 8.0529,7.121 619 | 1.4695,-1.0377 620 | 0.24501,0.60915 621 | -0.47303,1.4617 622 | 0.2507,0.089232 623 | 12.154,11.859 624 | 0.39827,-0.88783 625 | 9.4925,8.0424 626 | 1.7167,-0.44775 627 | 0.78138,0.61012 628 | -3.1283,-1.1265 629 | 9.3107,8.1099 630 | 8.8906,9.1636 631 | 1.3684,-1.2128 632 | -0.09445,1.1745 633 | 12.829,12.275 634 | 6.43,7.7245 635 | 0.34606,0.64937 636 | -1.8323,-0.3003 637 | 7.239,7.1065 638 | 9.1919,9.3163 639 | 0.98061,0.22193 640 | -0.66078,0.41192 641 | -0.0041177,1.1058 642 | 10.247,11.078 643 | 9.7882,11.102 644 | -0.23209,-0.93697 645 | 1.4824,2.4269 646 | 11.01,11.332 647 | 8.692,10.376 648 | 8.1569,12.411 649 | -0.67355,-0.065089 650 | -0.68551,-0.81328 651 | 2.389,0.79288 652 | -1.6841,0.22568 653 | 0.15863,-0.89822 654 | 2.3574,-0.19343 655 | 1.7542,0.73473 656 | 1.463,0.41416 657 | 8.3176,8.5595 658 | -0.56983,0.48957 659 | 1.3246,0.73792 660 | 2.7899,-0.61416 661 | -0.53301,-1.1595 662 | -2.7167,-0.71502 663 | -0.53188,-0.6688 664 | -0.037202,0.31909 665 | -1.2358,-1.0284 666 | 8.5188,8.3466 667 | 9.3699,10.068 668 | -2.0101,0.50632 669 | 0.26508,0.46765 670 | 2.0585,1.6941 671 | 1.7484,2.0233 672 | 0.76907,-0.093149 673 | -1.542,-0.72629 674 | -0.80662,-1.3123 675 | -3.5075,-1.3061 676 | 10.191,8.7383 677 | 9.8789,8.9258 678 | 10.999,11.259 679 | 8.7583,7.2092 680 | -0.44244,-0.39248 681 | 8.97,9.0633 682 | -0.58845,-0.13865 683 | -0.11818,-0.28315 684 | 0.27195,0.95054 685 | 9.4235,11.104 686 | 2.2175,0.26318 687 | 0.3886,2.5398 688 | 2.2992,-0.12376 689 | 1.8207,1.3173 690 | 12.609,16.187 691 | -1.9935,-0.80455 692 | 0.14561,0.41963 693 | -3.0819,-0.7201 694 | -1.1523,-0.45696 695 | -0.60453,-0.6925 696 | -2.391,-1.783 697 | -2.4237,-0.23609 698 | -2.611,-0.69035 699 | 12.502,12.509 700 | 0.21509,0.089809 701 | 0.35519,0.5766 702 | -0.59025,-0.8397 703 | -0.45148,0.60884 704 | 9.9144,10.075 705 | 8.5123,8.4557 706 | -0.89062,-0.10005 707 | 0.14361,1.5545 708 | -3.2398,-1.3208 709 | 0.11069,0.056754 710 | 0.012543,-0.69459 711 | 1.8049,1.0622 712 | -2.0184,-0.94972 713 | -0.47894,0.19217 714 | 0.59871,-0.54871 715 | 11.249,13.018 716 | 10.522,9.3465 717 | -1.9956,-1.2913 718 | 0.32862,-0.14048 719 | 0.62956,1.0459 720 | 0.91787,0.052711 721 | -0.3908,-1.3326 722 | 8.7325,8.9881 723 | 8.6205,9.9809 724 | 13.365,14.752 725 | 1.4269,0.14623 726 | 1.2949,1.1348 727 | 0.49076,1.406 728 | 2.3597,1.7185 729 | 0.75225,1.2633 730 | -0.85484,-0.56797 731 | 9.4822,7.0666 732 | -0.16932,-0.81292 733 | -1.0113,0.41581 734 | 0.074171,-1.0791 735 | 6.3792,7.497 736 | -3.0649,-0.54317 737 | -1.1793,-0.73239 738 | -1.0675,-1.6792 739 | -0.39776,-0.049936 740 | 8.0253,6.8174 741 | 10.256,12.357 742 | -1.3961,-0.25802 743 | 1.6447,1.8525 744 | -0.88066,-0.15222 745 | 0.81226,-0.88806 746 | -1.9343,-1.1139 747 | -1.5646,-0.5326 748 | -1.5003,0.010918 749 | 0.47999,-0.28193 750 | 9.8141,7.8247 751 | -2.7672,-1.8394 752 | 10.12,10.756 753 | -0.15007,-0.063316 754 | -0.30821,-0.39408 755 | 10.107,11.627 756 | -0.70874,-1.0286 757 | 0.48319,0.32624 758 | -1.6864,-1.5827 759 | 9.8568,10.875 760 | 11.974,11.56 761 | -0.92433,0.088228 762 | 0.16774,-0.16627 763 | -0.4483,-1.0538 764 | -3.6715,-1.3388 765 | 11.032,8.8347 766 | 1.1773,0.68148 767 | 10.296,10.926 768 | -0.52629,-1.6531 769 | -1.3209,-0.54223 770 | 8.7699,10.464 771 | 1.0858,0.01663 772 | 0.023737,0.4494 773 | 2.1313,2.0215 774 | -1.3752,-0.91287 775 | 8.7986,5.5883 776 | 0.40662,0.51123 777 | 3.059,0.36599 778 | 0.065528,-0.98242 779 | 2.3638,0.97324 780 | -0.49236,-1.5165 781 | -1.6891,-0.86431 782 | 0.30833,-0.86587 783 | -2.0631,-0.18043 784 | 11.193,11.646 785 | -1.3694,-1.1926 786 | 13.905,14.327 787 | 0.69911,0.2001 788 | 0.9545,1.2179 789 | 0.261,-0.32815 790 | 10.099,9.1684 791 | -2.6108,-1.7986 792 | -0.82371,0.06555 793 | 1.1348,-1.5011 794 | -0.36781,0.17515 795 | -0.25971,-0.066541 796 | -1.6679,-0.21365 797 | 10.158,11.661 798 | 8.3855,8.3275 799 | 10.322,8.1033 800 | 1.513,1.2989 801 | 10.108,12.819 802 | 10.585,9.6343 803 | 0.61627,-1.975 804 | -1.0761,-0.17904 805 | 10.002,13.065 806 | 0.29459,-0.020221 807 | 12.282,13.77 808 | 0.25978,-0.26381 809 | -1.3351,1.2465 810 | 9.1425,9.2811 811 | 1.7877,0.37461 812 | 11.365,12.19 813 | 10.882,10.31 814 | 1.4061,0.25866 815 | -2.9511,0.092719 816 | 11.251,10.872 817 | 11.433,10.955 818 | 7.9415,6.1853 819 | 0.2346,-0.10326 820 | 0.20347,0.48077 821 | -0.92582,-0.74585 822 | 6.7401,6.6479 823 | 1.2181,1.1644 824 | 0.97299,0.36884 825 | 10.146,8.3405 826 | 12.037,13.945 827 | 9.0607,7.815 828 | -0.11654,-0.76448 829 | 10.497,9.9001 830 | -1.565,-1.0863 831 | -2.8789,-1.0173 832 | 6.4055,7.806 833 | 1.5805,0.15631 834 | -0.11239,-1.1868 835 | 9.9929,6.7723 836 | -1.7137,-1.2951 837 | -2.6579,-1.4866 838 | 3.2542,1.7956 839 | -2.0536,-0.81762 840 | -1.701,-0.63282 841 | -0.12978,0.30842 842 | 11.593,10.597 843 | 11.377,10.559 844 | 0.095071,0.10421 845 | 10.232,9.6315 846 | -1.5481,1.3985 847 | 1.9075,0.63346 848 | 8.4071,7.9578 849 | -0.73202,-1.3871 850 | 11.894,9.3909 851 | 1.6275,-1.6238 852 | 1.451,-0.63939 853 | 1.5408,1.3584 854 | 10.268,12.338 855 | 11.314,10.031 856 | -2.314,-1.1185 857 | 8.3903,6.8234 858 | -1.5363,-0.74661 859 | 11.941,12.861 860 | -1.7295,-0.65271 861 | 10.217,14.5 862 | 3.7792,1.6991 863 | -2.7568,-1.0807 864 | 0.5877,0.4077 865 | 10.416,8.9013 866 | -0.60003,-1.1311 867 | 2.9026,1.6814 868 | 8.5059,10.594 869 | -2.353,-1.4907 870 | -0.4839,-0.28363 871 | 8.752,7.9997 872 | 1.554,0.59434 873 | 1.9266,1.1269 874 | -1.7709,0.017399 875 | -0.86281,0.29757 876 | -0.30387,0.055169 877 | 12.14,9.4232 878 | 9.2003,11.421 879 | 9.0449,9.8673 880 | 0.38109,0.51351 881 | -2.118,-1.3528 882 | 3.6901,2.3619 883 | 3.6316,0.81267 884 | 10.346,10.28 885 | 11.152,11.241 886 | -2.9039,-0.27536 887 | 9.8793,10.583 888 | 0.44888,0.31419 889 | 7.2135,7.6143 890 | -0.76878,0.1872 891 | 10.109,10.273 892 | 1.2696,0.25233 893 | 10.293,9.1981 894 | 0.78376,-0.22509 895 | 9.1791,8.9771 896 | 1.704,1.1602 897 | -0.35483,-0.37404 898 | 7.7211,9.7842 899 | 1.0582,1.742 900 | -3.0331,-2.2057 901 | 10.828,9.245 902 | 9.9523,11.089 903 | 1.9489,1.8258 904 | 0.51614,-0.55103 905 | 0.72976,1.4119 906 | 1.3062,1.7216 907 | -1.192,-1.0587 908 | 8.6874,5.3612 909 | 0.21424,-0.086869 910 | 9.2518,10.857 911 | -0.72356,-0.37336 912 | 0.12287,0.16873 913 | 0.81809,-0.44241 914 | 0.097576,-1.3156 915 | -1.2398,0.8849 916 | 0.076353,-0.69582 917 | 11.617,11.397 918 | 1.5357,-0.17044 919 | 9.7666,8.4611 920 | -3.2968,0.19517 921 | 11.243,11.649 922 | 9.9144,9.6174 923 | 9.4126,7.2641 924 | -3.461,0.10029 925 | -1.2067,0.81741 926 | 1.0313,0.0031946 927 | -0.84665,-0.81568 928 | 7.7838,6.5926 929 | 8.7091,10.877 930 | 0.68609,-0.54795 931 | -0.57743,-1.2503 932 | 10.9,14.304 933 | 9.1112,8.5846 934 | -0.9928,0.8453 935 | 0.1409,0.79755 936 | 11.786,11.905 937 | 4.3866,0.98394 938 | -0.056458,-0.52843 939 | 0.41853,0.018107 940 | 7.6858,5.9527 941 | 0.49144,-1.1589 942 | 1.8287,0.56397 943 | -0.15127,-0.10767 944 | 0.14385,0.90046 945 | 10.296,10.652 946 | 12.982,14.638 947 | -0.3469,-0.68627 948 | 0.9152,1.7382 949 | 0.090048,-1.1134 950 | 10.999,15.232 951 | 0.8302,-1.3283 952 | 9.4581,9.6798 953 | 8.5882,8.4947 954 | 8.3649,6.6688 955 | 8.321,8.4805 956 | 11.978,10.727 957 | 11.06,14.136 958 | -0.031092,0.082962 959 | -0.32887,-0.50207 960 | -0.026179,1.3061 961 | 3.0342,0.96952 962 | 8.131,8.0432 963 | -4.5856,-0.71 964 | 9.004,6.9836 965 | 3.0505,1.3927 966 | 9.1502,9.7377 967 | -0.41003,0.24711 968 | -1.2204,-0.38539 969 | -3.5151,-0.36111 970 | 11.928,10.438 971 | 8.6872,9.0007 972 | 11.796,10.128 973 | 0.23679,0.77441 974 | -0.30941,0.27922 975 | 12.447,11.616 976 | 10.349,8.7338 977 | -0.48541,0.12716 978 | 10.325,11.548 979 | 10.096,11.076 980 | 9.6602,11.056 981 | -1.6289,-0.93551 982 | -1.5132,-0.14215 983 | 2.8784,0.93817 984 | -0.87346,-1.4483 985 | 9.6201,7.8188 986 | -0.70492,0.76406 987 | 0.92164,1.5002 988 | 11.233,9.0491 989 | 0.44072,0.33546 990 | 1.5931,-0.68289 991 | 0.721,0.34599 992 | 12.581,15.37 993 | -0.30127,0.87618 994 | 9.7431,10.859 995 | -3.5207,-1.4565 996 | -2.7292,-0.80484 997 | 8.3003,7.4942 998 | 1.1984,0.19762 999 | 10.787,11.55 1000 | 1.1209,-0.14348 1001 | -------------------------------------------------------------------------------- /src/GMM/data/Test2.csv: -------------------------------------------------------------------------------- 1 | 4.4552,14.744 2 | 16.681,20.624 3 | 1.5596,9.1421 4 | 9.9942,17.596 5 | 3.3958,11.135 6 | 2.4238,10.513 7 | 2.4306,9.9394 8 | 9.9264,18.139 9 | 0.97096,7.9364 10 | 4.3155,11.764 11 | 1.4786,8.4429 12 | 1.4438,9.6364 13 | 11.444,19.481 14 | 2.7425,13.973 15 | 2.6214,11.203 16 | 2.0176,10.175 17 | -0.17831,9.8289 18 | 17.348,21.172 19 | 1.2593,9.288 20 | 14.397,20.378 21 | 0.77319,8.1834 22 | 2.2022,9.3108 23 | 2.5864,13.321 24 | 1.7422,12.508 25 | 13.9,19.363 26 | 1.8958,12.212 27 | 1.7904,8.7043 28 | 1.7363,7.9632 29 | 0.91621,7.728 30 | 1.8173,9.1145 31 | 2.0523,10.811 32 | 1.3857,9.4037 33 | -0.049074,6.8795 34 | 2.213,12.106 35 | 3.1176,10.204 36 | 2.4719,10.441 37 | 2.0672,11.696 38 | 2.5884,9.0692 39 | 1.8017,13.951 40 | 16.26,20.278 41 | 16.232,19.68 42 | 13.12,19.85 43 | 2.5771,11.835 44 | 2.1161,11.902 45 | 2.5953,8.769 46 | 2.7314,9.5481 47 | 20.211,21.955 48 | 2.4473,10.96 49 | 1.377,9.1285 50 | 1.1086,6.9903 51 | 1.8211,9.5289 52 | 1.5357,9.1039 53 | 16.968,20.451 54 | 16.647,20.055 55 | 3.4731,8.741 56 | 16.695,20.615 57 | 1.6017,7.8945 58 | 1.3215,7.8117 59 | 3.1477,11.289 60 | 2.0742,8.7463 61 | 10.668,18.701 62 | 1.4027,9.6864 63 | 14.217,20.613 64 | 15.36,20.841 65 | 9.4502,16.988 66 | 1.3408,10.231 67 | 1.5028,10.184 68 | 16.871,20.337 69 | 14.536,19.732 70 | 2.4277,10.037 71 | 18.353,21.502 72 | 0.42103,8.7261 73 | 3.0516,8.4531 74 | 2.7386,11.231 75 | 15.336,19.415 76 | 1.9273,10.629 77 | 17.173,21.095 78 | 0.14773,7.4874 79 | 17.989,21.441 80 | 12.566,18.999 81 | 16.815,20.893 82 | 18.888,21.327 83 | 13.337,18.931 84 | 12.558,18.096 85 | 12.435,18.741 86 | 2.833,9.5568 87 | 14.517,19.83 88 | -0.047861,9.043 89 | 14.612,20.452 90 | 1.2925,10.519 91 | 1.968,11.096 92 | 2.4242,10.776 93 | 13.634,20.379 94 | 2.4934,8.6684 95 | 1.6227,10.283 96 | 13.862,20.423 97 | 2.3872,11.731 98 | 2.1424,7.1489 99 | 3.5228,10.861 100 | 1.2565,10.844 101 | 13.307,19.413 102 | 0.37897,8.7378 103 | 2.5454,8.2396 104 | 2.1759,8.5501 105 | 1.8259,11.127 106 | 3.4648,9.5914 107 | 2.6195,12.091 108 | 0.45438,6.8235 109 | 1.5678,8.4618 110 | 4.1206,11.045 111 | 17.807,21.843 112 | 2.4581,10.727 113 | 2.5397,11.778 114 | 15.819,20.206 115 | 3.152,10.911 116 | 15.986,20.322 117 | 2.2849,10.693 118 | 2.6802,9.3402 119 | 1.4634,9.5471 120 | 2.5181,9.4938 121 | 0.59717,8.5038 122 | 3.4848,9.8498 123 | 17.033,20.689 124 | 0.43166,7.9945 125 | 1.8529,8.5649 126 | 1.6405,7.9014 127 | 13.887,19.753 128 | 19.67,22.419 129 | 4.0285,10.213 130 | 16.118,19.804 131 | 10.563,17.913 132 | -0.41486,5.5638 133 | 12.858,18.681 134 | 2.5013,12.282 135 | 10.413,18.727 136 | 1.7394,9.9889 137 | 16.43,20.397 138 | 1.493,9.2113 139 | 0.92128,10.692 140 | 0.63723,8.959 141 | 3.5541,12.135 142 | 14.655,19.395 143 | 14.187,19.145 144 | 3.0343,12.518 145 | 2.672,8.535 146 | 2.3623,8.7282 147 | 17.306,20.951 148 | 2.4527,9.4906 149 | 1.6577,9.1726 150 | 13.288,18.912 151 | 2.6991,12.993 152 | 17.086,20.475 153 | 1.4739,8.1008 154 | 11.546,18.596 155 | 13.92,19.295 156 | 0.6788,10.467 157 | 3.3635,10.71 158 | 13.367,18.774 159 | 2.1688,10.947 160 | 11.279,18.624 161 | 0.43384,6.4251 162 | 13.91,19.679 163 | 1.3872,9.2542 164 | 2.0511,8.861 165 | 1.6098,9.7846 166 | 2.9718,12.94 167 | 3.1988,10.564 168 | 14.401,19.334 169 | 12.246,19.66 170 | 0.96209,9.0582 171 | 14.733,19.78 172 | 20.118,21.824 173 | 15.418,19.606 174 | 1.9819,7.4526 175 | 17.373,21.191 176 | 1.2936,8.8833 177 | 17.759,21.701 178 | -0.55483,6.5433 179 | 1.2012,10.279 180 | 1.5452,9.0741 181 | 0.38663,9.6581 182 | 2.2711,10.227 183 | 13.573,19.595 184 | 1.559,10.847 185 | 1.1926,9.0376 186 | 2.9826,7.6674 187 | 3.0341,10.415 188 | 0.98637,10.777 189 | 15.425,19.274 190 | 3.9304,10.994 191 | 14.733,20.127 192 | 14.046,19.382 193 | 1.3985,9.115 194 | 1.6948,7.9498 195 | 3.5466,12.589 196 | 3.2693,10.037 197 | 1.0685,6.3471 198 | 10.399,17.717 199 | 11.276,19.024 200 | 10.359,18.54 201 | 13.694,19.731 202 | 17.818,21.24 203 | 16.132,20.841 204 | 12.592,19.025 205 | 0.34127,8.076 206 | 3.6437,11.98 207 | 0.452,6.3443 208 | 15.674,19.633 209 | 3.3256,9.7074 210 | 3.0866,10.891 211 | 1.0388,8.2255 212 | 3.4512,9.5687 213 | 2.9181,11.553 214 | 11.678,19.239 215 | 3.1538,11.115 216 | 12.442,18.667 217 | 3.2168,9.2725 218 | 0.98891,10.165 219 | 16.077,20.044 220 | 3.2451,11.821 221 | 14.733,19.195 222 | 1.4833,8.331 223 | 3.9032,11.942 224 | 14.562,19.886 225 | 2.3986,9.9334 226 | 3.8357,12.907 227 | 13.374,19.157 228 | 1.2136,10.047 229 | 13.9,19.872 230 | 17.616,21.109 231 | 0.89292,9.1488 232 | 2.1574,11.777 233 | 2.1229,13.288 234 | 12.468,18.936 235 | 1.3134,9.1951 236 | 14.448,19.939 237 | 12.892,19.336 238 | 3.5314,12.295 239 | 2.7661,9.6912 240 | 15.754,21.162 241 | 1.0617,9.1217 242 | 2.4638,12.004 243 | -0.20198,9.452 244 | 1.8406,10.74 245 | 18.661,22.378 246 | 14.98,20.365 247 | 4.5325,15.782 248 | 1.3442,13.36 249 | 2.4076,11.2 250 | 1.593,9.3977 251 | 14.608,20.471 252 | 15.524,19.951 253 | 2.6195,11.745 254 | 0.91951,10.778 255 | 1.0353,8.7071 256 | 3.2313,11.875 257 | 2.1944,9.0076 258 | 14.886,19.64 259 | 8.9363,17.043 260 | 2.3647,8.6249 261 | -0.30001,6.6436 262 | 0.35835,8.4339 263 | 9.2392,17.157 264 | 13.739,19.549 265 | 1.4041,9.3622 266 | 14.481,19.415 267 | 1.0831,5.8821 268 | 2.15,9.5916 269 | 14.389,19.773 270 | 16.145,20.284 271 | 15.095,20.022 272 | 17.616,21.909 273 | 2.3525,10.316 274 | 4.0971,8.9014 275 | 1.8146,7.7531 276 | 18.742,22.303 277 | 14.374,19.879 278 | 14.619,19.259 279 | 11.742,18.861 280 | 2.3222,12.036 281 | 3.2897,12.128 282 | 2.278,11.073 283 | 14.553,20.33 284 | 4.178,11.764 285 | 1.5009,7.9699 286 | 2.2934,7.5799 287 | 2.0346,8.6109 288 | 3.5786,14.243 289 | 1.8848,9.273 290 | 2.2437,10.935 291 | 14.626,20.054 292 | 1.3171,8.3451 293 | 1.9026,6.6243 294 | 1.5836,11.201 295 | 0.15307,6.6354 296 | 2.0288,10.146 297 | 1.8016,12.252 298 | 16.716,21.26 299 | 2.132,9.1527 300 | 3.7071,11.548 301 | 0.12452,10.329 302 | 0.89898,9.5527 303 | 1.5549,9.1168 304 | 2.92,9.6053 305 | 1.5963,9.038 306 | 2.5255,10.729 307 | 2.7591,11.602 308 | 1.0583,7.4328 309 | 3.7943,10.366 310 | 16.662,20.722 311 | 2.3666,8.8188 312 | 3.3117,11.083 313 | 1.0477,5.1684 314 | 2.0875,9.5013 315 | 14.097,19.685 316 | 3.1158,12.068 317 | 13.893,18.97 318 | 20.972,22.779 319 | 2.0822,8.8157 320 | 2.2655,7.3971 321 | 3.5801,10.459 322 | 1.8355,8.9172 323 | 1.0743,7.685 324 | 17.162,21.189 325 | 2.2089,12.985 326 | 17.79,21.068 327 | 14.425,18.834 328 | 1.9884,9.4215 329 | 13.281,19.168 330 | 2.2519,11.659 331 | 2.4137,9.1578 332 | 13.68,19.627 333 | 2.0849,11.942 334 | 0.76783,9.5438 335 | 13.021,19.894 336 | 3.3084,12.391 337 | 2.9343,9.0366 338 | 2.3548,11.288 339 | 2.8248,9.9766 340 | 3.5526,10.842 341 | 12.297,18.829 342 | 10.816,18.562 343 | 14.29,19.233 344 | 1.4768,9.2746 345 | 1.412,9.7783 346 | 3.0311,11.047 347 | 0.9086,7.6833 348 | 17.204,20.552 349 | 0.10766,10.15 350 | 14.862,20 351 | 17.768,20.958 352 | 1.5688,10.72 353 | 2.7154,11.104 354 | 1.4365,8.2809 355 | 2.1494,10.707 356 | 17.127,21.304 357 | 2.3518,11.216 358 | 2.7071,10.645 359 | 2.6788,8.6015 360 | 1.9408,10.06 361 | 0.99344,9.9013 362 | 13.274,19.233 363 | 3.4086,11.018 364 | 0.1552,9.3222 365 | 2.7789,8.6391 366 | 1.4157,9.0651 367 | 0.82123,7.9304 368 | 13.43,18.782 369 | 2.1668,12.127 370 | 2.4012,10.391 371 | 12.926,18.704 372 | 2.3509,9.8036 373 | 3.312,11.348 374 | 1.5204,10.626 375 | 4.4771,12.126 376 | 0.3346,8.114 377 | 13.418,19.47 378 | 16.86,20.375 379 | 14.335,19.849 380 | 15.795,20.889 381 | 1.6924,9.3769 382 | 2.5419,11.016 383 | 3.0619,11.018 384 | 1.0098,9.0298 385 | 17.518,20.986 386 | 14.974,19.857 387 | 2.8283,10.254 388 | 11.955,18.311 389 | 2.7408,10.269 390 | 3.1974,9.5362 391 | 2.9742,12.741 392 | -0.068804,9.327 393 | 1.5063,8.2451 394 | 17.476,20.39 395 | 16.264,19.786 396 | 14.89,19.816 397 | 1.7979,9.2797 398 | 2.4746,8.8294 399 | 0.97424,11.526 400 | 3.0193,9.936 401 | 16.899,21.169 402 | -0.13083,7.4692 403 | 15.055,20.058 404 | 1.5912,5.747 405 | 2.2196,10.201 406 | 2.9523,10.862 407 | 2.6014,11.952 408 | 1.3399,8.1709 409 | 1.3748,10.456 410 | 3.7691,11.787 411 | 17.33,21.602 412 | 12.992,18.946 413 | 15.524,20.872 414 | 18.968,20.947 415 | 1.4584,8.8493 416 | 0.94808,7.1788 417 | 2.3166,11.562 418 | 3.2462,11.703 419 | 16.935,21.327 420 | 2.3398,11.786 421 | 0.72188,9.0538 422 | 1.8831,12.965 423 | 15.547,20.54 424 | 2.027,8.7652 425 | 1.0887,8.3839 426 | 4.2535,15.265 427 | 16.358,21.016 428 | 15.996,20.631 429 | 2.6478,11.003 430 | 4.0257,11.876 431 | 16.995,20.519 432 | 14.531,20.425 433 | 0.51769,10.893 434 | 2.3512,11.317 435 | 2.1182,8.4719 436 | 14.989,20.922 437 | 15.139,19.845 438 | 1.6038,9.5898 439 | 3.1108,9.9053 440 | 2.424,10.339 441 | 18.959,22.44 442 | 0.49982,9.9232 443 | 14.277,19.683 444 | 14.663,19.728 445 | 1.8225,7.8292 446 | 18.256,20.65 447 | 2.6258,9.3312 448 | 13.54,18.959 449 | 2.28,11.692 450 | 2.5794,10.933 451 | 1.5081,9.9027 452 | 3.2214,9.1533 453 | 1.6249,11.977 454 | 0.71839,7.1575 455 | 3.1377,9.4813 456 | 11.897,18.924 457 | 16.301,20.463 458 | 1.5312,12.638 459 | 15.401,19.946 460 | 14.361,19.223 461 | -0.063395,7.7953 462 | 16.061,20.179 463 | 3.0909,11.792 464 | 1.4377,6.317 465 | 3.3717,10.654 466 | 2.139,10.516 467 | 16.024,21.133 468 | 13.404,18.982 469 | 3.1144,11.209 470 | 14.978,19.812 471 | 12.303,18.969 472 | 16.031,20.594 473 | 0.83142,8.4083 474 | 16.137,20.34 475 | 1.8981,10.165 476 | 16.454,20.374 477 | 19.353,22.589 478 | 15.342,20.54 479 | 0.52574,7.1783 480 | 2.4512,11.678 481 | 1.9951,10.019 482 | 20.251,22.067 483 | 3.2354,8.98 484 | 16.636,20.931 485 | 2.3044,9.7563 486 | 13.849,19.129 487 | 1.9406,8.3468 488 | 13.557,19.487 489 | 0.93033,9.627 490 | 0.031846,7.5307 491 | 17.616,21.062 492 | 1.8746,7.5555 493 | 15.013,19.579 494 | 2.7177,10.268 495 | 13.315,19.62 496 | 2.006,10.359 497 | 3.0792,11.532 498 | 13.348,18.614 499 | 1.9437,10.681 500 | 2.1886,11.366 501 | 3.0265,10.016 502 | 12.154,19.097 503 | 19.257,21.988 504 | 4.3773,14.702 505 | 12.72,18.817 506 | 2.2213,8.1839 507 | 1.5168,6.067 508 | 2.6207,13.2 509 | 19.531,21.687 510 | 0.81876,9.6422 511 | 2.2474,11.349 512 | 3.2975,10.275 513 | 1.5569,8.887 514 | 0.42899,9.5249 515 | 1.9109,10.43 516 | 15.208,19.439 517 | 15.574,20.546 518 | 1.366,8.0882 519 | 12.573,18.947 520 | 12.621,18.823 521 | 2.4123,12.195 522 | 1.802,8.5326 523 | 14.241,20.031 524 | 2.0855,10.116 525 | 3.2605,11.887 526 | 18.654,21.274 527 | 14.267,19.99 528 | 0.13805,9.7589 529 | 2.2725,11.926 530 | 2.2739,8.4806 531 | 13.65,20.388 532 | 0.50724,10.318 533 | 1.9975,11.106 534 | 1.9741,10.811 535 | 13.519,19.353 536 | 19.152,21.119 537 | 3.3961,9.7507 538 | -0.22106,8.3155 539 | 2.7838,8.7862 540 | 1.9477,10.234 541 | 1.1028,9.9424 542 | 12.213,18.744 543 | 13.632,19.722 544 | 15.342,19.949 545 | 0.99759,10.1 546 | 14.516,19.279 547 | 17.575,20.899 548 | 2.1801,9.5555 549 | 1.1291,9.2418 550 | 1.8281,8.5575 551 | 2.7831,11.364 552 | 3.153,13.195 553 | 14.307,19.398 554 | 2.6372,8.2246 555 | 1.7345,11.777 556 | 2.882,10.369 557 | 2.9826,14.04 558 | 15.51,20.525 559 | 15.708,19.978 560 | 1.9834,10.439 561 | 18.144,21.457 562 | 15.201,20.262 563 | 0.78275,9.8702 564 | 0.97717,11.232 565 | 1.4643,8.6335 566 | 2.8645,10.004 567 | 14.938,20.271 568 | 0.98389,7.8409 569 | 2.8817,12.515 570 | 15.116,19.672 571 | 1.2849,9.6082 572 | 0.95446,7.2198 573 | 2.1431,10.824 574 | 2.7749,14.844 575 | 2.0578,8.6167 576 | 3.0663,9.359 577 | 15.554,19.424 578 | 1.7896,9.2342 579 | 2.9355,11.556 580 | 14.596,19.944 581 | 1.9104,10.207 582 | 18.709,20.782 583 | 1.2919,5.6405 584 | 16.608,20.944 585 | 2.2916,12.053 586 | 3.1604,11.575 587 | 0.86211,10.539 588 | 17.734,20.32 589 | 15.993,20.294 590 | 1.3312,9.2172 591 | 0.84805,9.8848 592 | 0.71057,8.7717 593 | 1.6301,11.169 594 | 2.4845,10.743 595 | 3.2099,13.201 596 | 2.252,11.903 597 | 1.6184,10.648 598 | 13.017,19.518 599 | 1.5049,10.434 600 | 1.9357,9.8818 601 | 14.761,20.771 602 | 14.119,19.46 603 | 1.9455,8.3241 604 | 2.0194,9.766 605 | 14.735,19.305 606 | 16.895,21.388 607 | 13.487,19.573 608 | 13.914,19.659 609 | 2.0203,8.9103 610 | 0.48761,8.519 611 | 1.4401,10.239 612 | 1.5346,11.31 613 | 3.4475,11.416 614 | 1.5535,10.892 615 | -0.4527,7.8317 616 | 1.4758,8.4832 617 | 12.105,19.7 618 | 0.73559,9.1174 619 | 2.3809,9.0861 620 | 16.037,19.631 621 | 1.3832,9.619 622 | 1.9338,10.062 623 | 2.1388,10.794 624 | 0.82135,8.8827 625 | 15.616,20.39 626 | 14.311,19.408 627 | 1.3428,10.24 628 | 1.5729,8.4626 629 | 0.62476,8.9335 630 | -0.4581,9.4002 631 | 1.6865,10.674 632 | 14.2,19.488 633 | 15.849,20.281 634 | 3.1913,11.322 635 | 15.71,20.4 636 | 2.9793,9.4403 637 | 2.147,10.242 638 | 0.86915,5.873 639 | 0.84003,8.3757 640 | 0.8407,9.2793 641 | 0.53181,7.5908 642 | 16.882,20.758 643 | -0.78096,5.9187 644 | 13.946,20.355 645 | 3.6322,12.251 646 | 16.623,20.885 647 | 15.573,20.778 648 | 0.76374,6.9354 649 | 11.887,19.543 650 | 14.127,20.045 651 | 1.257,7.0383 652 | 2.7484,9.4865 653 | 2.0744,9.8387 654 | 12.784,19.128 655 | 0.86861,8.7484 656 | 3.0145,10.209 657 | 1.8177,9.7307 658 | 1.1631,10.581 659 | 3.5542,9.8079 660 | 0.67294,7.4769 661 | 2.6984,9.7079 662 | 1.8702,9.3437 663 | 2.4009,9.4148 664 | 1.0303,10.985 665 | 13.162,19.075 666 | 0.39566,7.3782 667 | 11.231,18.4 668 | 13.34,20.245 669 | 1.4609,9.5363 670 | 14.957,20.027 671 | -0.14219,8.0275 672 | 2.6937,12.126 673 | 1.7922,10.6 674 | 1.6726,11.822 675 | 16.846,20.035 676 | 1.7605,7.2338 677 | 2.9064,13.095 678 | 0.74969,9.1492 679 | 1.6835,12.395 680 | 1.5037,7.0766 681 | 1.1188,10.692 682 | 1.9329,11.473 683 | 0.67138,7.5956 684 | 3.4525,9.1349 685 | 15.149,20.011 686 | 10.637,18.845 687 | 15.116,19.104 688 | -0.63592,7.8536 689 | 14.13,19.497 690 | 2.493,10.359 691 | 12.178,18.883 692 | 16.93,20.723 693 | 2.6676,9.8115 694 | 0.85692,7.6976 695 | 3.4799,11.089 696 | 18.338,21.769 697 | 3.1039,12.552 698 | 13.174,18.763 699 | 1.4265,10.406 700 | 14.746,20.128 701 | 0.94466,9.643 702 | 1.2152,7.7016 703 | 1.6241,10.985 704 | 1.8485,6.6835 705 | 1.7335,10.144 706 | 18.003,20.991 707 | 0.5627,9.1392 708 | 2.415,12.594 709 | 2.4849,10.369 710 | 0.55916,6.6483 711 | 1.7816,8.6792 712 | 3.4507,12.762 713 | 1.9678,8.2867 714 | 1.9804,7.0903 715 | 2.8024,12.374 716 | 2.3081,10.702 717 | 15.59,20.831 718 | 0.033262,7.3211 719 | 3.5523,12.497 720 | 1.3375,9.5442 721 | 16.767,21.087 722 | 2.9445,11.368 723 | 2.9485,7.8096 724 | 2.3547,9.739 725 | 14.183,19.025 726 | 1.0136,12.856 727 | 2.3535,10.309 728 | 1.7121,12.496 729 | 0.96568,11.064 730 | 1.4722,8.7186 731 | 2.4945,8.0026 732 | 1.9724,11.829 733 | 2.0238,6.1041 734 | 2.1275,11.384 735 | 2.282,7.9895 736 | 2.0728,9.9789 737 | 17.696,21.016 738 | 2.6902,9.6407 739 | 2.1981,11.701 740 | 17.518,21.212 741 | 14.371,19.95 742 | 18.651,21.847 743 | 1.7242,7.9559 744 | 1.6129,11.753 745 | 1.1037,7.6922 746 | 16.502,20.382 747 | 14.709,19.908 748 | 16.019,20.84 749 | 11.082,18.895 750 | 12.447,19.45 751 | 1.5851,10.903 752 | 13.299,19.016 753 | 2.9262,12.642 754 | 15.261,20.529 755 | 1.8888,10.59 756 | 1.7914,11.216 757 | 0.0099729,8.5375 758 | 14.836,19.845 759 | 3.7991,12.525 760 | 12.637,19.014 761 | 1.8565,10.615 762 | 2.5971,9.4766 763 | 2.3392,12.177 764 | 14.106,19.596 765 | 14.823,19.054 766 | 3.6082,12.315 767 | 12.034,18.764 768 | 15.2,20.925 769 | 12.918,19.083 770 | 13.876,19.067 771 | 14.516,20.101 772 | 1.7768,10.143 773 | 16.842,20.429 774 | 2.2514,10.196 775 | 18.028,21.407 776 | 1.3967,7.3363 777 | 15.624,20.645 778 | 1.0562,6.8259 779 | 1.0314,9.8859 780 | 15.437,19.913 781 | 2.8568,10.503 782 | 14.337,20.216 783 | 2.442,11.143 784 | 3.4718,12.005 785 | 2.3768,10.938 786 | 18.417,21.266 787 | 0.27903,7.4154 788 | 2.5899,11.185 789 | 13.941,19.802 790 | 1.6957,9.1 791 | 0.89442,10.713 792 | 1.3437,8.795 793 | 1.7262,12.814 794 | 2.8488,11.277 795 | 2.6229,11.259 796 | -0.18851,7.6636 797 | 1.7673,11.807 798 | 0.86601,11.252 799 | 2.9274,13.364 800 | 2.9217,9.794 801 | 17.004,21.27 802 | 1.6386,9.2498 803 | 3.0457,12.201 804 | 0.91949,7.0423 805 | 11.992,19.157 806 | 2.2153,6.6524 807 | -1.5041,9.3856 808 | 14.728,20.102 809 | 4.0565,12.108 810 | 2.1135,9.9691 811 | 1.2961,7.748 812 | 1.4218,8.3968 813 | 0.94707,9.7546 814 | 13.687,19.192 815 | 1.7318,11.984 816 | 1.8847,10.63 817 | 1.8963,10.238 818 | 0.57971,10.708 819 | 15.298,19.977 820 | 1.7512,9.0048 821 | 14.398,20.306 822 | 15.539,20.026 823 | 3.4795,13.228 824 | 2.5229,8.8789 825 | 16.663,20.816 826 | 4.0364,9.693 827 | 0.98073,8.3698 828 | 3.3634,11.322 829 | 1.9916,7.4364 830 | 16.373,19.835 831 | 1.4919,8.3732 832 | 14.866,20.166 833 | 15.354,20.463 834 | 15.328,19.743 835 | 2.0529,10.527 836 | 3.5553,14.283 837 | 2.7406,11.776 838 | 1.8729,10.55 839 | 14.048,19.835 840 | 2.6117,11.001 841 | 16.53,19.355 842 | 13.779,20.167 843 | 2.6425,12.355 844 | 1.2517,8.5327 845 | 3.0343,10.453 846 | 15.922,20.637 847 | 0.44474,7.4124 848 | 15.429,19.671 849 | 1.98,10.848 850 | 0.74381,9.3174 851 | 1.7369,7.5076 852 | 2.584,10.868 853 | 1.3038,10.222 854 | 2.2823,8.9095 855 | 1.867,7.9036 856 | 2.0384,11.307 857 | 3.7448,12.13 858 | 2.2056,7.7818 859 | 11.966,18.297 860 | 15.824,19.748 861 | 12.296,19.328 862 | 3.6317,10.209 863 | 2.7948,7.5714 864 | 12.415,18.652 865 | -0.35282,9.7141 866 | 1.3417,7.9246 867 | 3.2421,12.337 868 | 1.5249,9.568 869 | 13.311,19.094 870 | 2.7237,7.7931 871 | 3.2749,12.078 872 | 2.5427,11.878 873 | 15.649,20.809 874 | 2.7646,11.919 875 | 2.4939,7.5476 876 | 1.0265,7.267 877 | 11.616,18.475 878 | 2.5349,10.773 879 | 17.637,21.414 880 | 1.382,12.86 881 | 3.6998,10.044 882 | 12.376,18.987 883 | 3.0463,11.267 884 | 2.0633,10.47 885 | 14.613,20.366 886 | 0.69153,6.8416 887 | 2.7977,9.6653 888 | 0.56776,7.7296 889 | 15.907,21.083 890 | 3.9359,13.172 891 | 14.674,20.249 892 | 1.3926,7.8961 893 | 1.38,8.4705 894 | 20.181,22.442 895 | 2.3147,10.839 896 | 0.22292,8.1192 897 | -0.51525,4.591 898 | 3.3717,10.981 899 | 17.235,20.579 900 | 3.7226,9.7224 901 | 12.857,19.947 902 | 2.3809,12.391 903 | 1.9849,8.0811 904 | 1.8802,9.6457 905 | 1.8116,8.5648 906 | 1.3024,10.223 907 | 3.2789,11.462 908 | -0.16916,8.2892 909 | 3.1911,9.5012 910 | 0.29612,9.751 911 | 0.50601,8.2622 912 | 1.4892,6.8666 913 | 13.218,19.302 914 | 2.4882,7.2716 915 | 2.341,11.842 916 | 1.7067,8.168 917 | 3.0174,11.794 918 | 16.915,20.834 919 | 16.458,20.376 920 | 2.3413,11.387 921 | 2.8786,10.811 922 | 16.345,19.975 923 | 2.3082,12.734 924 | 1.6772,11.24 925 | 3.3974,13.692 926 | 2.5192,10.444 927 | 1.8695,12.205 928 | 2.7196,10.551 929 | 1.051,7.4052 930 | 14.375,20.2 931 | 14.852,19.48 932 | 1.3306,10.397 933 | 1.9956,11.438 934 | 1.5515,9.8055 935 | 2.6043,9.8613 936 | 0.064605,8.3299 937 | 16.795,20.427 938 | 4.289,12.319 939 | 1.5024,11.054 940 | 16.448,21.027 941 | 1.9539,10.89 942 | 2.6521,10.811 943 | 0.96964,8.494 944 | 13.945,19.785 945 | 2.3632,10.084 946 | 0.64649,8.0456 947 | 15.349,20.985 948 | 15.962,20.746 949 | 2.8514,9.9777 950 | 2.5836,11.282 951 | 2.1398,11.785 952 | 17.557,20.131 953 | 13.66,19.814 954 | 1.3185,9.4631 955 | 16.036,20.594 956 | 4.0646,13.887 957 | 12.817,19.067 958 | 3.172,12.474 959 | 1.3718,11.261 960 | 15.786,19.594 961 | 17.49,21.151 962 | 1.9169,9.234 963 | 15.909,20.467 964 | 2.3852,11.363 965 | 1.065,10.031 966 | 14.7,19.404 967 | 1.8673,9.6182 968 | 1.3752,10.1 969 | 17.395,20.572 970 | 13.864,19.484 971 | 0.86126,9.0187 972 | 16.994,20.499 973 | 3.2371,12.342 974 | 1.6055,7.8493 975 | 1.1247,8.177 976 | 14.636,19.577 977 | 18.217,21.403 978 | 1.3412,12.641 979 | 1.7404,12.327 980 | 1.1187,10.765 981 | 13.855,20.171 982 | 0.5673,8.9596 983 | 1.8365,9.4955 984 | 2.0734,9.8806 985 | 12.976,17.808 986 | 12.075,18.893 987 | 15.718,20.431 988 | 4.0136,11.493 989 | 1.288,9.7509 990 | 1.0062,5.8188 991 | 11.662,18.586 992 | 1.3095,7.4302 993 | 14.391,19.673 994 | 2.6996,9.8585 995 | 1.0072,9.2783 996 | 2.6386,11.594 997 | 2.7513,12.098 998 | 2.9831,9.3229 999 | 1.2284,7.2057 1000 | 2.0056,10.724 1001 | -------------------------------------------------------------------------------- /src/GMM/data/Train1.csv: -------------------------------------------------------------------------------- 1 | 10.254,8.597 2 | -0.58581,1.3881 3 | 2.4457,1.0898 4 | -4.6235,-2.0176 5 | -0.27672,-1.0047 6 | 3.1285,1.7302 7 | 10.707,8.0399 8 | -2.0434,0.13591 9 | -0.50164,0.10736 10 | -1.9229,-0.86761 11 | 1.6664,0.16926 12 | 12.234,11.181 13 | 10.038,8.854 14 | 0.67645,0.76041 15 | -0.43084,-1.9019 16 | -0.017779,1.1909 17 | 8.9667,8.3693 18 | 0.69476,0.70484 19 | -3.2938,-0.82277 20 | 0.0052694,2.5424 21 | 2.4199,1.9444 22 | -1.2083,-1.0396 23 | -1.268,0.20874 24 | -0.022256,0.47421 25 | 0.76826,0.39416 26 | -0.3838,-0.6483 27 | -1.8356,-1.6402 28 | 9.9794,10.814 29 | 0.16767,1.1457 30 | -1.8414,-0.89782 31 | 0.35197,1.5117 32 | 1.5342,0.42624 33 | 8.2109,6.6495 34 | -3.1089,-1.3173 35 | -1.4227,0.18142 36 | 7.5269,8.3935 37 | 0.12643,-0.11866 38 | 11.354,15.555 39 | 11.936,10.444 40 | 1.2713,1.1642 41 | 1.1805,1.1518 42 | 1.9571,0.9094 43 | -0.039407,0.39516 44 | 2.221,2.0459 45 | 11.616,12.366 46 | -0.79206,-0.66637 47 | -2.4033,-0.84024 48 | 0.92322,1.1338 49 | -0.78902,0.23106 50 | -0.18426,-1.074 51 | 0.13189,0.61945 52 | 0.092721,0.42425 53 | -2.3223,-0.60945 54 | 1.8736,0.24728 55 | 0.66323,0.45015 56 | 0.35477,-0.70983 57 | -1.6604,-1.6169 58 | 1.2716,0.2847 59 | 12.288,11.489 60 | 10.704,10.984 61 | 9.2944,9.3752 62 | 1.5,-0.44262 63 | 12.727,13.222 64 | 12.077,11.265 65 | 12.713,15.248 66 | 0.24564,0.44458 67 | -0.10524,0.38306 68 | -0.42696,-0.74234 69 | 8.082,4.1657 70 | 1.1148,0.076398 71 | -0.86834,-0.0033319 72 | 0.5915,-0.43817 73 | 11.189,12.259 74 | -2.4047,0.23217 75 | -0.9336,-0.55489 76 | -0.018964,-0.35029 77 | 11.342,13.729 78 | 0.15794,0.35004 79 | -0.78794,-0.1847 80 | 0.907,0.79815 81 | 10.923,8.9316 82 | 9.1059,8.9637 83 | 8.4286,10.128 84 | 8.2329,6.9255 85 | 9.0252,8.4701 86 | 9.6374,9.6622 87 | 1.2737,-0.29743 88 | -1.1513,-0.58344 89 | 0.79715,0.48667 90 | -3.142,-1.7496 91 | 1.771,0.62456 92 | -3.0915,-1.3514 93 | 9.5122,10.344 94 | 12.489,12.963 95 | -1.1595,-1.0794 96 | 8.9024,10.669 97 | 9.9348,11.431 98 | 8.3284,8.7763 99 | -1.2568,1.3021 100 | -1.089,-0.63196 101 | 8.3839,8.6995 102 | 1.221,-0.09629 103 | 11.305,12.041 104 | -0.84806,-0.73955 105 | 0.7028,1.0251 106 | 6.5687,7.5886 107 | 1.6471,0.62244 108 | 0.80127,-1.4684 109 | -1.746,-0.686 110 | -3.5853,0.11331 111 | -0.35455,-2.4086 112 | 11.139,11.356 113 | -1.4237,-1.0113 114 | 9.451,9.183 115 | 10.499,10.026 116 | 10.581,12.214 117 | -2.0818,-0.17027 118 | 7.8278,5.4016 119 | 12.426,12.522 120 | 3.1261,1.2184 121 | 7.6421,6.754 122 | 11.936,13.648 123 | -1.0267,0.45289 124 | -0.27413,-0.96726 125 | 1.981,-0.62189 126 | 10.775,12.41 127 | 0.42536,1.3618 128 | 9.8794,9.1476 129 | -0.49728,-1.843 130 | -1.6623,-0.14237 131 | 0.70918,0.51208 132 | 2.474,1.3827 133 | 7.1023,4.4943 134 | 0.79049,-0.31031 135 | 7.076,6.1622 136 | 7.6131,7.404 137 | 11.028,8.4782 138 | 0.5045,-0.49492 139 | -2.1337,-0.77251 140 | 3.5716,1.4945 141 | 11.6,12.548 142 | -1.2612,-0.33147 143 | 0.22612,1.3125 144 | 10.251,13.155 145 | 3.5125,-0.4268 146 | 10.011,10.082 147 | -2.1084,0.42098 148 | -1.3234,-0.52039 149 | 0.09936,-0.36064 150 | 4.0328,1.52 151 | -0.36571,-0.9148 152 | 0.28774,-0.18746 153 | 5.1718,1.9319 154 | 1.6422,0.87833 155 | 2.5111,0.60125 156 | 0.1712,-1.9052 157 | 9.8115,12.95 158 | -1.5535,0.51822 159 | 10.388,9.8589 160 | 8.2899,5.2295 161 | -0.93471,-1.4832 162 | -0.61151,-1.3371 163 | 2.4139,0.76056 164 | 0.6228,-0.52362 165 | -2.9344,-1.741 166 | -2.0643,-1.0509 167 | -1.1693,-1.0921 168 | 2.66,2.054 169 | -1.3611,0.55849 170 | 0.49483,0.68145 171 | -1.993,-0.25831 172 | -2.5246,-0.20717 173 | 10.519,12.834 174 | 0.62195,-0.11249 175 | 11.28,14.53 176 | 11.723,13.938 177 | 0.16688,-1.8734 178 | -0.5192,0.4934 179 | 10.63,11.525 180 | 10.252,7.458 181 | -0.82352,-2.1415 182 | -3.7014,-1.2379 183 | 8.8294,5.8795 184 | 9.7235,10.16 185 | 8.0448,10.996 186 | -1.3736,-0.78107 187 | -1.1637,-0.45261 188 | -0.3232,-0.73368 189 | 11.858,10.929 190 | 9.7308,9.6809 191 | 1.1068,0.73968 192 | -0.0021903,0.18731 193 | -0.41431,-0.71891 194 | -0.4314,-0.20684 195 | 2.4891,2.5597 196 | 0.047793,-0.18487 197 | -2.3064,-0.59501 198 | 9.939,9.0761 199 | -0.70296,1.0223 200 | 0.40819,-0.030563 201 | -0.28646,0.66075 202 | 1.1518,1.3471 203 | -0.014153,0.18541 204 | 11.074,11.644 205 | -1.7927,-1.2028 206 | 10.357,11.678 207 | -0.8847,-0.60808 208 | 1.213,-2.0558 209 | 9.7219,11.984 210 | -0.63916,-0.2567 211 | 9.378,8.9408 212 | 1.6166,0.15888 213 | 12.208,11.909 214 | 8.3393,8.1664 215 | 1.9133,1.0683 216 | 8.9749,7.8822 217 | 10.263,9.1713 218 | -2.5415,-0.92898 219 | -0.42594,0.44748 220 | -0.57811,-2.5559 221 | 0.14401,0.49701 222 | 0.9592,0.45044 223 | 11.84,12.449 224 | -0.89261,0.70166 225 | -2.5067,-1.5283 226 | 8.9286,9.3645 227 | 3.5827,0.027104 228 | -1.1846,-0.38031 229 | 2.1227,-0.28266 230 | 10.624,10.589 231 | 11.696,10.408 232 | 8.5719,8.1244 233 | 8.76,9.1585 234 | 6.9973,5.6124 235 | 2.1484,2.043 236 | 11.7,10.033 237 | -2.4592,-0.46744 238 | -0.14198,-1.3875 239 | -0.10088,-0.17534 240 | 5.8706,4.8642 241 | -1.7798,-0.53015 242 | 1.2069,1.8957 243 | -1.3132,-0.20774 244 | 9.566,10.002 245 | -0.35995,-1.2522 246 | 2.2516,0.52683 247 | -1.9299,-1.3355 248 | 9.5325,7.8723 249 | 1.339,-0.8025 250 | 0.11233,-0.74974 251 | -0.31954,-0.58515 252 | -1.8946,-1.9836 253 | 9.8066,8.6094 254 | 9.8669,8.1846 255 | -2.5308,-0.91632 256 | -0.58498,0.70083 257 | -0.30878,-0.17952 258 | 9.7869,9.2464 259 | 0.51219,-1.145 260 | 11.026,10.472 261 | 2.2012,-0.22079 262 | -0.78675,-0.26779 263 | 10.086,10.583 264 | 9.9088,7.2926 265 | -0.55356,-0.45665 266 | -1.4186,-2.1188 267 | 10.178,11.767 268 | 10.411,7.4151 269 | -0.77494,0.95967 270 | 8.5056,7.2228 271 | -0.87345,0.78545 272 | 0.19588,-0.34235 273 | 10.842,9.3015 274 | -1.0695,-0.36421 275 | 9.0304,10.212 276 | 0.59177,-0.06424 277 | 0.76553,0.50075 278 | -0.66517,-0.25088 279 | 0.4097,0.15405 280 | 3.2745,2.8835 281 | 0.34651,0.1166 282 | 10.376,8.4539 283 | 2.3003,1.7131 284 | -0.0025664,-0.15676 285 | 8.217,8.7505 286 | 7.1154,5.7397 287 | -0.42256,0.32786 288 | -0.56526,0.31484 289 | 8.7955,8.6444 290 | 10.97,11.789 291 | -1.0597,-1.2332 292 | 0.21972,0.35581 293 | -1.3467,-0.38451 294 | 10.666,9.4972 295 | 3.2763,0.98177 296 | 10.601,11.958 297 | 9.263,9.4729 298 | -0.042406,-0.10512 299 | 0.19671,0.28976 300 | 0.68676,-0.69979 301 | 0.6762,0.69896 302 | 0.12207,0.10568 303 | 0.48501,0.50614 304 | 8.8203,7.826 305 | -3.3197,-2.5278 306 | -2.419,-0.20326 307 | 2.8162,1.6539 308 | 8.2183,10.656 309 | -0.06105,0.89823 310 | 1.7737,0.45205 311 | -1.8669,-0.45419 312 | 0.015084,0.31647 313 | 9.7031,11.614 314 | 0.52747,0.24606 315 | -0.078751,0.23556 316 | -4.7293,-1.9661 317 | 0.24855,-1.2452 318 | -1.0209,-0.092637 319 | 10.918,12.984 320 | 0.40823,-1.1913 321 | -4.1437,-0.31603 322 | 0.39999,-0.20946 323 | 0.20185,-0.9246 324 | 0.59707,0.49697 325 | 9.4933,10.086 326 | -0.48506,0.80124 327 | 10.597,11.555 328 | -1.6644,-0.50926 329 | 3.6765,0.47621 330 | 3.0004,2.2368 331 | 8.4133,7.7198 332 | 1.606,0.82595 333 | 0.96587,0.43082 334 | 12.493,9.5535 335 | 12.753,14.413 336 | 9.3452,10.621 337 | 8.3899,7.1798 338 | 11.523,10.49 339 | -3.6472,-1.1865 340 | 0.25494,1.117 341 | 11.356,15.19 342 | 10.611,10.444 343 | 9.9666,13.262 344 | -1.2289,0.1917 345 | -1.2581,-1.2841 346 | -0.018027,0.5908 347 | 1.2858,-0.18737 348 | 1.1293,-0.74685 349 | 7.3825,11.469 350 | 0.50639,1.2071 351 | 0.23561,-0.92909 352 | 10.864,11.37 353 | 0.042489,0.055735 354 | -1.5876,-1.2375 355 | 2.6076,-0.25347 356 | 1.4441,-0.14256 357 | -0.36787,0.24478 358 | 0.39733,0.19776 359 | 1.2558,0.024671 360 | 0.78508,-2.0018 361 | -1.4738,-0.51001 362 | 12.199,12.084 363 | 1.4441,1.6197 364 | 2.2087,-0.73167 365 | -1.3974,-0.82506 366 | 10.607,11.246 367 | 0.40946,0.11106 368 | 0.21075,-0.26324 369 | 0.091788,-0.26063 370 | -0.42864,0.4286 371 | 1.4902,0.92639 372 | 0.34646,-1.1952 373 | 0.60937,0.27931 374 | 12.296,9.5946 375 | 9.0277,7.3691 376 | 10.61,9.9787 377 | -2.4331,-1.3145 378 | -1.6708,-2.2369 379 | 8.1575,7.6768 380 | -1.3565,-1.1107 381 | 9.3262,9.2757 382 | 10.011,11.788 383 | 8.3121,8.4284 384 | -1.3756,-0.49108 385 | 0.97257,-1.057 386 | 0.37914,-0.022868 387 | 8.2097,6.6582 388 | 0.96134,0.027574 389 | 10.806,13.447 390 | 0.26557,0.83996 391 | 0.96807,1.1028 392 | -3.8621,-1.8156 393 | -2.3036,-0.17147 394 | -0.87091,0.45403 395 | 0.94419,-1.0843 396 | -0.69838,0.056585 397 | -1.3155,0.22168 398 | 0.18493,-0.22154 399 | -3.4966,-1.9775 400 | 0.056224,-0.23726 401 | 0.79997,-0.070035 402 | 9.0673,8.6083 403 | 0.96064,1.1216 404 | -1.99,-0.5413 405 | 1.0382,0.34515 406 | -0.49479,-0.15954 407 | 2.4575,2.1043 408 | 10.521,8.8384 409 | 8.2455,7.1509 410 | -1.3876,-0.68216 411 | 0.49594,0.84141 412 | 11.081,10.02 413 | 10.669,11.046 414 | 11.242,11.787 415 | 1.976,0.97282 416 | 9.1038,9.9952 417 | 3.1036,0.14185 418 | -0.60368,-0.34128 419 | 10.447,9.7156 420 | -1.1763,-0.073007 421 | 0.098333,-0.24643 422 | -0.24888,-0.58051 423 | 8.0132,6.0398 424 | 3.7438,4.1407 425 | 10.818,12.042 426 | -3.018,-1.5525 427 | -3.8022,-1.2656 428 | 8.5157,3.084 429 | 0.20956,0.097357 430 | 10.197,9.2072 431 | -0.28967,-0.54244 432 | 9.4327,7.1122 433 | 10.594,11.766 434 | 0.60473,-0.6271 435 | 0.24131,0.2186 436 | 1.1895,1.0361 437 | -1.3455,-0.26826 438 | 7.5676,6.8671 439 | 1.5507,0.5519 440 | 11.031,10.547 441 | -1.2872,-0.036183 442 | 10.407,9.7148 443 | -0.52543,0.51018 444 | -0.59739,0.80055 445 | 1.5029,0.86539 446 | 8.348,11.419 447 | 8.0761,9.1146 448 | 10.841,11.056 449 | -0.98811,-0.52253 450 | 8.6897,7.3387 451 | 0.45768,1.4049 452 | 10.587,10.26 453 | -0.82552,-0.14774 454 | 12.153,12.31 455 | 1.001,0.78468 456 | -0.92529,-0.097887 457 | -2.099,-0.16606 458 | -0.93237,0.12952 459 | 3.2861,1.9806 460 | 0.49385,-0.43315 461 | 2.129,0.67538 462 | 10.311,12.236 463 | 8.3304,11.213 464 | -0.67568,-0.84508 465 | 0.19037,-0.32647 466 | -2.2424,-0.49613 467 | 9.5859,10.071 468 | 2.8679,0.69894 469 | 0.77409,-0.62847 470 | 1.0107,0.02519 471 | -1.6588,0.19416 472 | 11.326,12.669 473 | -0.22438,-1.021 474 | -0.71451,-0.18641 475 | 1.4269,-1.2024 476 | 1.4915,1.7917 477 | 8.8691,9.6474 478 | 1.3942,-0.15513 479 | 2.2208,1.7142 480 | 9.9626,10.739 481 | 9.5149,9.6388 482 | -0.41502,0.24072 483 | 9.8957,6.3426 484 | 0.91239,-0.27938 485 | 9.5362,7.1941 486 | 1.4268,0.58728 487 | -1.2504,-0.15561 488 | 1.1742,0.76622 489 | -0.87747,-2.4218 490 | -0.84815,-0.46493 491 | 0.16693,0.60936 492 | 0.94835,0.88353 493 | 0.82126,0.88646 494 | -2.7959,-0.68212 495 | 10.03,9.061 496 | -0.26589,-0.51444 497 | 10.788,11.588 498 | 10.832,8.9567 499 | 1.8402,1.4595 500 | 1.6882,1.2866 501 | 0.33935,0.64071 502 | 10.641,10.149 503 | 10.396,10.197 504 | -3.8373,-0.61458 505 | -2.37,-1.2636 506 | -0.90292,0.29966 507 | 11.451,11.874 508 | -0.0009133,0.40302 509 | 11.08,10.136 510 | 10.572,11.385 511 | 1.6089,-0.031251 512 | 10.886,14.711 513 | 9.5043,7.731 514 | 10.393,11.011 515 | 9.6709,8.9233 516 | -0.32677,-1.1965 517 | 1.4593,-0.42232 518 | 1.3539,1.6073 519 | 9.0277,9.9546 520 | 7.7749,6.2442 521 | -0.10587,-1.7074 522 | 11.771,12.213 523 | 9.6016,10.766 524 | 0.43574,0.075034 525 | -0.34216,-0.93374 526 | 0.19808,-0.56597 527 | 8.1658,11.472 528 | 2.6021,-0.69231 529 | 9.1853,8.9828 530 | 8.0965,8.043 531 | -1.8488,-0.62558 532 | 1.1229,-0.39771 533 | 11.846,11.18 534 | 3.5015,0.68328 535 | 0.32162,-0.68973 536 | 1.442,-0.96958 537 | -0.76531,0.50674 538 | 0.80983,-0.2054 539 | 2.2247,0.46851 540 | 0.21639,0.33481 541 | 4.1633,1.614 542 | 0.025219,0.054011 543 | -0.41267,0.51408 544 | -1.0865,-0.26311 545 | -1.5278,-1.6786 546 | 8.7284,8.9853 547 | 1.1974,0.93198 548 | -1.2506,-1.1885 549 | -2.0451,-1.1142 550 | -0.81568,0.02466 551 | -0.90605,-1.221 552 | -1.24,0.90229 553 | 0.3744,0.22702 554 | 11.403,11.583 555 | 10.53,10.272 556 | 0.56549,-1.4873 557 | 7.8667,6.3613 558 | 9.9629,6.1729 559 | 0.23709,0.057197 560 | -0.18834,0.46969 561 | 10.713,7.9564 562 | 10.438,10.978 563 | 11.196,9.7987 564 | 0.19451,1.3042 565 | 7.5023,5.6481 566 | 10.793,11.964 567 | -0.3337,-0.7583 568 | -1.8045,-1.1064 569 | 10.816,9.5019 570 | 0.63397,1.3684 571 | 10.827,11.139 572 | 0.48865,0.55289 573 | -1.5897,-0.79976 574 | 11.334,12.45 575 | -1.0579,-0.42377 576 | 9.32,9.6635 577 | -1.0018,-0.54277 578 | -2.8115,-0.0074689 579 | 11.158,10.323 580 | 0.59821,-0.50449 581 | 8.6572,10.321 582 | 9.7199,12.483 583 | 11.134,12.915 584 | 0.63627,-0.46977 585 | 0.4755,0.81742 586 | 12.298,12.304 587 | 1.3757,-0.94883 588 | 3.0135,2.151 589 | 8.1437,8.2396 590 | -1.3178,-1.1167 591 | 11.114,8.5581 592 | 11.851,14.921 593 | 1.6609,-0.21149 594 | -1.053,0.27016 595 | -3.0434,-0.70274 596 | -0.82846,-0.70593 597 | -3.1564,-1.7671 598 | 1.429,-0.35331 599 | 11.349,13.556 600 | 1.1417,0.25964 601 | 11.414,12.548 602 | -0.62436,-0.63792 603 | -3.1428,-1.2867 604 | 9.5214,11.986 605 | 10.568,13.18 606 | 9.0953,8.8165 607 | 0.020576,-0.26999 608 | 1.7694,1.1035 609 | 9.595,9.6053 610 | 0.3351,0.17224 611 | 0.16013,0.060591 612 | 1.7721,1.0449 613 | 1.4485,0.88776 614 | -1.5322,-1.4017 615 | 9.4768,10.375 616 | -3.9608,-0.96873 617 | 0.77425,-0.84077 618 | -0.85227,1.2284 619 | -2.3783,1.0962 620 | 3.5096,1.3524 621 | -0.73932,-0.60774 622 | 3.0764,-2.2656 623 | -0.64862,-1.5637 624 | 3.5601,0.58787 625 | 10.26,9.2047 626 | 1.5706,0.15438 627 | 11.903,14.588 628 | -1.1328,0.63648 629 | -0.11556,0.021324 630 | 4.3716,1.7954 631 | -0.31623,0.65021 632 | -0.8098,-0.031815 633 | -0.94666,0.55539 634 | -2.0992,0.53928 635 | 10.341,12.381 636 | -3.0224,-1.035 637 | 0.97153,0.41354 638 | 11.193,12.616 639 | 0.74403,1.2173 640 | -0.71531,-1.8061 641 | 6.6838,3.9853 642 | 12.305,12.214 643 | 7.4502,10.132 644 | -1.4408,-1.632 645 | 3.623,-0.59404 646 | 10.873,11.291 647 | -3.4975,-0.8161 648 | -3.8171,-1.9398 649 | 10.766,10.618 650 | -2.4031,-0.28869 651 | -5.5302,-0.82613 652 | 8.884,8.2337 653 | 7.934,5.0431 654 | -1.3494,-0.66973 655 | 12.636,11.272 656 | -3.4182,-1.7089 657 | -0.43495,0.4985 658 | 0.080956,1.4588 659 | 0.21907,-0.27899 660 | -3.8561,-0.24778 661 | 10.951,9.137 662 | -0.18992,1.12 663 | 9.3865,9.7904 664 | 9.4276,9.5759 665 | -0.58973,-0.53851 666 | 9.769,10.43 667 | 9.6228,9.8871 668 | 1.2628,-1.0208 669 | 1.057,-0.069431 670 | 2.4467,0.1787 671 | -0.005815,0.34562 672 | 2.4753,0.16399 673 | 10.551,8.512 674 | -0.72536,-0.39323 675 | -0.77387,-0.53784 676 | -0.24236,-0.62247 677 | 9.0012,7.8467 678 | 2.5415,1.4327 679 | 11.283,11.145 680 | 0.34087,0.39198 681 | -1.2056,0.20658 682 | 8.1432,8.1566 683 | 2.0278,-0.39964 684 | 2.3725,1.7484 685 | 0.30339,0.52696 686 | -2.2467,-0.95793 687 | -0.60372,0.035494 688 | 0.38438,0.10485 689 | 10.466,10.013 690 | 3.2568,0.66548 691 | 0.065664,0.48535 692 | 11.148,12.268 693 | 0.16964,-0.37989 694 | 10.148,10.536 695 | -1.1163,-0.38664 696 | 1.9403,1.7139 697 | -1.8975,-0.60046 698 | -2.3293,-1.2271 699 | 8.4616,8.9978 700 | 2.1532,2.1323 701 | 10.976,10.12 702 | 10.888,11.727 703 | 2.605,0.33904 704 | 1.227,1.453 705 | 2.6092,1.3144 706 | -3.6509,-1.4827 707 | 1.518,1.6091 708 | 2.2028,1.2837 709 | 0.86165,-0.16629 710 | -5.1827,-3.0777 711 | -1.6215,-1.4881 712 | -1.3972,-0.59128 713 | 10.183,12.681 714 | -0.17392,0.84679 715 | -2.9777,-1.0335 716 | -2.8831,-1.7772 717 | 8.7464,6.4837 718 | -0.54855,-0.34195 719 | 11.414,10.688 720 | 0.77524,1.5566 721 | -0.87814,-0.51331 722 | -0.68756,-1.7589 723 | 1.9106,-0.17668 724 | 8.7485,6.5198 725 | 1.3565,1.3647 726 | 1.0632,-0.47846 727 | -0.53252,-0.8901 728 | -0.29535,-0.22238 729 | 1.3877,0.301 730 | -0.2562,-0.619 731 | -0.66799,-0.49181 732 | 8.522,7.4885 733 | -0.91588,0.41682 734 | -2.3231,-1.2166 735 | -1.4639,-1.5574 736 | 7.3607,4.5329 737 | 2.8731,1.3256 738 | -0.90332,0.12083 739 | -0.097125,0.83809 740 | 0.15825,-1.9566 741 | -0.23852,-0.57907 742 | -1.2696,-1.0153 743 | 1.8447,1.3784 744 | 12.149,14.222 745 | 0.22571,1.3341 746 | 10.762,8.4394 747 | 12.502,12.229 748 | -0.21893,0.91302 749 | 11.509,11.281 750 | 0.63397,0.79091 751 | 0.14233,-0.57676 752 | 0.39842,-0.031839 753 | -1.1565,0.24975 754 | 8.7645,7.1845 755 | -0.57692,0.66199 756 | 3.8327,-0.46238 757 | 1.2625,0.28508 758 | 1.8892,1.9554 759 | 2.3073,2.1478 760 | -0.25804,0.7227 761 | 0.16688,0.95922 762 | 0.28179,-0.73497 763 | 0.1936,0.58805 764 | 8.1014,7.9954 765 | 9.1895,8.8503 766 | -1.1201,-0.33014 767 | 0.6672,0.91648 768 | 10.549,12.171 769 | -0.82185,-0.037196 770 | 8.3499,9.0478 771 | 12.069,12.415 772 | 1.7844,0.76695 773 | 10.951,10.747 774 | 9.4367,11.604 775 | -0.045408,0.78241 776 | -1.0456,1.7745 777 | -2.8904,-0.15902 778 | 8.899,10.993 779 | -1.5022,-0.42546 780 | -0.13091,0.52089 781 | -0.23041,-0.29188 782 | 1.7693,-0.64085 783 | 10.414,8.2071 784 | -2.1978,-0.81084 785 | 8.9137,9.4556 786 | 1.2632,0.74042 787 | 10.051,7.7961 788 | 3.0006,-0.088211 789 | 0.95106,-0.59108 790 | -1.2385,1.1534 791 | -0.28288,-1.2395 792 | -1.0816,-0.59279 793 | 0.8447,0.098105 794 | 10.962,10.1 795 | 10.046,10.771 796 | 8.1014,8.7456 797 | 10.691,13.321 798 | 9.2943,6.6409 799 | 1.4029,0.60071 800 | 9.1231,8.1504 801 | 4.1019,2.1534 802 | 1.9312,-0.21508 803 | -1.4309,-0.71798 804 | -1.2927,0.039508 805 | 9.8192,8.6417 806 | 4.6343,5.2844 807 | -1.0733,-1.1197 808 | 0.12589,-1.1124 809 | 9.7757,9.6571 810 | -1.029,-0.50466 811 | 10.862,11.487 812 | -2.5711,-1.9545 813 | -1.9437,-0.028541 814 | 7.7244,4.1965 815 | -1.0797,-0.91956 816 | -0.51706,0.11269 817 | -0.62514,-0.69781 818 | 0.10716,0.46561 819 | 0.10569,0.51595 820 | -1.3204,-0.063969 821 | 0.59011,0.24919 822 | -0.37884,0.62002 823 | 5.0537,4.3729 824 | 10.739,10.71 825 | 1.7531,1.5643 826 | -1.6376,-0.053333 827 | -3.6802,-2.3765 828 | 10.74,10.108 829 | 2.6199,1.6281 830 | 9.7508,9.627 831 | 11.088,10.702 832 | 0.015442,-1.5693 833 | -0.46358,0.25063 834 | 10.495,9.996 835 | 9.4463,9.6548 836 | 1.1758,-0.059914 837 | 2.1542,1.499 838 | 11.775,11.694 839 | -0.79385,0.46666 840 | 7.8589,3.1217 841 | 9.993,12.266 842 | -2.5934,-0.77937 843 | 8.9625,8.0242 844 | -1.5839,-0.58506 845 | 4.1936,0.71834 846 | 8.1916,7.8895 847 | 8.0565,9.3841 848 | 2.2876,1.007 849 | 10.856,10.962 850 | 0.41484,1.0639 851 | 13.139,14.856 852 | 0.79481,-0.091882 853 | 7.4843,6.6099 854 | 9.3191,9.3681 855 | -0.27124,0.63457 856 | -0.31257,0.50791 857 | 1.7859,0.096459 858 | 9.3807,9.5535 859 | -2.1806,-0.78603 860 | -0.54106,1.4146 861 | 0.63678,0.22339 862 | -2.5382,0.15471 863 | 10.308,9.7088 864 | -0.49028,-0.86662 865 | -0.72876,-1.5019 866 | -0.4089,-0.12106 867 | -1.3926,-0.29391 868 | 8.391,10.283 869 | 4.5173,1.8159 870 | 0.57285,-0.67858 871 | 0.19883,0.60388 872 | 1.1794,0.85875 873 | 9.3345,10.498 874 | 9.5064,7.0354 875 | 10.199,10.207 876 | -1.1441,0.21062 877 | 10.862,10.032 878 | 11.952,15.731 879 | -2.6654,-1.4692 880 | 0.4661,0.93342 881 | 10.911,10.804 882 | 0.85653,-0.14187 883 | 10.742,10.362 884 | 10.115,9.1344 885 | -3.0756,-1.1407 886 | -0.57786,-0.746 887 | -0.055864,0.74503 888 | 10.262,8.6906 889 | -1.9347,-1.5685 890 | 1.8449,0.23974 891 | 10.052,9.5051 892 | 10.656,11.087 893 | -1.0695,-0.15099 894 | 10.578,10.884 895 | 0.66731,0.30142 896 | 0.29245,1.1926 897 | 8.764,10.434 898 | -0.79939,0.095263 899 | 0.2014,-0.32154 900 | 0.75782,1.0924 901 | 0.189,-0.3218 902 | 0.96856,0.37942 903 | -0.16644,-1.4369 904 | 1.364,-0.8081 905 | 2.3967,1.423 906 | 7.602,6.2211 907 | -0.5241,0.47605 908 | 2.2534,1.4265 909 | 9.281,11.007 910 | -1.3231,-0.80469 911 | -1.6751,-0.31136 912 | -1.993,-0.54959 913 | 0.7632,0.34901 914 | 9.6786,9.3043 915 | 0.23503,0.743 916 | 9.9414,10.661 917 | -1.2408,-0.079604 918 | 12.124,9.8193 919 | 3.2433,1.5589 920 | -2.2026,-0.13799 921 | 11.914,13.465 922 | 2.5885,1.1344 923 | 8.2701,8.3201 924 | 12.184,11.48 925 | 0.021539,1.4308 926 | 9.2237,11.728 927 | 1.1717,1.7244 928 | 0.55636,-1.0471 929 | -0.28914,-0.47506 930 | -1.3437,-1.5965 931 | -1.1074,-0.90011 932 | 3.2499,1.3549 933 | 0.59098,-1.7984 934 | 12.053,12.967 935 | 9.6584,11.419 936 | -0.45416,-0.20137 937 | 9.9898,8.3882 938 | 10.821,10.146 939 | -1.0794,-0.52382 940 | 10.723,9.9514 941 | -0.3537,-0.33986 942 | -0.43524,-0.67203 943 | -0.37739,0.1037 944 | 2.9547,0.9768 945 | 12.953,12.841 946 | -3.9054,-1.0895 947 | -0.47777,0.5542 948 | 9.7065,12.245 949 | 0.136,-0.72631 950 | 10.608,9.8419 951 | -2.6937,-0.41683 952 | -3.5101,-0.41088 953 | -2.0281,-0.24546 954 | 0.62478,-0.048525 955 | 10.176,11.063 956 | 9.0053,7.4278 957 | -0.19251,-0.09013 958 | 11.99,13.289 959 | 0.43499,0.042456 960 | 10.078,4.9782 961 | -0.17924,0.73569 962 | -0.38093,-0.18284 963 | 3.3278,1.5845 964 | 1.73,0.21423 965 | -1.104,-1.2463 966 | 8.9209,11.346 967 | 0.2242,1.0104 968 | 11.64,13.68 969 | 9.5065,9.8564 970 | 11.381,9.3877 971 | 0.019999,0.21759 972 | 0.75796,0.16314 973 | -2.6508,0.45972 974 | -1.5808,-0.7228 975 | 1.4131,0.18919 976 | 11.966,12.302 977 | -0.51782,-0.5884 978 | -0.7582,-0.5496 979 | 11.959,11.44 980 | -4.0437,-2.4401 981 | 0.77979,0.14231 982 | -0.51164,0.51512 983 | 2.1571,0.2469 984 | 2.5381,0.031367 985 | -2.1453,0.88171 986 | 9.1404,11.134 987 | 4.2577,2.1554 988 | 11.16,13.856 989 | 11.227,11.812 990 | 10.647,11.173 991 | 0.69358,0.1488 992 | -0.78917,-1.0197 993 | 10.1,10.325 994 | 0.84068,-0.81955 995 | 8.7401,10.516 996 | 10.256,9.7508 997 | 8.702,8.2367 998 | 8.7876,5.3568 999 | -0.51219,-0.26696 1000 | 1.2387,0.56984 1001 | -------------------------------------------------------------------------------- /src/GMM/data/Train2.csv: -------------------------------------------------------------------------------- 1 | 14.372,19.909 2 | 12.965,20.145 3 | 1.4002,9.1804 4 | 1.7654,8.5207 5 | 1.6011,8.002 6 | 18.672,21.611 7 | 14.146,19.317 8 | 2.2197,11.021 9 | 2.9723,11.805 10 | 2.2692,9.6697 11 | 12.787,18.496 12 | 1.5492,9.1551 13 | 1.83,12.428 14 | 1.8337,9.5763 15 | 14.147,19.321 16 | 13.534,19.95 17 | 0.93188,7.682 18 | 2.4233,11.555 19 | 2.8688,8.6865 20 | 1.8632,7.1198 21 | 2.7262,9.985 22 | 14.319,19.332 23 | 17.102,21.128 24 | 2.7124,12.526 25 | 2.9837,12.543 26 | 2.7563,11.798 27 | 4.2407,11.071 28 | 1.9862,11.374 29 | 3.1481,12.145 30 | 12.742,19.361 31 | 12.817,18.958 32 | 16.902,20.845 33 | 18.207,20.609 34 | -0.099016,8.5092 35 | 2.2945,10.616 36 | 14.055,19.73 37 | 1.7826,8.0453 38 | 2.9836,11.416 39 | -1.247,9.1302 40 | 2.7797,9.9367 41 | 16.754,20.822 42 | 16.493,20.576 43 | 14.56,20.821 44 | 16.631,21.134 45 | 2.3075,10.191 46 | 20.247,22.871 47 | 0.11082,7.797 48 | 16.327,20.079 49 | 3.1951,14.368 50 | 2.1323,11.325 51 | 17.223,21.699 52 | 16.098,19.831 53 | 1.7109,9.0478 54 | 1.066,9.6783 55 | 2.2445,11.629 56 | 11.656,19.666 57 | 1.6718,10.123 58 | 13.263,20.027 59 | 2.1507,11.314 60 | 0.065132,7.642 61 | 16.295,20.554 62 | 2.2776,10.907 63 | 3.0158,10.252 64 | 16.15,20.549 65 | 13.881,19.434 66 | 12.723,18.603 67 | 3.245,10.913 68 | 2.9887,9.7181 69 | 2.6562,13.617 70 | 3.3765,13.954 71 | 3.4562,12.516 72 | 10.322,18.859 73 | 2.7327,10.07 74 | 12.961,19.142 75 | 14.628,20.636 76 | 3.6102,10.837 77 | 3.2561,11.813 78 | 3.1371,10.416 79 | 14.261,19.801 80 | 4.5491,12.68 81 | 1.3385,7.9523 82 | 17.276,21.214 83 | 14.375,20.826 84 | 1.9644,8.572 85 | 13.115,19.091 86 | 14.623,19.904 87 | 2.529,11.095 88 | 0.81273,10.188 89 | 13.762,20.195 90 | 2.0828,11.221 91 | 0.99675,5.9041 92 | 2.9287,10.868 93 | 0.34206,9.6446 94 | 2.4169,11.348 95 | 1.0704,7.6775 96 | -0.46808,7.988 97 | 2.3616,12.197 98 | 0.82433,9.318 99 | 4.2283,14.443 100 | 16.257,19.528 101 | 15.616,20.118 102 | 14.003,19.787 103 | 2.3608,11.727 104 | 1.1951,10.911 105 | -0.16477,7.911 106 | 0.53308,8.4224 107 | 2.1322,9.2337 108 | 2.9745,10.273 109 | 0.88015,10.486 110 | 2.9646,12.74 111 | 2.9687,10.435 112 | 2.2793,9.9392 113 | 2.5642,13.927 114 | 2.2606,9.7626 115 | 2.8714,10.943 116 | 1.9937,10.123 117 | 2.5979,9.6674 118 | 16.677,21.186 119 | 1.0512,10.004 120 | 3.4788,12.062 121 | 0.78434,8.3298 122 | 0.68719,7.3909 123 | 1.7413,7.9986 124 | 17.039,20.349 125 | 1.5136,10.732 126 | 1.3796,8.7613 127 | 2.254,10.941 128 | 1.0352,8.4616 129 | 1.0784,8.9566 130 | 10.607,17.765 131 | 0.52141,9.6295 132 | 1.3415,9.7398 133 | 14.425,19.279 134 | 2.6823,13.582 135 | 1.5575,8.8164 136 | 3.1535,13.706 137 | 2.0511,8.6717 138 | 12.9,19.132 139 | 1.3891,7.9466 140 | 2.2936,8.948 141 | 11.466,17.785 142 | 2.8528,9.263 143 | 1.5997,6.7407 144 | 2.2731,9.5239 145 | 1.823,8.2526 146 | 3.0509,9.8296 147 | 0.87628,9.2038 148 | 1.9662,9.6626 149 | 17.834,22.152 150 | 0.25554,9.06 151 | -0.066701,8.9149 152 | 2.2278,10.909 153 | 2.2469,10.491 154 | 1.5777,10.822 155 | 14.147,18.792 156 | 12.552,18.003 157 | 0.60302,7.8833 158 | 0.92616,10.159 159 | 0.077962,9.0113 160 | 2.2757,9.7787 161 | 2.5599,11.768 162 | 1.6498,10.412 163 | 1.3414,11.699 164 | 17.546,20.253 165 | 2.8654,10.333 166 | 2.0041,9.9803 167 | 12.983,18.948 168 | 1.0145,9.032 169 | 16.742,21.445 170 | 15.171,20.65 171 | 2.881,12.492 172 | 0.86618,7.5802 173 | 2.4966,9.3155 174 | 11.447,18.188 175 | 17.066,20.658 176 | 2.496,11.537 177 | 2.3793,7.7675 178 | 2.9388,10.777 179 | 2.1593,7.5877 180 | 0.52357,8.9429 181 | 1.544,10.717 182 | 15.661,20.091 183 | 16.338,20.524 184 | 13.007,19.323 185 | 1.5794,8.7713 186 | 2.6678,10.576 187 | 1.392,8.0258 188 | 1.9041,8.2481 189 | 0.25347,7.06 190 | 2.153,12.22 191 | 1.7364,11.451 192 | 13.849,20.291 193 | 1.1354,10.122 194 | 17.181,21.514 195 | 11.137,18.78 196 | 1.7513,9.4208 197 | 13.887,19.19 198 | 1.2836,10.473 199 | 1.0327,8.8034 200 | 1.3575,11.929 201 | 14.311,19.18 202 | 3.1727,12.659 203 | 1.6535,8.454 204 | 16.032,20.257 205 | 1.3722,10.213 206 | 3.5306,13.261 207 | 3.573,12.067 208 | 3.8249,8.5819 209 | 2.9163,10.166 210 | 1.7039,11.499 211 | 1.3778,9.3653 212 | 15.241,20.083 213 | 1.8439,9.6085 214 | 17.99,21.332 215 | 0.63959,7.7718 216 | 15.737,21.003 217 | 16.612,21.303 218 | 15.915,21.085 219 | 2.4354,9.6261 220 | 1.8994,10.841 221 | 3.0214,10.418 222 | 3.1356,12.89 223 | 2.4944,11.215 224 | 3.2444,11.575 225 | 2.5159,8.1874 226 | 2.988,12.078 227 | 3.5433,11.506 228 | 1.6807,9.1001 229 | 1.1789,7.8316 230 | 13.347,19.385 231 | 1.6519,10.505 232 | 0.44305,9.8869 233 | 18.456,21.237 234 | 1.4237,10.039 235 | 1.2863,9.3702 236 | 1.163,9.7965 237 | 2.048,11.444 238 | 0.54322,9.0284 239 | 1.5983,10.304 240 | 0.06499,7.2213 241 | 1.3768,8.7403 242 | 15.838,19.889 243 | 18.901,21.584 244 | 2.9038,10.303 245 | 1.2942,8.2718 246 | 2.2055,9.5923 247 | 18.374,21.888 248 | 13.758,19.147 249 | 3.076,9.6219 250 | 13.39,19.236 251 | 2.1162,9.3083 252 | 3.77,12.658 253 | 3.2887,12.947 254 | 0.7496,6.9634 255 | 10.597,18.058 256 | 2.4458,7.9611 257 | 1.1059,7.9603 258 | 15.634,20.175 259 | 2.0843,10.516 260 | 1.7941,9.8073 261 | 1.6164,9.5389 262 | 2.621,11.522 263 | 11.92,19.44 264 | 1.9911,12.334 265 | 3.0634,10.355 266 | 1.5952,6.5861 267 | 18.53,21.212 268 | 2.5872,7.9519 269 | 14.107,20.137 270 | 13.498,19.517 271 | 14.222,19.321 272 | 2.8094,12.024 273 | 16.711,20.672 274 | 2.7528,11.887 275 | 15.991,21.301 276 | 12.186,18.758 277 | 13.711,20.014 278 | 1.8931,8.7617 279 | 13.104,18.903 280 | 1.94,9.6501 281 | 4.2358,12.304 282 | 17.105,20.933 283 | 2.4092,11.435 284 | 1.8033,10.914 285 | 10.372,17.815 286 | 2.0329,9.1905 287 | 16.958,21.34 288 | 15.995,20.555 289 | 1.9396,9.5328 290 | 14.39,19.564 291 | 14.097,19.211 292 | 0.71615,9.6755 293 | 14.887,19.531 294 | 1.7133,7.1735 295 | 2.0626,8.1808 296 | 1.9888,11.501 297 | 15.279,20.176 298 | 2.7092,12.917 299 | 1.8184,10.573 300 | 1.0448,9.2035 301 | 1.9215,11.21 302 | 10.659,18.295 303 | 1.7114,12.278 304 | 1.8816,8.486 305 | 13.878,18.988 306 | 12.911,18.325 307 | 1.2474,6.9935 308 | 1.3218,8.6812 309 | 1.6809,9.2449 310 | 1.2375,8.4922 311 | 1.9316,11.194 312 | 2.6327,9.4608 313 | 2.9824,11.582 314 | 2.7011,12.325 315 | 14.844,19.406 316 | 3.0172,8.9406 317 | 1.9846,9.9827 318 | 13.522,19.135 319 | 1.5992,10.413 320 | 3.0337,14.872 321 | 16.377,20.621 322 | 12.869,18.749 323 | 15.654,20.333 324 | 1.5371,9.8923 325 | 2.3869,11.881 326 | 3.0901,12.166 327 | 1.9041,9.7499 328 | -0.24311,7.1226 329 | 15.583,21.223 330 | 0.73692,10.746 331 | 9.4065,17.172 332 | 1.9529,10.701 333 | 2.0502,9.3939 334 | 1.137,10.439 335 | 16.747,20.026 336 | 12.631,18.537 337 | 15.412,19.812 338 | 16.439,20.601 339 | 0.13095,9.5403 340 | 0.53008,8.2926 341 | 2.0336,12.212 342 | 16.452,20.139 343 | 16.601,20.215 344 | 2.2168,10.483 345 | 0.088496,5.717 346 | 16.171,20.861 347 | 1.7613,12.525 348 | 2.1064,9.1635 349 | 14.758,19.781 350 | 17.298,21.453 351 | 2.6332,9.8255 352 | 2.1561,9.1749 353 | 1.8043,9.1887 354 | 15.779,20.465 355 | 2.5542,10.662 356 | 13.872,20.39 357 | 2.2186,11.332 358 | 2.7054,10.972 359 | 1.2703,9.6019 360 | 1.5104,10.273 361 | 3.5453,8.1649 362 | 2.8752,9.99 363 | 2.8224,10.638 364 | 1.272,10.557 365 | 2.3618,9.138 366 | 1.1288,11.81 367 | 2.8902,12.005 368 | 2.263,9.6306 369 | 1.7895,11.768 370 | 0.79249,9.0309 371 | 2.7118,8.8424 372 | 2.5753,11.856 373 | 3.5613,10.737 374 | 12.583,18.685 375 | 1.4644,10.475 376 | 0.8634,10.797 377 | 4.5644,11.976 378 | 16.717,21.179 379 | 1.7026,10.762 380 | 14.806,19.022 381 | 1.4828,8.5922 382 | 1.0593,9.6031 383 | 15.906,20.138 384 | 2.4512,10.161 385 | 2.3226,9.398 386 | 0.29763,7.2853 387 | 1.346,11.898 388 | 2.1643,11.411 389 | 16.018,20.674 390 | 15.034,20.014 391 | 15.078,20.429 392 | 15.57,20.151 393 | 3.4838,10.841 394 | 15.32,20.203 395 | 3.0166,10.36 396 | 2.3933,10.42 397 | 16.188,19.726 398 | 13.918,19.176 399 | 13.679,19.153 400 | 1.5326,8.4034 401 | 15.459,19.514 402 | 2.767,10.853 403 | 2.281,10.022 404 | -0.074561,9.0115 405 | 3.6236,9.8505 406 | 2.13,8.4951 407 | 2.5881,8.9976 408 | 2.5852,12.09 409 | 18.223,21.035 410 | 15.205,20.065 411 | 13.089,18.628 412 | 16.242,20.892 413 | 2.0282,11.686 414 | 1.031,8.861 415 | 0.94104,9.3707 416 | 0.57748,9.8214 417 | 2.5478,10.895 418 | 12.117,19.457 419 | 3.6888,10.484 420 | 2.4099,9.7153 421 | 2.6243,11.67 422 | 12.246,18.631 423 | 1.3378,9.8333 424 | 1.0713,10.338 425 | 2.4658,10.424 426 | 16.113,20.965 427 | 2.1957,11.809 428 | 1.7543,9.9126 429 | 16.009,20.008 430 | 2.3178,13.61 431 | 3.531,14.73 432 | 15.733,20.592 433 | 15.489,20.669 434 | 18.633,22.229 435 | 2.9463,11.248 436 | 2.7528,9.3087 437 | 9.9819,18.474 438 | 1.6977,9.869 439 | 4.4015,11.326 440 | 1.6879,10.49 441 | 18.333,21.249 442 | 3.5302,12.2 443 | 1.1544,9.9489 444 | 1.6755,11.743 445 | 1.7594,9.8875 446 | 2.5154,9.1987 447 | 1.7935,9.4398 448 | 1.1702,10.669 449 | 15.859,20.742 450 | 3.4275,10.897 451 | 14.64,20.097 452 | 0.29918,9.1237 453 | 0.67675,8.0796 454 | 3.4992,10.149 455 | 0.17547,7.2715 456 | 3.7393,12.409 457 | 17.546,21.289 458 | 12.436,19.342 459 | 14.45,19.555 460 | 12.891,18.548 461 | 1.6481,10.439 462 | 2.1657,10.371 463 | 17.271,21.425 464 | 3.9736,12.689 465 | 3.529,13.155 466 | 16.827,20.863 467 | 3.2743,12.063 468 | 16.938,20.889 469 | 11.83,19.042 470 | 12.941,18.924 471 | 1.4157,8.9664 472 | 2.882,13.212 473 | 17.109,21.12 474 | 2.3966,10.562 475 | 19.338,21.721 476 | 2.1079,13.317 477 | 15.255,19.393 478 | 1.5773,11.018 479 | 2.5856,8.849 480 | 15.987,19.796 481 | 1.5994,8.0153 482 | 15.453,20.562 483 | 1.7123,9.9 484 | 3.7284,11.16 485 | 0.50376,9.1313 486 | 2.6096,10.224 487 | 2.2911,11.462 488 | 11.518,18.696 489 | 0.45227,8.7138 490 | 1.5811,9.5416 491 | 1.0107,10.188 492 | 18.788,20.834 493 | 3.2137,10.751 494 | 2.0647,11.047 495 | 1.6329,10.031 496 | 10.871,17.861 497 | 0.4346,9.6208 498 | 3.1168,11.842 499 | 1.0371,8.8136 500 | 2.416,10.945 501 | 1.864,11.198 502 | 1.1148,10.747 503 | 18.294,21.173 504 | 17.926,20.656 505 | 2.0866,11.607 506 | 3.0883,9.9691 507 | 0.77927,9.6566 508 | 2.8247,10.273 509 | 13.496,19.146 510 | 0.70571,7.267 511 | 11.734,18.867 512 | 15.576,20.249 513 | 15.558,19.741 514 | 10.817,19 515 | 11.422,19.459 516 | 15.414,19.702 517 | 12.723,18.67 518 | 2.4093,9.1251 519 | 15.979,20.046 520 | 16.387,21.025 521 | 12.58,18.684 522 | 16.401,20.108 523 | 3.4888,9.8225 524 | 3.1321,10.529 525 | 2.0428,9.0845 526 | 0.61041,8.3299 527 | 3.5741,12.429 528 | 3.7747,12.325 529 | 15.695,19.925 530 | 1.8547,9.845 531 | 2.2501,11.61 532 | 3.7837,12.486 533 | 14.289,19.444 534 | 2.1441,8.7357 535 | 2.6268,10.47 536 | 1.3622,7.9075 537 | 2.6113,11.098 538 | 18.22,20.676 539 | 15.163,19.403 540 | 0.88733,10.108 541 | 15.89,20.506 542 | 3.2896,11.761 543 | 2.7967,11.574 544 | 16.141,19.859 545 | 2.4505,12.788 546 | 1.5321,8.292 547 | 4.2699,14.338 548 | 1.2779,11.02 549 | 1.3519,11.69 550 | 1.5943,8.5281 551 | 10.467,18.715 552 | 17.57,20.772 553 | 0.0036281,8.4358 554 | 2.8326,14.182 555 | 2.367,8.3976 556 | 2.3391,11.642 557 | 2.465,9.5052 558 | 1.5595,8.5647 559 | 18.29,22.717 560 | 2.5345,10.432 561 | 2.3501,9.7088 562 | 2.1501,9.2663 563 | 1.8442,9.8914 564 | 9.8744,17.378 565 | 16.931,21.123 566 | -0.094202,8.0749 567 | 15.797,21.005 568 | 12.74,19.713 569 | 12.25,19.116 570 | 1.8009,10.161 571 | 14.741,19.964 572 | 2.6342,7.5694 573 | 1.5543,10.747 574 | 3.8497,11.901 575 | 2.8329,10.567 576 | 17.744,20.44 577 | 15.374,19.713 578 | 1.544,13.639 579 | 18.015,21.548 580 | 3.2309,11.101 581 | 1.9305,9.3399 582 | 2.4578,8.4885 583 | 2.4186,10.589 584 | 11.802,19.019 585 | 11.876,18.102 586 | 1.5975,7.7852 587 | 17.516,21.282 588 | 15.648,20.723 589 | 16.232,20.313 590 | 16.739,21.859 591 | 1.4576,8.7394 592 | 2.3872,9.4445 593 | 2.0764,12.269 594 | 15.18,20.231 595 | 2.0295,7.179 596 | 3.1236,9.0412 597 | 11.279,19.092 598 | 18.268,21.071 599 | 2.1216,10.668 600 | 0.036801,9.302 601 | 2.6819,11.762 602 | 16.659,20.65 603 | 15.712,19.586 604 | 18.231,21.442 605 | 0.88451,10.041 606 | 13.409,18.886 607 | 16.074,20.868 608 | 3.2303,13.49 609 | 3.0838,8.3498 610 | 18.135,21.109 611 | 2.0303,9.0337 612 | 14.1,19.641 613 | 1.534,9.2164 614 | 2.8102,10.045 615 | 1.6651,10.893 616 | 15.04,20.126 617 | 1.7489,12.05 618 | 0.85491,3.717 619 | 1.0915,10.124 620 | 3.0233,11.305 621 | 2.1165,8.4584 622 | 13.041,19.416 623 | 16.354,21.239 624 | 0.67239,8.4243 625 | 2.566,8.0368 626 | 2.5703,7.3046 627 | 2.5567,11.263 628 | 1.3321,10.659 629 | 4.2874,13.137 630 | 1.3565,9.8499 631 | 3.3673,14.302 632 | 1.5781,12.885 633 | 17.257,20.944 634 | 4.6154,11.597 635 | 1.4865,10.369 636 | 2.8147,9.0214 637 | 2.5249,10.328 638 | 14.562,19.939 639 | 2.0978,6.8789 640 | 1.7058,10.205 641 | 3.6531,11.526 642 | 1.0184,10.84 643 | 3.6494,10.242 644 | -0.31252,8.4017 645 | 2.6113,11.434 646 | 2.4964,7.6888 647 | 2.7407,12.076 648 | 2.0162,10.098 649 | 2.8596,11.154 650 | 0.017664,10.705 651 | 1.4335,10.922 652 | 0.27874,9.8982 653 | 16.616,20.81 654 | 16.213,20.149 655 | 14.139,19.458 656 | 0.28827,7.7828 657 | 2.3004,13.592 658 | 0.94021,8.3425 659 | 1.4102,9.2879 660 | 1.3666,8.0542 661 | 4.4067,12.014 662 | -0.61246,7.7456 663 | 2.2731,8.9136 664 | 19.499,21.416 665 | 12.628,18.781 666 | 14.665,19.612 667 | 15.481,20.491 668 | 2.3512,9.6253 669 | 0.26159,9.0351 670 | 0.87324,8.4972 671 | 0.76113,7.0058 672 | 1.8718,10.942 673 | 5.4474,12.776 674 | 13.119,19.696 675 | 2.7971,11.001 676 | 1.7297,11.302 677 | 17.83,21.179 678 | 2.6204,11.261 679 | 14.914,20.182 680 | 2.8934,11.553 681 | 1.7308,10.678 682 | 2.2607,9.3215 683 | 0.99168,11.19 684 | 12.128,18.007 685 | 18.636,22.337 686 | 0.36879,9.5225 687 | 2.0461,12.806 688 | 9.0883,17.776 689 | 2.3926,10.65 690 | 12.09,18.353 691 | 2.2899,8.7233 692 | 16.981,21.413 693 | 2.3363,10.664 694 | 13.709,18.925 695 | 15.652,20.669 696 | 1.6101,8.5851 697 | 2.0669,12.684 698 | 10.665,18.478 699 | 2.7433,11.241 700 | 12.47,19.18 701 | 2.2471,11.054 702 | 2.5713,10.474 703 | 16.127,20.186 704 | 10.762,18.856 705 | 0.80451,11.038 706 | 3.4502,9.8832 707 | 15.902,19.637 708 | 16.99,21.015 709 | 18.141,20.63 710 | 14.994,20.094 711 | 21.782,22.482 712 | 2.2971,12.657 713 | 2.597,8.7292 714 | 16.58,20.661 715 | 12.41,18.759 716 | 17.374,20.752 717 | 3.2191,12.9 718 | 11.894,18.688 719 | 1.1687,8.8667 720 | 3.2726,9.3867 721 | 2.1945,12.519 722 | 1.2975,10.479 723 | 15.194,19.926 724 | 1.2105,8.9453 725 | 2.3475,9.8386 726 | 12.845,19.523 727 | 14.438,20.164 728 | 1.7523,8.8423 729 | 16.156,20.194 730 | 3.5427,9.9089 731 | 3.8767,11.016 732 | 2.1885,10.895 733 | 3.0544,8.6718 734 | 3.5346,10.535 735 | -1.0687,9.6353 736 | 2.329,11.975 737 | 12.881,19.821 738 | 17.571,21.126 739 | 17.474,20.672 740 | 2.1781,9.6246 741 | 4.055,8.5729 742 | 3.267,8.6831 743 | 11.015,18.595 744 | 1.692,11.136 745 | 9.9084,18.176 746 | 2.43,12.115 747 | 2.6386,10.977 748 | 16.567,20.663 749 | 1.9373,7.5267 750 | 15.238,19.236 751 | 2.1941,11.096 752 | 3.0963,12.262 753 | 2.3512,8.6088 754 | 3.092,10.588 755 | 12.651,18.431 756 | 14.811,19.568 757 | 18.62,21.747 758 | 0.44246,6.6598 759 | 2.8325,10.59 760 | 2.3253,11.19 761 | 2.8319,12.738 762 | 1.0854,11.663 763 | 1.7102,8.7402 764 | 2.0974,9.6648 765 | 13.088,19.691 766 | 16.714,20.666 767 | 3.7313,12.85 768 | 16.18,20.99 769 | 1.6501,8.8758 770 | 0.96976,10.595 771 | 15.132,19.312 772 | 13.124,19.153 773 | 16.175,20.143 774 | 2.8292,10.597 775 | 1.8376,12.152 776 | 19.214,21.141 777 | 0.61834,8.6362 778 | 0.5671,10.25 779 | 1.9164,10.772 780 | 1.2481,9.7311 781 | 2.2906,11.194 782 | 15.746,20.445 783 | 1.902,10.18 784 | 16.619,20.926 785 | 3.1913,12.572 786 | 13.157,19.312 787 | 1.6104,10.026 788 | 1.9377,9.3865 789 | 14.862,19.807 790 | 2.3585,11.245 791 | 14.829,19.353 792 | 1.8762,9.1265 793 | 2.4644,10.472 794 | 3.2647,11.887 795 | 11.087,18.038 796 | 2.25,9.0185 797 | 14.99,20.942 798 | 2.9592,11.666 799 | 1.7697,11.218 800 | 0.45798,5.6886 801 | 2.3201,10.729 802 | 0.41931,7.6913 803 | 1.4531,8.7456 804 | 1.0609,8.7686 805 | 4.297,12.713 806 | 3.9266,10.644 807 | 1.795,10.381 808 | 10.957,18.976 809 | 3.1589,12.854 810 | 0.027733,8.444 811 | 1.7453,12.016 812 | 1.5781,7.3706 813 | 2.6011,9.6611 814 | 14.357,20.093 815 | 1.7259,11.451 816 | 2.25,12.888 817 | 16.465,21.036 818 | 2.4074,11.159 819 | 2.837,11.499 820 | -0.13539,9.1002 821 | 2.1129,9.0458 822 | 17.964,20.884 823 | 1.9312,11.241 824 | 0.075791,6.8934 825 | 3.2132,11.028 826 | 0.73355,7.0949 827 | 16.469,20.687 828 | 3.0822,11.586 829 | 0.14212,6.3962 830 | 14.593,20.221 831 | 14.578,19.654 832 | 1.8171,10.216 833 | 3.6355,9.2442 834 | 11.616,18.438 835 | 13.466,18.857 836 | 1.4441,8.3761 837 | 14.089,19.693 838 | 2.7376,10.56 839 | 0.99055,9.323 840 | -0.11633,9.2481 841 | 3.256,9.8117 842 | 2.1542,7.6427 843 | 0.87089,9.4846 844 | 1.0335,8.0702 845 | 0.92369,8.3099 846 | 2.984,12.246 847 | 1.7525,10.394 848 | 1.9533,11.036 849 | 16.352,20.103 850 | 20.866,22.422 851 | 1.0289,10.923 852 | 2.5007,12.078 853 | 10.21,18.288 854 | 10.777,18.155 855 | 1.5047,9.0768 856 | 11.446,19.625 857 | 18.311,22.215 858 | 0.55852,9.5844 859 | 3.3392,11.357 860 | 15.244,20.493 861 | 2.7656,12.097 862 | 0.17897,6.9788 863 | 2.0629,9.3836 864 | 16.156,21.153 865 | 0.49051,7.7721 866 | 12.72,19.337 867 | 2.8788,11.149 868 | 1.8973,8.3967 869 | 0.15911,6.4288 870 | 3.0077,11.375 871 | 1.471,9.3822 872 | 13.557,18.893 873 | 0.11437,8.874 874 | 1.2279,7.969 875 | 16.948,20.942 876 | 0.78259,7.0693 877 | 15.618,19.774 878 | 13.361,18.519 879 | 1.9965,10.948 880 | 2.3958,12.236 881 | 3.2623,9.3737 882 | 1.6588,11.036 883 | 1.9883,11.988 884 | 1.9455,7.7088 885 | 2.6332,9.5414 886 | 2.6019,10.039 887 | 14.854,20.712 888 | 1.0751,9.5519 889 | 2.561,10.561 890 | 2.4363,11.779 891 | 16.16,21.076 892 | 0.30425,6.2725 893 | 2.3233,10.159 894 | 1.5,8.8066 895 | 1.8957,12.464 896 | 1.1891,10.075 897 | 10.52,18.227 898 | 14.697,20.48 899 | 1.4076,8.5273 900 | 2.3637,9.5151 901 | 11.731,19.024 902 | 2.8437,11.873 903 | 13.218,18.695 904 | 2.5382,11.916 905 | 0.81259,9.2722 906 | 2.062,9.8205 907 | 14.411,20.163 908 | 2.8954,12.693 909 | 1.8694,10.26 910 | 16.681,20.443 911 | 1.111,7.7742 912 | 2.7038,11.177 913 | 18.382,21.494 914 | 1.1058,7.9362 915 | 12.219,18.671 916 | 12.335,17.734 917 | 1.979,11.844 918 | 3.1184,11.783 919 | 1.7143,8.8202 920 | 17.374,20.562 921 | 2.8036,13.174 922 | 1.1148,10.556 923 | 15.348,19.854 924 | 2.5569,13.096 925 | 17.501,21.173 926 | 12.705,18.814 927 | 14.486,19.874 928 | 18.225,20.536 929 | 2.4838,11.322 930 | 1.2989,8.0877 931 | 2.0701,11.346 932 | 2.1212,9.6991 933 | 1.2985,10.631 934 | 3.4867,12.009 935 | 2.3712,12.409 936 | 15.245,19.606 937 | 1.9497,10.154 938 | 2.5721,8.9586 939 | 14.518,20.035 940 | 17.567,21.218 941 | 0.76568,6.1053 942 | 16.114,20.155 943 | 1.5159,8.8046 944 | 16.799,20.272 945 | 0.72204,8.8321 946 | 2.2942,10.167 947 | 0.71574,9.2648 948 | 2.4409,10.34 949 | 19.216,22.076 950 | 1.6343,10.974 951 | 1.1525,9.146 952 | 2.7529,14.086 953 | 12.977,18.927 954 | 2.0067,9.1559 955 | 2.1632,12.195 956 | 2.4163,10.156 957 | 1.7738,11.135 958 | 3.4385,10.876 959 | 3.0632,9.8493 960 | 16.965,20.168 961 | 1.5799,10.631 962 | 14.557,19.413 963 | 2.5033,11.092 964 | 2.0392,9.2908 965 | 21.467,23.133 966 | 2.6008,10.324 967 | 15.537,20.413 968 | 0.80158,11.443 969 | 2.8966,11.041 970 | 2.6976,12.635 971 | 1.9003,8.0955 972 | 13.856,19.513 973 | 4.1349,13.147 974 | 1.4969,7.3023 975 | 1.8581,11.567 976 | 2.4118,9.7254 977 | 2.4908,12.619 978 | 2.2048,11.651 979 | 2.5971,10.207 980 | 13.439,19.337 981 | 13.968,19.339 982 | 0.87939,9.238 983 | 2.7337,11.293 984 | 1.2864,6.9901 985 | 1.7251,8.5695 986 | 16.777,21.139 987 | 14.327,20.347 988 | 1.9166,10.23 989 | 2.5707,10.851 990 | 14.689,19.939 991 | 0.4342,8.7204 992 | 1.728,9.8851 993 | 12.359,18.284 994 | 1.4515,11.217 995 | 2.6463,13.134 996 | 1.9198,10.298 997 | 2.654,9.3146 998 | 1.1172,9.7477 999 | 16.017,19.476 1000 | 1.9983,8.8181 1001 | -------------------------------------------------------------------------------- /src/GMM/data_helper.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import numpy as np 3 | import csv 4 | 5 | 6 | def load_sample_data(): 7 | """ 8 | load sample data. 9 | :return: 10 | """ 11 | data = np.array( 12 | [[3.600, 79], [1.800, 54], [3.333, 74], [2.283, 62], [4.533, 85], [2.883, 55], [4.700, 88], [3.600, 85], 13 | [1.950, 51], [4.350, 85], [1.833, 54], [3.917, 84], [4.200, 78], [1.750, 47], [4.700, 83], [2.167, 52], 14 | [1.750, 62], [4.800, 84], [1.600, 52], [4.250, 79], [1.800, 51], [1.750, 47], [3.450, 78], [3.067, 69], 15 | [4.533, 74], [3.600, 83], [1.967, 55], [4.083, 76], [3.850, 78], [4.433, 79], [4.300, 73], [4.467, 77], 16 | [3.367, 66], [4.033, 80], [3.833, 74], [2.017, 52], [1.867, 48], [4.833, 80], [1.833, 59], [4.783, 90], 17 | [4.350, 80], [1.883, 58], [4.567, 84], [1.750, 58], [4.533, 73], [3.317, 83], [3.833, 64], [2.100, 53], 18 | [4.633, 82], [2.000, 59], [4.800, 75], [4.716, 90], [1.833, 54], [4.833, 80], [1.733, 54], [4.883, 83], 19 | [3.717, 71], [1.667, 64], [4.567, 77], [4.317, 81], [2.233, 59], [4.500, 84], [1.750, 48], [4.800, 82], 20 | [1.817, 60], [4.400, 92], [4.167, 78], [4.700, 78], [2.067, 65], [4.700, 73], [4.033, 82], [1.967, 56], 21 | [4.500, 79], [4.000, 71], [1.983, 62], [5.067, 76], [2.017, 60], [4.567, 78], [3.883, 76], [3.600, 83], 22 | [4.133, 75], [4.333, 82], [4.100, 70], [2.633, 65], [4.067, 73], [4.933, 88], [3.950, 76], [4.517, 80], 23 | [2.167, 48], [4.000, 86], [2.200, 60], [4.333, 90], [1.867, 50], [4.817, 78], [1.833, 63], [4.300, 72], 24 | [4.667, 84], [3.750, 75], [1.867, 51], [4.900, 82], [2.483, 62], [4.367, 88], [2.100, 49], [4.500, 83], 25 | [4.050, 81], [1.867, 47], [4.700, 84], [1.783, 52], [4.850, 86], [3.683, 81], [4.733, 75], [2.300, 59], 26 | [4.900, 89], [4.417, 79], [1.700, 59], [4.633, 81], [2.317, 50], [4.600, 85], [1.817, 59], [4.417, 87], 27 | [2.617, 53], [4.067, 69], [4.250, 77], [1.967, 56], [4.600, 88], [3.767, 81], [1.917, 45], [4.500, 82], 28 | [2.267, 55], [4.650, 90], [1.867, 45], [4.167, 83], [2.800, 56], [4.333, 89], [1.833, 46], [4.383, 82], 29 | [1.883, 51], [4.933, 86], [2.033, 53], [3.733, 79], [4.233, 81], [2.233, 60], [4.533, 82], [4.817, 77], 30 | [4.333, 76], [1.983, 59], [4.633, 80], [2.017, 49], [5.100, 96], [1.800, 53], [5.033, 77], [4.000, 77], 31 | [2.400, 65], [4.600, 81], [3.567, 71], [4.000, 70], [4.500, 81], [4.083, 93], [1.800, 53], [3.967, 89], 32 | [2.200, 45], [4.150, 86], [2.000, 58], [3.833, 78], [3.500, 66], [4.583, 76], [2.367, 63], [5.000, 88], 33 | [1.933, 52], [4.617, 93], [1.917, 49], [2.083, 57], [4.583, 77], [3.333, 68], [4.167, 81], [4.333, 81], 34 | [4.500, 73], [2.417, 50], [4.000, 85], [4.167, 74], [1.883, 55], [4.583, 77], [4.250, 83], [3.767, 83], 35 | [2.033, 51], [4.433, 78], [4.083, 84], [1.833, 46], [4.417, 83], [2.183, 55], [4.800, 81], [1.833, 57], 36 | [4.800, 76], [4.100, 84], [3.966, 77], [4.233, 81], [3.500, 87], [4.366, 77], [2.250, 51], [4.667, 78], 37 | [2.100, 60], [4.350, 82], [4.133, 91], [1.867, 53], [4.600, 78], [1.783, 46], [4.367, 77], [3.850, 84], 38 | [1.933, 49], [4.500, 83], [2.383, 71], [4.700, 80], [1.867, 49], [3.833, 75], [3.417, 64], [4.233, 76], 39 | [2.400, 53], [4.800, 94], [2.000, 55], [4.150, 76], [1.867, 50], [4.267, 82], [1.750, 54], [4.483, 75], 40 | [4.000, 78], [4.117, 79], [4.083, 78], [4.267, 78], [3.917, 70], [4.550, 79], [4.083, 70], [2.417, 54], 41 | [4.183, 86], [2.217, 50], [4.450, 90], [1.883, 54], [1.850, 54], [4.283, 77], [3.950, 79], [2.333, 64], 42 | [4.150, 75], [2.350, 47], [4.933, 86], [2.900, 63], [4.583, 85], [3.833, 82], [2.083, 57], [4.367, 82], 43 | [2.133, 67], [4.350, 74], [2.200, 54], [4.450, 83], [3.567, 73], [4.500, 73], [4.150, 88], [3.817, 80], 44 | [3.917, 71], [4.450, 83], [2.000, 56], [4.283, 79], [4.767, 78], [4.533, 84], [1.850, 58], [4.250, 83], 45 | [1.983, 43], [2.250, 60], [4.750, 75], [4.117, 81], [2.150, 46], [4.417, 90], [1.817, 46], [4.467, 74]]) 46 | return data 47 | 48 | 49 | def load_samples_data(train1_path='data/Train1.csv', train2_path='data/Train2.csv'): 50 | """ 51 | load Train1 and Train2 data. 52 | :param train1_path: 53 | :param train2_path: 54 | :return: 55 | """ 56 | with open(train1_path, 'r') as f1: 57 | lines = csv.reader(f1) 58 | train1_data = list(lines) 59 | 60 | with open(train2_path, 'r') as f2: 61 | lines = csv.reader(f2) 62 | train2_data = list(lines) 63 | return np.array(train1_data, dtype="float64"), np.array(train2_data, dtype='float64') 64 | 65 | 66 | def load_samples_test_data(test1_path='data/Test1.csv', test2_path='data/Test2.csv'): 67 | """ 68 | load Test1 data and Test2 data. 69 | :param test1_path: 70 | :param test2_path: 71 | :return: 72 | """ 73 | with open(test1_path, 'r') as f1: 74 | lines = csv.reader(f1) 75 | test1_data = list(lines) 76 | 77 | with open(test2_path, 'r') as f2: 78 | lines = csv.reader(f2) 79 | test2_data = list(lines) 80 | return np.array(test1_data, dtype='float64'), np.array(test2_data, dtype='float64') 81 | 82 | 83 | def load_mnist_data(filename='./data/TestSamples.csv', 84 | label_filename='./data/TrueLabels.csv'): 85 | """ 86 | load mnist data 87 | :param filename: 88 | :param label_filename: 89 | :return: 90 | """ 91 | 92 | with open(filename, 'r') as csvfile: 93 | lines = csv.reader(csvfile) 94 | dataSet = list(lines) 95 | 96 | with open(label_filename, 'r') as f: 97 | lines = csv.reader(f) 98 | training_data_label = list(lines) 99 | 100 | # transfer label to 1 dim, char to num 101 | training_data_label = [int(la[0]) for la in training_data_label] 102 | return np.array(dataSet, dtype='float64'), np.array(training_data_label) 103 | 104 | 105 | if __name__ == "__main__": 106 | train1_data, train2_data = load_samples_data() 107 | print(train1_data) 108 | print() 109 | print(train2_data) 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /src/GMM/pictures/mnist_res.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/GMM/pictures/mnist_res.png -------------------------------------------------------------------------------- /src/GMM/readme.md: -------------------------------------------------------------------------------- 1 | # GMM 2 | 高斯混合模型(Gaussian Mixed Model)指的是多个高斯分布函数的线性组合,理论上GMM可以拟合出任意类型的分布,通常用于解决同一集合下的数据包含多个不同的分布的情况。 3 | 4 | 5 | 6 | 7 | ## result 8 | 使用GMM分类器在mnist上的分类结果: 9 | 10 | ![mnist result](/src/GMM/pictures/mnist_res.png) 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/LMSE/data/Samples.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/LMSE/data/Samples.mat -------------------------------------------------------------------------------- /src/LMSE/data_helper.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import numpy as np 3 | import csv 4 | 5 | def load_sample_data(): 6 | """ 7 | load sample data. 8 | :return: 9 | """ 10 | datas = [ 11 | [1, 1], [2, 2], [2, 0], 12 | [0, 0], [1, 0], [0, 1], 13 | ] 14 | labels = [1, 1, 1, 2, 2, 2] 15 | return np.array(datas, dtype='float64'), np.array(labels) 16 | 17 | 18 | def load_mnist_data(filename='./data/TestSamples.csv', 19 | label_filename='./data/TrueLabels.csv'): 20 | """ 21 | load mnist data 22 | :param filename: 23 | :param label_filename: 24 | :return: 25 | """ 26 | 27 | with open(filename, 'r') as csvfile: 28 | lines = csv.reader(csvfile) 29 | dataSet = list(lines) 30 | 31 | with open(label_filename, 'r') as f: 32 | lines = csv.reader(f) 33 | training_data_label = list(lines) 34 | 35 | # transfer label to 1 dim, char to num 36 | training_data_label = [int(la[0]) for la in training_data_label] 37 | return np.array(dataSet, dtype='float64'), np.array(training_data_label) 38 | 39 | 40 | if __name__ == "__main__": 41 | datas, labels = load_sample_data() 42 | print(datas) 43 | print(labels) 44 | -------------------------------------------------------------------------------- /src/LMSE/lsme.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # coding:utf-8 3 | 4 | """ 5 | @author: yyhaker 6 | @contact: 572176750@qq.com 7 | @file: lsme.py 8 | @time: 2018/11/11 18:52 9 | """ 10 | 11 | import numpy as np 12 | import matplotlib.pyplot as plt 13 | from data_helper import load_sample_data, load_mnist_data 14 | 15 | 16 | class LSME(object): 17 | """最小均方误差算法""" 18 | def __init__(self): 19 | pass 20 | 21 | def predict(self, data, alpha): 22 | """ 23 | predict the label of the sample data. 24 | :param data: 增广后的数据 25 | :param alpha: alpha 26 | :return: 27 | 'label': 1 or 2. (类别) 28 | """ 29 | res = np.dot(alpha, data) 30 | if res > 0: 31 | return 1 32 | else: 33 | return 2 34 | 35 | def train(self, datas, another=3): 36 | """ 37 | :param datas: datas 38 | :param another: another class from idx. 39 | :return: 40 | """ 41 | # 增广数据 42 | # n x d 43 | n, d = datas.shape 44 | # aug datas (n, d) -> (n, 1+d) 45 | ones = np.ones(n) 46 | datas = np.insert(datas, 0, values=ones, axis=1) 47 | 48 | # 第二种类别乘以-1 49 | datas[another:] = datas[another:] * (-1) 50 | 51 | # 伪逆求解 52 | b = np.ones(n) 53 | YTY = np.dot(datas.T, datas) 54 | inv = np.linalg.inv(YTY) 55 | false_inv = np.dot(inv, datas.T) 56 | alpha = np.dot(false_inv, b) 57 | return alpha 58 | 59 | def plot_result(self, datas, alpha): 60 | """ 61 | plot the res. 62 | :param datas: n x d. 63 | :param alpha: 1+d. 64 | :return: 65 | """ 66 | colorMark = ['or', 'dg'] 67 | for idx, data in enumerate(datas): 68 | plt.plot(data[0], data[1], colorMark[idx >= 3]) 69 | x = np.linspace(-1, 3, 1000) 70 | y = -(alpha[0] + alpha[1] * x) / alpha[2] 71 | plt.plot(x, y, color='blue') 72 | plt.show() 73 | 74 | 75 | def experiment(): 76 | datas, labels = load_sample_data() 77 | lsme = LSME() 78 | alpha = lsme.train(datas) 79 | print("last alpha: ", alpha) 80 | lsme.plot_result(datas, alpha) 81 | 82 | 83 | def experiment2(): 84 | """ 85 | 使用LSME算法分类多类样本. 86 | ------ 87 | 1. 数据集归类 88 | 2. 每两类训练一个感知器模型,得到参数alpha,这样总共得到c(c-1)/2个 89 | 3. 对于测试样本x, 如果g_{ij}(x)>=0, 对于任意j不等于i,则x属于w_i. 90 | :return: 91 | """ 92 | # 数据集归类 93 | train_datas, train_labels = load_mnist_data() 94 | n, d = train_datas.shape 95 | print("total train datas is {}, dim is: {}".format(n, d)) 96 | datas = {} 97 | for idx, j in enumerate(train_labels): 98 | if j not in datas.keys(): 99 | datas[j] = [] 100 | datas[j].append(train_datas[idx]) 101 | c = len(datas.keys()) 102 | 103 | # 每两类训练一个感知器模型 104 | alphas = np.zeros((c, c, 1+d)) 105 | combines = [] 106 | for i in datas.keys(): 107 | for j in datas.keys(): 108 | if i != j: 109 | combines.append((i, j)) 110 | for i, j in combines: 111 | dataij = np.concatenate((datas[i], datas[j]), axis=0) 112 | # print(len(dataij), len(datas[i]), len(datas[j])) 113 | lsme = LSME() 114 | alphas[i, j] = lsme.train(dataij, another=len(datas[i])) 115 | print("=========>>> alpha[{}. {}] is {}".format(i, j, alphas[i, j])) 116 | 117 | # 对于测试样本x, 如果g_{ij}(x)>=0, 对于任意j不等于i,则x属于w_i. 118 | test_datas, test_labels = load_mnist_data(filename='./data/TestSamples.csv', 119 | label_filename='./data/TestLabels.csv') 120 | test_n, test_dim = test_datas.shape 121 | print("total test datas is: {}, dim is: {}".format(test_n, test_dim)) 122 | count = 0 123 | test_datas = np.insert(test_datas, 0, values=np.ones(test_n), axis=1) 124 | print("begin testing....") 125 | for idx, data in enumerate(test_datas): 126 | p_lbl = -1 127 | for i in range(c): 128 | flag = True 129 | for j in range(c): 130 | if (i, j) in combines: 131 | if np.dot(data, alphas[i, j]) < 0: 132 | flag = False 133 | break 134 | if flag: 135 | p_lbl = i 136 | if p_lbl == test_labels[idx]: 137 | count += 1 138 | print("total test acc is {} / {} = {}".format(count, test_n, (count + 0.0)/test_n)) 139 | 140 | 141 | if __name__ == "__main__": 142 | experiment2() 143 | -------------------------------------------------------------------------------- /src/LMSE/pictures/lsme_res.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/LMSE/pictures/lsme_res.png -------------------------------------------------------------------------------- /src/LMSE/readme.md: -------------------------------------------------------------------------------- 1 | # 最小均方误差算法(LSME) 2 | 最小均方误差算法是一种分类算法,其基本思想是将求解线性不等式组的问题转化为求解线性方程组,并采用误差矢量的平方作为准则函数。 3 | 4 | 5 | 6 | 7 | 8 | ## result 9 | 1. 使用LSME分类样本数据点,结果如下: 10 | 11 | ![lsme res](/src/LMSE/pictures/lsme_res.png) 12 | 13 | 2. 使用LSME解决样本多分类问题: 14 | 每两个训练一个分类器,总共有c(c-1)/2个分类器,测试时候如果对任意j != i,有gij(x) >= 0,则决策属于wi;其它情况,则拒识。 15 | 16 | 最后在17维mnist数据集上测试准确率0.8645 17 | -------------------------------------------------------------------------------- /src/common_functions/activation_functions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # coding:utf-8 3 | 4 | """ 5 | @author: yyhaker 6 | @contact: 572176750@qq.com 7 | @file: activation_functions.py 8 | @time: 2019/7/19 20:38 9 | """ 10 | import numpy as np 11 | 12 | 13 | def sigmoid(x): 14 | """sigmoid function(vectorized)""" 15 | s = 1 / (1 + np.exp(-x)) 16 | return s 17 | 18 | 19 | def tanh(x): 20 | """tanh function(vectorized)""" 21 | s1 = np.exp(x) - np.exp(-x) 22 | s2 = np.exp(x) + np.exp(-x) 23 | s = s1 / s2 24 | return s 25 | 26 | 27 | def relu(x): 28 | """relu function(vectorized)""" 29 | s = np.where(x < 0, 0, x) 30 | return s 31 | 32 | 33 | def softmax(x): 34 | """softmax function(vectorized)""" 35 | x_exp = np.exp(x) 36 | x_sum = np.sum(x_exp, axis=1, keepdims=True) 37 | s = x_exp / x_sum 38 | return s 39 | 40 | -------------------------------------------------------------------------------- /src/common_functions/loss_functions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # coding:utf-8 3 | 4 | """ 5 | @author: yyhaker 6 | @contact: 572176750@qq.com 7 | @file: loss_functions.py 8 | @time: 2019/7/19 20:29 9 | """ 10 | """ 11 | 实现常见的损失函数 12 | """ 13 | import numpy as np 14 | 15 | 16 | def cross_entropy(Y, P): 17 | """Cross-Entropy loss function. 18 | 以向量化的方式实现交叉熵函数 19 | Y and P are lists of labels and estimations 20 | returns the float corresponding to their cross-entropy. 21 | """ 22 | Y = np.float_(Y) 23 | P = np.float_(P) 24 | return -np.sum(Y * np.log(P) + (1 - Y) * np.log(1 - P)) / len(Y) 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/k-means/data/iris.data: -------------------------------------------------------------------------------- 1 | 5.1,3.5,1.4,0.2,Iris-setosa 2 | 4.9,3.0,1.4,0.2,Iris-setosa 3 | 4.7,3.2,1.3,0.2,Iris-setosa 4 | 4.6,3.1,1.5,0.2,Iris-setosa 5 | 5.0,3.6,1.4,0.2,Iris-setosa 6 | 5.4,3.9,1.7,0.4,Iris-setosa 7 | 4.6,3.4,1.4,0.3,Iris-setosa 8 | 5.0,3.4,1.5,0.2,Iris-setosa 9 | 4.4,2.9,1.4,0.2,Iris-setosa 10 | 4.9,3.1,1.5,0.1,Iris-setosa 11 | 5.4,3.7,1.5,0.2,Iris-setosa 12 | 4.8,3.4,1.6,0.2,Iris-setosa 13 | 4.8,3.0,1.4,0.1,Iris-setosa 14 | 4.3,3.0,1.1,0.1,Iris-setosa 15 | 5.8,4.0,1.2,0.2,Iris-setosa 16 | 5.7,4.4,1.5,0.4,Iris-setosa 17 | 5.4,3.9,1.3,0.4,Iris-setosa 18 | 5.1,3.5,1.4,0.3,Iris-setosa 19 | 5.7,3.8,1.7,0.3,Iris-setosa 20 | 5.1,3.8,1.5,0.3,Iris-setosa 21 | 5.4,3.4,1.7,0.2,Iris-setosa 22 | 5.1,3.7,1.5,0.4,Iris-setosa 23 | 4.6,3.6,1.0,0.2,Iris-setosa 24 | 5.1,3.3,1.7,0.5,Iris-setosa 25 | 4.8,3.4,1.9,0.2,Iris-setosa 26 | 5.0,3.0,1.6,0.2,Iris-setosa 27 | 5.0,3.4,1.6,0.4,Iris-setosa 28 | 5.2,3.5,1.5,0.2,Iris-setosa 29 | 5.2,3.4,1.4,0.2,Iris-setosa 30 | 4.7,3.2,1.6,0.2,Iris-setosa 31 | 4.8,3.1,1.6,0.2,Iris-setosa 32 | 5.4,3.4,1.5,0.4,Iris-setosa 33 | 5.2,4.1,1.5,0.1,Iris-setosa 34 | 5.5,4.2,1.4,0.2,Iris-setosa 35 | 4.9,3.1,1.5,0.1,Iris-setosa 36 | 5.0,3.2,1.2,0.2,Iris-setosa 37 | 5.5,3.5,1.3,0.2,Iris-setosa 38 | 4.9,3.1,1.5,0.1,Iris-setosa 39 | 4.4,3.0,1.3,0.2,Iris-setosa 40 | 5.1,3.4,1.5,0.2,Iris-setosa 41 | 5.0,3.5,1.3,0.3,Iris-setosa 42 | 4.5,2.3,1.3,0.3,Iris-setosa 43 | 4.4,3.2,1.3,0.2,Iris-setosa 44 | 5.0,3.5,1.6,0.6,Iris-setosa 45 | 5.1,3.8,1.9,0.4,Iris-setosa 46 | 4.8,3.0,1.4,0.3,Iris-setosa 47 | 5.1,3.8,1.6,0.2,Iris-setosa 48 | 4.6,3.2,1.4,0.2,Iris-setosa 49 | 5.3,3.7,1.5,0.2,Iris-setosa 50 | 5.0,3.3,1.4,0.2,Iris-setosa 51 | 7.0,3.2,4.7,1.4,Iris-versicolor 52 | 6.4,3.2,4.5,1.5,Iris-versicolor 53 | 6.9,3.1,4.9,1.5,Iris-versicolor 54 | 5.5,2.3,4.0,1.3,Iris-versicolor 55 | 6.5,2.8,4.6,1.5,Iris-versicolor 56 | 5.7,2.8,4.5,1.3,Iris-versicolor 57 | 6.3,3.3,4.7,1.6,Iris-versicolor 58 | 4.9,2.4,3.3,1.0,Iris-versicolor 59 | 6.6,2.9,4.6,1.3,Iris-versicolor 60 | 5.2,2.7,3.9,1.4,Iris-versicolor 61 | 5.0,2.0,3.5,1.0,Iris-versicolor 62 | 5.9,3.0,4.2,1.5,Iris-versicolor 63 | 6.0,2.2,4.0,1.0,Iris-versicolor 64 | 6.1,2.9,4.7,1.4,Iris-versicolor 65 | 5.6,2.9,3.6,1.3,Iris-versicolor 66 | 6.7,3.1,4.4,1.4,Iris-versicolor 67 | 5.6,3.0,4.5,1.5,Iris-versicolor 68 | 5.8,2.7,4.1,1.0,Iris-versicolor 69 | 6.2,2.2,4.5,1.5,Iris-versicolor 70 | 5.6,2.5,3.9,1.1,Iris-versicolor 71 | 5.9,3.2,4.8,1.8,Iris-versicolor 72 | 6.1,2.8,4.0,1.3,Iris-versicolor 73 | 6.3,2.5,4.9,1.5,Iris-versicolor 74 | 6.1,2.8,4.7,1.2,Iris-versicolor 75 | 6.4,2.9,4.3,1.3,Iris-versicolor 76 | 6.6,3.0,4.4,1.4,Iris-versicolor 77 | 6.8,2.8,4.8,1.4,Iris-versicolor 78 | 6.7,3.0,5.0,1.7,Iris-versicolor 79 | 6.0,2.9,4.5,1.5,Iris-versicolor 80 | 5.7,2.6,3.5,1.0,Iris-versicolor 81 | 5.5,2.4,3.8,1.1,Iris-versicolor 82 | 5.5,2.4,3.7,1.0,Iris-versicolor 83 | 5.8,2.7,3.9,1.2,Iris-versicolor 84 | 6.0,2.7,5.1,1.6,Iris-versicolor 85 | 5.4,3.0,4.5,1.5,Iris-versicolor 86 | 6.0,3.4,4.5,1.6,Iris-versicolor 87 | 6.7,3.1,4.7,1.5,Iris-versicolor 88 | 6.3,2.3,4.4,1.3,Iris-versicolor 89 | 5.6,3.0,4.1,1.3,Iris-versicolor 90 | 5.5,2.5,4.0,1.3,Iris-versicolor 91 | 5.5,2.6,4.4,1.2,Iris-versicolor 92 | 6.1,3.0,4.6,1.4,Iris-versicolor 93 | 5.8,2.6,4.0,1.2,Iris-versicolor 94 | 5.0,2.3,3.3,1.0,Iris-versicolor 95 | 5.6,2.7,4.2,1.3,Iris-versicolor 96 | 5.7,3.0,4.2,1.2,Iris-versicolor 97 | 5.7,2.9,4.2,1.3,Iris-versicolor 98 | 6.2,2.9,4.3,1.3,Iris-versicolor 99 | 5.1,2.5,3.0,1.1,Iris-versicolor 100 | 5.7,2.8,4.1,1.3,Iris-versicolor 101 | 6.3,3.3,6.0,2.5,Iris-virginica 102 | 5.8,2.7,5.1,1.9,Iris-virginica 103 | 7.1,3.0,5.9,2.1,Iris-virginica 104 | 6.3,2.9,5.6,1.8,Iris-virginica 105 | 6.5,3.0,5.8,2.2,Iris-virginica 106 | 7.6,3.0,6.6,2.1,Iris-virginica 107 | 4.9,2.5,4.5,1.7,Iris-virginica 108 | 7.3,2.9,6.3,1.8,Iris-virginica 109 | 6.7,2.5,5.8,1.8,Iris-virginica 110 | 7.2,3.6,6.1,2.5,Iris-virginica 111 | 6.5,3.2,5.1,2.0,Iris-virginica 112 | 6.4,2.7,5.3,1.9,Iris-virginica 113 | 6.8,3.0,5.5,2.1,Iris-virginica 114 | 5.7,2.5,5.0,2.0,Iris-virginica 115 | 5.8,2.8,5.1,2.4,Iris-virginica 116 | 6.4,3.2,5.3,2.3,Iris-virginica 117 | 6.5,3.0,5.5,1.8,Iris-virginica 118 | 7.7,3.8,6.7,2.2,Iris-virginica 119 | 7.7,2.6,6.9,2.3,Iris-virginica 120 | 6.0,2.2,5.0,1.5,Iris-virginica 121 | 6.9,3.2,5.7,2.3,Iris-virginica 122 | 5.6,2.8,4.9,2.0,Iris-virginica 123 | 7.7,2.8,6.7,2.0,Iris-virginica 124 | 6.3,2.7,4.9,1.8,Iris-virginica 125 | 6.7,3.3,5.7,2.1,Iris-virginica 126 | 7.2,3.2,6.0,1.8,Iris-virginica 127 | 6.2,2.8,4.8,1.8,Iris-virginica 128 | 6.1,3.0,4.9,1.8,Iris-virginica 129 | 6.4,2.8,5.6,2.1,Iris-virginica 130 | 7.2,3.0,5.8,1.6,Iris-virginica 131 | 7.4,2.8,6.1,1.9,Iris-virginica 132 | 7.9,3.8,6.4,2.0,Iris-virginica 133 | 6.4,2.8,5.6,2.2,Iris-virginica 134 | 6.3,2.8,5.1,1.5,Iris-virginica 135 | 6.1,2.6,5.6,1.4,Iris-virginica 136 | 7.7,3.0,6.1,2.3,Iris-virginica 137 | 6.3,3.4,5.6,2.4,Iris-virginica 138 | 6.4,3.1,5.5,1.8,Iris-virginica 139 | 6.0,3.0,4.8,1.8,Iris-virginica 140 | 6.9,3.1,5.4,2.1,Iris-virginica 141 | 6.7,3.1,5.6,2.4,Iris-virginica 142 | 6.9,3.1,5.1,2.3,Iris-virginica 143 | 5.8,2.7,5.1,1.9,Iris-virginica 144 | 6.8,3.2,5.9,2.3,Iris-virginica 145 | 6.7,3.3,5.7,2.5,Iris-virginica 146 | 6.7,3.0,5.2,2.3,Iris-virginica 147 | 6.3,2.5,5.0,1.9,Iris-virginica 148 | 6.5,3.0,5.2,2.0,Iris-virginica 149 | 6.2,3.4,5.4,2.3,Iris-virginica 150 | 5.9,3.0,5.1,1.8,Iris-virginica -------------------------------------------------------------------------------- /src/k-means/data_helper.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import csv 3 | import random 4 | import numpy as np 5 | 6 | 7 | def load_iris_data(filename, split): 8 | """ 9 | load iris data, and split the training and test set. 10 | :param filename: the data path 11 | :param split: split rate 12 | :return: 13 | 'trainSet': 14 | 'testSet': 15 | """ 16 | trainSet = [] 17 | testSet = [] 18 | with open(filename, 'r') as csvfile: 19 | lines = csv.reader(csvfile) 20 | dataSet = list(lines) 21 | for x in range(len(dataSet)): 22 | for y in range(4): 23 | dataSet[x][y] = float(dataSet[x][y]) 24 | if random.random() < split: 25 | trainSet.append(dataSet[x]) 26 | else: 27 | testSet.append(dataSet[x]) 28 | return trainSet, testSet 29 | 30 | 31 | def load_mnist_data(filename='./data/ClusterSamples.csv', 32 | label_filename='./data/SampleLabels.csv'): 33 | """ 34 | load mnist data 35 | :param filename: 36 | :param label_filename: 37 | :return: 38 | """ 39 | 40 | with open(filename, 'r') as csvfile: 41 | lines = csv.reader(csvfile) 42 | dataSet = list(lines) 43 | 44 | with open(label_filename, 'r') as f: 45 | lines = csv.reader(f) 46 | training_data_label = list(lines) 47 | 48 | # transfer label to 1 dim, char to num 49 | training_data_label = [int(la[0]) for la in training_data_label] 50 | return np.array(dataSet, dtype='float64'), np.array(training_data_label) 51 | 52 | 53 | def load_sample_data(): 54 | """ 55 | the sample data is to test the model if right. 56 | :return: 57 | """ 58 | labels = None 59 | dataSets = [ 60 | [0, 0], [1, 0], [0, 1], [1, 1], 61 | [2, 1], [1, 2], [2, 2], [3, 2], 62 | [6, 6], [7, 6], [8, 6], [7, 7], 63 | [8, 7], [9, 7], [7, 8], [8, 8], 64 | [9, 8], [8, 9], [9, 9] 65 | ] 66 | return np.array(dataSets), labels 67 | 68 | 69 | if __name__ == "__main__": 70 | # trainSet, testSet = load_iris_data('./data/iris.data', 0.66) 71 | # print(trainSet) 72 | # print("*"*100) 73 | # print(testSet) 74 | # load mnist data 75 | dataSets, labels = load_mnist_data() 76 | # print(dataSets) 77 | print(labels) 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/k-means/kMeans.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import numpy as np 3 | import random 4 | import matplotlib.pyplot as plt 5 | from data_helper import load_mnist_data, load_sample_data 6 | 7 | 8 | class KnnCluster(object): 9 | """k-means cluster.""" 10 | def __init__(self, dataSet, K, labels=None): 11 | """ 12 | :param dataSet: train data. 13 | :param K: the number of clusters. 14 | :param labels: train data labels. 15 | """ 16 | self.dataSet = dataSet 17 | self.K = K 18 | self.labels = labels 19 | 20 | def clusters(self): 21 | """ 22 | clusters . 23 | 聚类直到质心基本确定. 24 | :return: 25 | """ 26 | # init centroids 27 | self.centroidsList = self._init_centroids() 28 | 29 | clusterDict, clusterCount = self._cluster() 30 | print("current cluster dict count: ", clusterCount) 31 | newVar = self.getVar(self.centroidsList, clusterDict) 32 | 33 | oldVar = 1 34 | while abs(oldVar - newVar) >= 0.0001: 35 | self.centroidsList = self.getCentroids(clusterDict) 36 | clusterDict, clusterCount = self._cluster() 37 | print("current cluster dict count: ", clusterCount) 38 | 39 | oldVar = newVar 40 | newVar = self.getVar(self.centroidsList, clusterDict) 41 | print("var diff: ", abs(oldVar-newVar)) 42 | return self.centroidsList, clusterDict, clusterCount 43 | 44 | def _cluster(self): 45 | """ 46 | cluster for one time. 47 | 对于每个dataSet的item,计算item与centroidList中K个质心的距离, 48 | 找出最小的距离,并将item加入相应的聚类中. 49 | :return: 50 | 'clusterDict: {class1: [data1..], class2: [data2...], ...}' 51 | """ 52 | # dict 保存聚类结果 53 | clusterDict = {} 54 | 55 | # dict 保存类别数目 56 | cluster_count = {} 57 | 58 | # 将数据加到距离最近的cluster中 59 | for idx in range(self.dataSet.shape[0]): 60 | vec1 = self.dataSet[idx] 61 | minDis = float("inf") 62 | flag = -1 # 保存类别标记 63 | for i in range(self.K): 64 | vec2 = self.centroidsList[i] 65 | distance = self._calcDistance(vec1, vec2) 66 | if distance < minDis: 67 | minDis = distance 68 | flag = i 69 | if flag not in clusterDict.keys(): 70 | clusterDict[flag] = [] 71 | clusterDict[flag].append(vec1) 72 | 73 | # 记录这个cluster中的类别数目 74 | if self.labels is not None: 75 | if flag not in cluster_count.keys(): 76 | cluster_count[flag] = {} 77 | label = int(self.labels[idx]) 78 | if label not in cluster_count[flag].keys(): 79 | cluster_count[flag][label] = 1 80 | else: 81 | cluster_count[flag][label] += 1 82 | return clusterDict, cluster_count 83 | 84 | def getCentroids(self, clusterDict): 85 | """ 86 | 重新计算k个质心. 87 | :param clusterDict: 88 | :return: 89 | """ 90 | centroidList = [] 91 | for key in clusterDict.keys(): 92 | centroids = np.mean(clusterDict[key], axis=0) 93 | centroidList.append(centroids) 94 | return centroidList 95 | 96 | def getVar(self, centroidList, clusterDict): 97 | """ 98 | 计算各族集合间的均方误差. 99 | :param centroidList: 100 | :param clusterDict: 101 | :return: 102 | """ 103 | sum = 0.0 104 | for key in clusterDict.keys(): 105 | vec1 = centroidList[key] 106 | distance = 0.0 107 | for item in clusterDict[key]: 108 | vec2 = item 109 | distance += self._calcDistance(vec1, vec2) 110 | sum += distance / len(clusterDict[key]) 111 | return sum / self.K 112 | 113 | def _init_centroids(self): 114 | """ 115 | 随机选择k个中心点 116 | :return: 117 | """ 118 | dataSet = list(self.dataSet) 119 | return random.sample(dataSet, self.K) 120 | 121 | def _calcDistance(self, vec1, vec2): 122 | """ 123 | 计算欧式距离. 124 | :param vec1: 125 | :param vec2: 126 | :return: 127 | """ 128 | return np.linalg.norm(vec1 - vec2) 129 | 130 | def showCluster(self, centroidList, clusterDict): 131 | """ 132 | 展示聚类结果.(仅针对二维度数据) 133 | :param centroidList: 134 | :param clusterDict: 135 | :return: 136 | """ 137 | print("centroidList: ", centroidsList) 138 | colorMark = ['or', 'ob', 'og', 'ok', 'oy', 'ow'] # 不同簇类标记,o表示圆形,另一个表示颜色 139 | centroidMark = ['dr', 'db', 'dg', 'dk', 'dy', 'dw'] 140 | 141 | # plot the cluster result 142 | for key in clusterDict.keys(): 143 | plt.plot(centroidList[key][0], centroidList[key][1], centroidMark[key], markersize=12) # 质心点 144 | for item in clusterDict[key]: 145 | plt.plot(item[0], item[1], colorMark[key]) 146 | plt.show() 147 | 148 | 149 | if __name__ == "__main__": 150 | dataSets, labels = load_mnist_data() 151 | # dataSets, labels = load_sample_data() 152 | knn_cluster = KnnCluster(dataSets, K=10, labels=labels) 153 | centroidsList, clusterDict, clusterCount = knn_cluster.clusters() 154 | # print(centroidsList) 155 | # print(clusterDict) 156 | print("cluster dict count: ") 157 | for k, v in clusterDict.items(): 158 | print("class {}: {}".format(k, len(v))) 159 | print("final clustering result count(detail): ") 160 | print(clusterCount) 161 | # knn_cluster.showCluster(centroidsList, clusterDict) 162 | -------------------------------------------------------------------------------- /src/k-means/pictures/mnist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/k-means/pictures/mnist.png -------------------------------------------------------------------------------- /src/k-means/pictures/sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/k-means/pictures/sample.png -------------------------------------------------------------------------------- /src/k-means/readme.md: -------------------------------------------------------------------------------- 1 | # K-Means 聚类算法 2 | 使用K-Means聚类算法对Sample Data和手写数字识别进行K均值聚类 3 | 4 | 5 | ## result 6 | 1. 在SampleData上表现良好,聚类结果图如下: 7 | 8 | ![sample data cluster result](/src/k-means/pictures/sample.png) 9 | 10 | 11 | 2. 在mnist上表现一般,聚类结果如下图: 12 | 13 | ![mnist data cluster result](/src/k-means/pictures/mnist.png) -------------------------------------------------------------------------------- /src/knn/data/iris.data: -------------------------------------------------------------------------------- 1 | 5.1,3.5,1.4,0.2,Iris-setosa 2 | 4.9,3.0,1.4,0.2,Iris-setosa 3 | 4.7,3.2,1.3,0.2,Iris-setosa 4 | 4.6,3.1,1.5,0.2,Iris-setosa 5 | 5.0,3.6,1.4,0.2,Iris-setosa 6 | 5.4,3.9,1.7,0.4,Iris-setosa 7 | 4.6,3.4,1.4,0.3,Iris-setosa 8 | 5.0,3.4,1.5,0.2,Iris-setosa 9 | 4.4,2.9,1.4,0.2,Iris-setosa 10 | 4.9,3.1,1.5,0.1,Iris-setosa 11 | 5.4,3.7,1.5,0.2,Iris-setosa 12 | 4.8,3.4,1.6,0.2,Iris-setosa 13 | 4.8,3.0,1.4,0.1,Iris-setosa 14 | 4.3,3.0,1.1,0.1,Iris-setosa 15 | 5.8,4.0,1.2,0.2,Iris-setosa 16 | 5.7,4.4,1.5,0.4,Iris-setosa 17 | 5.4,3.9,1.3,0.4,Iris-setosa 18 | 5.1,3.5,1.4,0.3,Iris-setosa 19 | 5.7,3.8,1.7,0.3,Iris-setosa 20 | 5.1,3.8,1.5,0.3,Iris-setosa 21 | 5.4,3.4,1.7,0.2,Iris-setosa 22 | 5.1,3.7,1.5,0.4,Iris-setosa 23 | 4.6,3.6,1.0,0.2,Iris-setosa 24 | 5.1,3.3,1.7,0.5,Iris-setosa 25 | 4.8,3.4,1.9,0.2,Iris-setosa 26 | 5.0,3.0,1.6,0.2,Iris-setosa 27 | 5.0,3.4,1.6,0.4,Iris-setosa 28 | 5.2,3.5,1.5,0.2,Iris-setosa 29 | 5.2,3.4,1.4,0.2,Iris-setosa 30 | 4.7,3.2,1.6,0.2,Iris-setosa 31 | 4.8,3.1,1.6,0.2,Iris-setosa 32 | 5.4,3.4,1.5,0.4,Iris-setosa 33 | 5.2,4.1,1.5,0.1,Iris-setosa 34 | 5.5,4.2,1.4,0.2,Iris-setosa 35 | 4.9,3.1,1.5,0.1,Iris-setosa 36 | 5.0,3.2,1.2,0.2,Iris-setosa 37 | 5.5,3.5,1.3,0.2,Iris-setosa 38 | 4.9,3.1,1.5,0.1,Iris-setosa 39 | 4.4,3.0,1.3,0.2,Iris-setosa 40 | 5.1,3.4,1.5,0.2,Iris-setosa 41 | 5.0,3.5,1.3,0.3,Iris-setosa 42 | 4.5,2.3,1.3,0.3,Iris-setosa 43 | 4.4,3.2,1.3,0.2,Iris-setosa 44 | 5.0,3.5,1.6,0.6,Iris-setosa 45 | 5.1,3.8,1.9,0.4,Iris-setosa 46 | 4.8,3.0,1.4,0.3,Iris-setosa 47 | 5.1,3.8,1.6,0.2,Iris-setosa 48 | 4.6,3.2,1.4,0.2,Iris-setosa 49 | 5.3,3.7,1.5,0.2,Iris-setosa 50 | 5.0,3.3,1.4,0.2,Iris-setosa 51 | 7.0,3.2,4.7,1.4,Iris-versicolor 52 | 6.4,3.2,4.5,1.5,Iris-versicolor 53 | 6.9,3.1,4.9,1.5,Iris-versicolor 54 | 5.5,2.3,4.0,1.3,Iris-versicolor 55 | 6.5,2.8,4.6,1.5,Iris-versicolor 56 | 5.7,2.8,4.5,1.3,Iris-versicolor 57 | 6.3,3.3,4.7,1.6,Iris-versicolor 58 | 4.9,2.4,3.3,1.0,Iris-versicolor 59 | 6.6,2.9,4.6,1.3,Iris-versicolor 60 | 5.2,2.7,3.9,1.4,Iris-versicolor 61 | 5.0,2.0,3.5,1.0,Iris-versicolor 62 | 5.9,3.0,4.2,1.5,Iris-versicolor 63 | 6.0,2.2,4.0,1.0,Iris-versicolor 64 | 6.1,2.9,4.7,1.4,Iris-versicolor 65 | 5.6,2.9,3.6,1.3,Iris-versicolor 66 | 6.7,3.1,4.4,1.4,Iris-versicolor 67 | 5.6,3.0,4.5,1.5,Iris-versicolor 68 | 5.8,2.7,4.1,1.0,Iris-versicolor 69 | 6.2,2.2,4.5,1.5,Iris-versicolor 70 | 5.6,2.5,3.9,1.1,Iris-versicolor 71 | 5.9,3.2,4.8,1.8,Iris-versicolor 72 | 6.1,2.8,4.0,1.3,Iris-versicolor 73 | 6.3,2.5,4.9,1.5,Iris-versicolor 74 | 6.1,2.8,4.7,1.2,Iris-versicolor 75 | 6.4,2.9,4.3,1.3,Iris-versicolor 76 | 6.6,3.0,4.4,1.4,Iris-versicolor 77 | 6.8,2.8,4.8,1.4,Iris-versicolor 78 | 6.7,3.0,5.0,1.7,Iris-versicolor 79 | 6.0,2.9,4.5,1.5,Iris-versicolor 80 | 5.7,2.6,3.5,1.0,Iris-versicolor 81 | 5.5,2.4,3.8,1.1,Iris-versicolor 82 | 5.5,2.4,3.7,1.0,Iris-versicolor 83 | 5.8,2.7,3.9,1.2,Iris-versicolor 84 | 6.0,2.7,5.1,1.6,Iris-versicolor 85 | 5.4,3.0,4.5,1.5,Iris-versicolor 86 | 6.0,3.4,4.5,1.6,Iris-versicolor 87 | 6.7,3.1,4.7,1.5,Iris-versicolor 88 | 6.3,2.3,4.4,1.3,Iris-versicolor 89 | 5.6,3.0,4.1,1.3,Iris-versicolor 90 | 5.5,2.5,4.0,1.3,Iris-versicolor 91 | 5.5,2.6,4.4,1.2,Iris-versicolor 92 | 6.1,3.0,4.6,1.4,Iris-versicolor 93 | 5.8,2.6,4.0,1.2,Iris-versicolor 94 | 5.0,2.3,3.3,1.0,Iris-versicolor 95 | 5.6,2.7,4.2,1.3,Iris-versicolor 96 | 5.7,3.0,4.2,1.2,Iris-versicolor 97 | 5.7,2.9,4.2,1.3,Iris-versicolor 98 | 6.2,2.9,4.3,1.3,Iris-versicolor 99 | 5.1,2.5,3.0,1.1,Iris-versicolor 100 | 5.7,2.8,4.1,1.3,Iris-versicolor 101 | 6.3,3.3,6.0,2.5,Iris-virginica 102 | 5.8,2.7,5.1,1.9,Iris-virginica 103 | 7.1,3.0,5.9,2.1,Iris-virginica 104 | 6.3,2.9,5.6,1.8,Iris-virginica 105 | 6.5,3.0,5.8,2.2,Iris-virginica 106 | 7.6,3.0,6.6,2.1,Iris-virginica 107 | 4.9,2.5,4.5,1.7,Iris-virginica 108 | 7.3,2.9,6.3,1.8,Iris-virginica 109 | 6.7,2.5,5.8,1.8,Iris-virginica 110 | 7.2,3.6,6.1,2.5,Iris-virginica 111 | 6.5,3.2,5.1,2.0,Iris-virginica 112 | 6.4,2.7,5.3,1.9,Iris-virginica 113 | 6.8,3.0,5.5,2.1,Iris-virginica 114 | 5.7,2.5,5.0,2.0,Iris-virginica 115 | 5.8,2.8,5.1,2.4,Iris-virginica 116 | 6.4,3.2,5.3,2.3,Iris-virginica 117 | 6.5,3.0,5.5,1.8,Iris-virginica 118 | 7.7,3.8,6.7,2.2,Iris-virginica 119 | 7.7,2.6,6.9,2.3,Iris-virginica 120 | 6.0,2.2,5.0,1.5,Iris-virginica 121 | 6.9,3.2,5.7,2.3,Iris-virginica 122 | 5.6,2.8,4.9,2.0,Iris-virginica 123 | 7.7,2.8,6.7,2.0,Iris-virginica 124 | 6.3,2.7,4.9,1.8,Iris-virginica 125 | 6.7,3.3,5.7,2.1,Iris-virginica 126 | 7.2,3.2,6.0,1.8,Iris-virginica 127 | 6.2,2.8,4.8,1.8,Iris-virginica 128 | 6.1,3.0,4.9,1.8,Iris-virginica 129 | 6.4,2.8,5.6,2.1,Iris-virginica 130 | 7.2,3.0,5.8,1.6,Iris-virginica 131 | 7.4,2.8,6.1,1.9,Iris-virginica 132 | 7.9,3.8,6.4,2.0,Iris-virginica 133 | 6.4,2.8,5.6,2.2,Iris-virginica 134 | 6.3,2.8,5.1,1.5,Iris-virginica 135 | 6.1,2.6,5.6,1.4,Iris-virginica 136 | 7.7,3.0,6.1,2.3,Iris-virginica 137 | 6.3,3.4,5.6,2.4,Iris-virginica 138 | 6.4,3.1,5.5,1.8,Iris-virginica 139 | 6.0,3.0,4.8,1.8,Iris-virginica 140 | 6.9,3.1,5.4,2.1,Iris-virginica 141 | 6.7,3.1,5.6,2.4,Iris-virginica 142 | 6.9,3.1,5.1,2.3,Iris-virginica 143 | 5.8,2.7,5.1,1.9,Iris-virginica 144 | 6.8,3.2,5.9,2.3,Iris-virginica 145 | 6.7,3.3,5.7,2.5,Iris-virginica 146 | 6.7,3.0,5.2,2.3,Iris-virginica 147 | 6.3,2.5,5.0,1.9,Iris-virginica 148 | 6.5,3.0,5.2,2.0,Iris-virginica 149 | 6.2,3.4,5.4,2.3,Iris-virginica 150 | 5.9,3.0,5.1,1.8,Iris-virginica -------------------------------------------------------------------------------- /src/knn/data_helper.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import csv 3 | import random 4 | import numpy as np 5 | 6 | 7 | def load_iris_data(filename, split): 8 | """ 9 | load iris data, and split the training and test set. 10 | :param filename: the data path 11 | :param split: split rate 12 | :return: 13 | 'trainSet': 14 | 'testSet': 15 | """ 16 | trainSet = [] 17 | testSet = [] 18 | with open(filename, 'r') as csvfile: 19 | lines = csv.reader(csvfile) 20 | dataSet = list(lines) 21 | for x in range(len(dataSet)): 22 | for y in range(4): 23 | dataSet[x][y] = float(dataSet[x][y]) 24 | if random.random() < split: 25 | trainSet.append(dataSet[x]) 26 | else: 27 | testSet.append(dataSet[x]) 28 | return trainSet, testSet 29 | 30 | 31 | def load_mnist_data(filename='./data/ClusterSamples.csv', 32 | label_filename='./data/SampleLabels.csv'): 33 | """ 34 | load mnist data 35 | :param filename: 36 | :param label_filename: 37 | :return: 38 | """ 39 | 40 | with open(filename, 'r') as csvfile: 41 | lines = csv.reader(csvfile) 42 | dataSet = list(lines) 43 | 44 | with open(label_filename, 'r') as f: 45 | lines = csv.reader(f) 46 | training_data_label = list(lines) 47 | 48 | # transfer label to 1 dim, char to num 49 | training_data_label = [int(la[0]) for la in training_data_label] 50 | return np.array(dataSet, dtype='float64'), np.array(training_data_label) 51 | 52 | 53 | def load_sample_data(): 54 | """ 55 | the sample data is to test the model if right. 56 | :return: 57 | """ 58 | labels = None 59 | dataSets = [ 60 | [0, 0], [1, 0], [0, 1], [1, 1], 61 | [2, 1], [1, 2], [2, 2], [3, 2], 62 | [6, 6], [7, 6], [8, 6], [7, 7], 63 | [8, 7], [9, 7], [7, 8], [8, 8], 64 | [9, 8], [8, 9], [9, 9] 65 | ] 66 | return np.array(dataSets), labels 67 | 68 | 69 | if __name__ == "__main__": 70 | # trainSet, testSet = load_iris_data('./data/iris.data', 0.66) 71 | # print(trainSet) 72 | # print("*"*100) 73 | # print(testSet) 74 | # load mnist data 75 | dataSets, labels = load_mnist_data() 76 | # print(dataSets) 77 | print(labels) 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/knn/filels/myplot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/knn/filels/myplot.jpg -------------------------------------------------------------------------------- /src/knn/knn.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import absolute_import 3 | import math 4 | import operator 5 | from data_helper import load_iris_data 6 | 7 | 8 | class KnnClassifier(object): 9 | """K-nearest neighbor classifier algorithm.""" 10 | def __init__(self, training_data, k): 11 | """ 12 | :param training_data: training data, the last dim is label. 13 | :param k: k value. 14 | """ 15 | self.training_data = training_data 16 | self.k = k 17 | 18 | def predict(self, sample): 19 | pass 20 | 21 | def test(self, test_data): 22 | """ 23 | use the test data to test the model, return accuracy. 24 | :param test_data: a list of list data, the last dim is label. 25 | :return: 26 | """ 27 | predictions = [] 28 | for i in range(len(testSet)): 29 | neighbors = self.getNeighbors(self.training_data, testSet[i], self.k) 30 | response = self.getResponse(neighbors) 31 | predictions.append(response) 32 | accuracy = self.getAccuracy(test_data, predictions) 33 | return accuracy 34 | 35 | def getAccuracy(self, testSet, predictions): 36 | """ 37 | calc accuracy. 38 | :param testSet: 39 | :param predictions: 40 | :return: 41 | """ 42 | correct = 0 43 | for i in range(len(testSet)): 44 | if testSet[i][-1] == predictions[i]: 45 | correct += 1 46 | return (correct / float(len(testSet))) * 100 47 | 48 | def getResponse(self, neighbors): 49 | """ 50 | 基于最近的实例来预测结果. 51 | :param neighbors: 52 | :return: 53 | """ 54 | classVotes = {} 55 | for i in range(len(neighbors)): 56 | response = neighbors[i][-1] 57 | if response in classVotes: 58 | classVotes[response] += 1 59 | else: 60 | classVotes[response] = 1 61 | sortedVotes = sorted(classVotes.items(), key=operator.itemgetter(1), 62 | reverse=True) 63 | return sortedVotes[0][0] 64 | 65 | def getNeighbors(self, training_set, testInstance, k): 66 | """ 67 | get k nearest neighbors of one sample. 68 | :param training_set: train data. 69 | :param testInstance: test data. 70 | :param k: k 71 | :return: 72 | """ 73 | distances = [] 74 | length = len(testInstance) - 1 75 | for data in training_set: 76 | dist = self.euclideanDistance(data, testInstance, length) 77 | distances.append((data, dist)) 78 | distances.sort(key=operator.itemgetter(1)) 79 | neighbors = [] 80 | # k neighbors 81 | for i in range(k): 82 | neighbors.append(distances[i][0]) 83 | return neighbors 84 | 85 | def euclideanDistance(self, instance1, instance2, length): 86 | """ 87 | calc euclidean distance. 88 | :param instance1: 89 | :param instance2: 90 | :param length: dim 91 | :return: 92 | """ 93 | distance = 0 94 | for x in range(length): 95 | distance += pow((instance1[x] - instance2[x]), 2) 96 | return math.sqrt(distance) 97 | 98 | 99 | if __name__ == "__main__": 100 | print("load iris data...") 101 | trainingSet, testSet = load_iris_data('./data/iris.data', 0.66) 102 | print("load data done, training set size {}, test set size {}".format(len(trainingSet), len(testSet))) 103 | knn_classifier = KnnClassifier(trainingSet, k=3) 104 | acc = knn_classifier.test(testSet) 105 | print("accuracy: ", acc) 106 | -------------------------------------------------------------------------------- /src/knn/readme.md: -------------------------------------------------------------------------------- 1 | # K-Means cluster 2 | 使用k均值算法做聚类。 3 | 4 | ClusterSamples中的10000个784维特征手写数字样本聚类为10个类别,根据 5 | SampleLabels中的标签统计每个聚类中不同样本的数量。测试不同初始值对聚 6 | 类结果的影响。 7 | 8 | 使用k-means cluster对样本数据做聚类结果如下图所示: 9 | 10 | 11 | # knn classifier 12 | 使用k均值算法做分类。 13 | 14 | 15 | 16 | ## reference 17 | [1] [机器学习之k-means算法](https://github.com/yunshuipiao/SWBlog/blob/master/maching_learning/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E4%B9%8Bk-means%E8%81%9A%E7%B1%BB%E7%AE%97%E6%B3%95(python%E5%AE%9E%E7%8E%B0).md) 18 | 19 | [2] [【无监督学习】K-means聚类算法原理](https://blog.csdn.net/zzz_cming/article/details/79859490) 20 | -------------------------------------------------------------------------------- /src/knn/test_kMenas.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from data_helper import load_mnist_data 3 | from sklearn.cluster import KMeans 4 | import numpy as np 5 | 6 | 7 | def evaluate_cluster(labels, predict): 8 | """ 9 | calc the acc of cluster. 10 | :param labels: array like 11 | :param predict: array like 12 | :return: 13 | 'accuracy', float 14 | """ 15 | return np.sum(labels == predict) / labels.shape[0] 16 | 17 | 18 | if __name__ == "__main__": 19 | train_data, train_data_label = load_mnist_data() 20 | # k-means 21 | kmeans = KMeans(n_clusters=10, init='random') 22 | print("begin clustering.....") 23 | kmeans = kmeans.fit(train_data) 24 | print("end clustering") 25 | # get the labels 26 | predict_labels = kmeans.predict(train_data) 27 | 28 | # calc acc 29 | print("train_data_label: ", train_data_label) 30 | print("predict labels: ", predict_labels) 31 | print("acc: ", evaluate_cluster(train_data_label, predict_labels)) 32 | -------------------------------------------------------------------------------- /src/mnist_classify/GMM.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 高斯混合模型(GMM) 4 | TODO: 下溢 5 | """ 6 | import numpy as np 7 | import copy 8 | from dataHelper import load_mnist_data 9 | 10 | 11 | def gaussian(data, mean, cov): 12 | """ 13 | 计算高维高斯函数概率密度. 14 | :param data: 样本数据 15 | :param mean: 均值 16 | :param cov: 协方差 17 | :return: 18 | """ 19 | dim = np.shape(cov)[0] # 计算维度 20 | covdet = np.linalg.det(cov) # 计算|cov| 21 | covinv = np.linalg.inv(cov) # 计算cov的逆 22 | if covdet == 0: # 以防行列式为0 23 | covdet = np.linalg.det(cov+np.eye(dim)*0.01) 24 | covinv = np.linalg.inv(cov+np.eye(dim)*0.01) 25 | m = data - mean 26 | z = -0.5 * np.dot(np.dot(m, covinv), m) # 计算exp()里的值 27 | return 1.0/(np.power(np.power(2*np.pi, dim)*abs(covdet), 0.5))*np.exp(z) # 返回概率密度值1234567891011 28 | 29 | 30 | def isdistance(means, criterion=0.03): 31 | """ 32 | 用于判断初始聚类簇中的means是否距离离得比较近 33 | :param means: 初始聚类簇means集合 34 | :param criterion: 35 | :return: 36 | """ 37 | K = len(means) 38 | for i in range(K): 39 | for j in range(i+1, K): 40 | if criterion > np.linalg.norm(means[i]-means[j]): 41 | return False 42 | return True 43 | 44 | 45 | def getInitialMeans(data, K, criterion): 46 | """ 47 | 获取最初的聚类中心. 48 | :param data: 数据集合 49 | :param K: 50 | :param criterion: 51 | :return: 52 | """ 53 | dim = data.shape[1] # 数据的维度 54 | means = [[] for k in range(K)] # 存储均值 55 | minmax = [] # 存储每一维的最大最小值 56 | for i in range(dim): 57 | minmax.append(np.array([min(data[:, i]), max(data[:, i])])) 58 | minmax = np.array(minmax) 59 | 60 | # 随机产生means 61 | while True: 62 | for i in range(K): 63 | means[i] = [] 64 | for j in range(dim): 65 | means[i].append(np.random.random()*(minmax[i][1]-minmax[i][0])+minmax[i][0]) 66 | means[i] = np.array(means[i]) 67 | # judge 68 | if isdistance(means, criterion): 69 | break 70 | return means 71 | 72 | 73 | def kmeans(data, K): 74 | """ 75 | k-means cluster. 76 | 估计大约几个样本属于一个GMM. 77 | :param data: 样本数据集 78 | :param K: K个类别 79 | :return: 80 | """ 81 | N = data.shape[0] # 样本数量 82 | dim = data.shape[1] # 样本维度 83 | # 初始化聚类中心点 84 | means = getInitialMeans(data, K, 15) 85 | 86 | means_old = [np.zeros(dim) for k in range(K)] 87 | # 收敛条件 88 | while np.sum([np.linalg.norm(means_old[k] - means[k]) for k in range(K)]) > 0.01: 89 | means_old = copy.deepcopy(means) 90 | numlog = [0] * K # 存储属于某类的个数 91 | sumlog = [np.zeros(dim) for k in range(K)] # 存储属于某类的样本均值 92 | 93 | # E步 94 | for i in range(N): 95 | dislog = [np.linalg.norm(data[i]-means[k]) for k in range(K)] 96 | tok = dislog.index(np.min(dislog)) 97 | numlog[tok] += 1 # 属于该类的样本数量加1 98 | sumlog[tok] += data[i] # 存储属于该类的样本取值 99 | 100 | # M步 101 | for k in range(K): 102 | means[k] = 1.0 / (numlog[k] + 1.) * sumlog[k] 103 | return means 104 | 105 | 106 | def GMM(data, K): 107 | """ 108 | GMM Models. 109 | ------- 110 | 下面代码计算过程出现了下溢出问题! 111 | :param data: 数据集合 112 | :param K: K 113 | :return: 114 | """ 115 | N = data.shape[0] 116 | dim = data.shape[1] 117 | means = kmeans(data, K) 118 | convs = [0] * K 119 | # 初始方差等于整体data的方差 120 | for i in range(K): 121 | convs[i] = np.cov(data.T) 122 | pis = [1.0/K] * K 123 | gammas = [np.zeros(K) for i in range(N)] 124 | loglikelyhood = 0 125 | oldloglikelyhood = 1 126 | 127 | while np.abs(loglikelyhood - oldloglikelyhood) > 0.0001: 128 | oldloglikelyhood = loglikelyhood 129 | 130 | # E步 131 | for i in range(N): 132 | res = [pis[k] * gaussian(data[i], means[k], convs[k]) for k in range(K)] 133 | sumres = np.sum(res) 134 | for k in range(K): # gamma表示第n个样本属于第k个混合高斯的概率 135 | gammas[i][k] = res[k] / sumres 136 | 137 | # M步 138 | for k in range(K): 139 | Nk = np.sum([gammas[n][k] for n in range(N)]) # N[k] 表示N个样本中有多少属于第k个高斯 140 | 141 | pis[k] = 1.0 * Nk/N 142 | means[k] = (1.0/Nk) * np.sum([gammas[n][k] * data[n] for n in range(N)], axis=0) 143 | xdiffs = data - means[k] 144 | convs[k] = (1.0/Nk)*np.sum([gammas[n][k] * xdiffs[n].reshape(dim, 1) * xdiffs[n] for n in range(N)], axis=0) 145 | # 计算最大似然函数 146 | loglikelyhood = np.sum( 147 | [np.log(np.sum([pis[k] * gaussian(data[n], means[k], convs[k]) for k in range(K)])) for n in range(N)]) 148 | 149 | print("current pi: ", pis, " means: ", means, " convs: ", convs, ' loglikelyhood: ', loglikelyhood) 150 | return pis, means, convs 151 | 152 | 153 | def GMM_prob(data, pis, means, convs): 154 | """ 155 | calc the GMM prob of the sample data. 156 | :param data: 157 | :param pis: 158 | :param means: 159 | :param convs: 160 | :return: 161 | """ 162 | K = len(pis) 163 | probs = [pis[i]*gaussian(data, means[i], convs[i]) for i in range(K)] 164 | return np.sum(probs) 165 | 166 | 167 | def main(): 168 | """ 169 | GMM分类压缩后的mnist. 170 | --------- 171 | 1. 对每一个类别训练一个GMM. 172 | 2. 对于一个样本,判断这个样本属于哪个GMM的概率大就属于哪个类别. 173 | :return: 174 | """ 175 | # 设置GMM中的K值 176 | K = 10 177 | # 将数据分为C类 178 | datas = {} 179 | train_datas, train_labels = load_mnist_data(file_name='data/train_data/TrainSamples', 180 | label_filename='data/train_data/TrainLabels') 181 | for idx, j in enumerate(train_labels): 182 | if j not in datas.keys(): 183 | datas[j] = [] 184 | datas[j].append(train_datas[idx]) 185 | 186 | # train C GMM 187 | print("train C GMM....") 188 | params = {} 189 | for c in datas.keys(): 190 | pis, means, convs = GMM(np.array(datas[c], dtype='float64'), K) 191 | params[c] = (pis, means, convs) 192 | 193 | # test the test_data accuracy 194 | print("test the data acc.....") 195 | test_datas, test_labels = load_mnist_data(file_name='data/valid_data/ValidSamples', 196 | label_filename='data/valid_data/ValidLabels') 197 | count = 0 198 | for idx, test_data in enumerate(test_datas): 199 | target = test_labels[idx] 200 | max_prob = 0. 201 | max_c = 0 202 | for c in params.keys(): 203 | pis, means, convs = params[c] 204 | prob = GMM_prob(test_data, pis, means, convs) 205 | if prob > max_prob: 206 | max_prob = prob 207 | max_c = c 208 | if target == max_c: 209 | count += 1 210 | print("test accuracy is:{} / {} = {} ".format(count, len(test_datas), count / (len(test_datas) + 0.))) 211 | 212 | 213 | if __name__ == "__main__": 214 | main() 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | -------------------------------------------------------------------------------- /src/mnist_classify/KNN.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # coding:utf-8 3 | 4 | """ 5 | 使用KNN来对MNIST数据进行分类 6 | @author: yyhaker 7 | @contact: 572176750@qq.com 8 | @file: SVM.py 9 | @time: 2018/11/25 16:09 10 | """ 11 | import numpy as np 12 | from sklearn.preprocessing import StandardScaler 13 | from sklearn import metrics 14 | from sklearn.neighbors import KNeighborsClassifier 15 | from dataHelper import load_mnist_data 16 | 17 | 18 | def main(): 19 | # load train data and test data 20 | print("loading data...") 21 | train_datas, train_labels = load_mnist_data(file_name='data/train_data/TrainSamples', 22 | label_filename='data/train_data/TrainLabels') 23 | test_datas, test_labels = load_mnist_data(file_name='data/valid_data/ValidSamples', 24 | label_filename='data/valid_data/ValidLabels') 25 | print("Train data size: {}, Test data size: {}".format(len(train_datas), len(test_datas))) 26 | 27 | # 对训练和测试的特征数据进行标准化 28 | # ss = StandardScaler() 29 | # train_datas = ss.fit_transform(train_datas) 30 | # test_datas = ss.transform(test_datas) 31 | 32 | # create models and train 33 | print("training the model....") 34 | clf = KNeighborsClassifier(n_neighbors=5) 35 | clf.fit(train_datas, train_labels) 36 | print("training is done!") 37 | print("fit result: ", clf.score(train_datas, train_labels)) 38 | # test on the test data 39 | acc = clf.score(test_datas, test_labels) 40 | print("test acc: ", acc) 41 | predict = clf.predict(test_datas) 42 | print("Classification report:\n ", metrics.classification_report(test_labels, predict)) 43 | print("Confusion matrix:\n ", metrics.confusion_matrix(test_labels, predict)) 44 | 45 | 46 | if __name__ == "__main__": 47 | main() 48 | -------------------------------------------------------------------------------- /src/mnist_classify/NB.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # coding:utf-8 3 | 4 | """ 5 | 使用Naive Bayes来对MNIST数据进行分类 6 | @author: yyhaker 7 | @contact: 572176750@qq.com 8 | @file: SVM.py 9 | @time: 2018/11/25 16:09 10 | """ 11 | import numpy as np 12 | from sklearn.preprocessing import StandardScaler 13 | from sklearn import metrics 14 | from sklearn import naive_bayes 15 | from dataHelper import load_mnist_data 16 | 17 | 18 | def main(): 19 | # load train data and test data 20 | print("loading data...") 21 | train_datas, train_labels = load_mnist_data(file_name='data/train_data/TrainSamples', 22 | label_filename='data/train_data/TrainLabels') 23 | test_datas, test_labels = load_mnist_data(file_name='data/valid_data/ValidSamples', 24 | label_filename='data/valid_data/ValidLabels') 25 | print("Train data size: {}, Test data size: {}".format(len(train_datas), len(test_datas))) 26 | 27 | # 对训练和测试的特征数据进行标准化 28 | # ss = StandardScaler() 29 | # train_datas = ss.fit_transform(train_datas) 30 | # test_datas = ss.transform(test_datas) 31 | 32 | # create models and train 33 | print("training the model....") 34 | clf = naive_bayes.GaussianNB() 35 | clf.fit(train_datas, train_labels) 36 | print("training is done!") 37 | print("fit result: ", clf.score(train_datas, train_labels)) 38 | # test on the test data 39 | acc = clf.score(test_datas, test_labels) 40 | print("test acc: ", acc) 41 | predict = clf.predict(test_datas) 42 | print("Classification report:\n ", metrics.classification_report(test_labels, predict)) 43 | print("Confusion matrix:\n ", metrics.confusion_matrix(test_labels, predict)) 44 | 45 | 46 | if __name__ == "__main__": 47 | main() 48 | -------------------------------------------------------------------------------- /src/mnist_classify/SVM.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # coding:utf-8 3 | 4 | """ 5 | 使用SVM来对MNIST数据进行分类 6 | @author: yyhaker 7 | @contact: 572176750@qq.com 8 | @file: SVM.py 9 | @time: 2018/11/25 16:09 10 | """ 11 | import numpy as np 12 | from sklearn import svm, metrics 13 | from sklearn.multiclass import OneVsRestClassifier 14 | from sklearn.preprocessing import StandardScaler 15 | from dataHelper import load_mnist_data 16 | 17 | 18 | def main(): 19 | # load train data and test data 20 | print("loading data...") 21 | train_datas, train_labels = load_mnist_data(file_name='data/train_data/TrainSamples', 22 | label_filename='data/train_data/TrainLabels') 23 | test_datas, test_labels = load_mnist_data(file_name='data/valid_data/ValidSamples', 24 | label_filename='data/valid_data/ValidLabels') 25 | print("Train data size: {}, Test data size: {}".format(len(train_datas), len(test_datas))) 26 | 27 | # 对训练和测试的特征数据进行标准化 28 | ss = StandardScaler() 29 | train_datas = ss.fit_transform(train_datas) 30 | test_datas = ss.transform(test_datas) 31 | 32 | # create models and train 33 | print("training the model....") 34 | clf = OneVsRestClassifier(estimator=svm.SVC(C=10, kernel='rbf', gamma='auto'), n_jobs=4) 35 | clf.fit(train_datas, train_labels) 36 | print("training is done!") 37 | print("fit result: ", clf.score(train_datas, train_labels)) 38 | # test on the test data 39 | acc = clf.score(test_datas, test_labels) 40 | print("test acc: ", acc) 41 | predict = clf.predict(test_datas) 42 | print("Classification report:\n ", metrics.classification_report(test_labels, predict)) 43 | print("Confusion matrix:\n ", metrics.confusion_matrix(test_labels, predict)) 44 | 45 | 46 | if __name__ == "__main__": 47 | main() 48 | 49 | -------------------------------------------------------------------------------- /src/mnist_classify/best_result/DNN+BN0.992/acc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/mnist_classify/best_result/DNN+BN0.992/acc.png -------------------------------------------------------------------------------- /src/mnist_classify/best_result/DNN+BN0.992/best_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/mnist_classify/best_result/DNN+BN0.992/best_model.pkl -------------------------------------------------------------------------------- /src/mnist_classify/best_result/DNN+BN0.992/loss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/mnist_classify/best_result/DNN+BN0.992/loss.png -------------------------------------------------------------------------------- /src/mnist_classify/dataHelper.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # coding:utf-8 3 | 4 | """ 5 | @author: yyhaker 6 | @contact: 572176750@qq.com 7 | @file: dataHelper.py 8 | @time: 2018/10/16 09:01 9 | """ 10 | import numpy as np 11 | import csv 12 | import torch 13 | from torch.utils.data import Dataset 14 | import matplotlib.pyplot as plt 15 | 16 | from myutils import write_to_csv 17 | 18 | 19 | class MnistDataSet(Dataset): 20 | """ 21 | MNIST dataset. 22 | """ 23 | def __init__(self, file_name='./data/TrainSamples.csv', 24 | label_filename='./data/TrainLabels.csv', 25 | data_type="train"): 26 | """ 27 | :param file_name: data files. 28 | :param label_filename: label files. 29 | :param data_type: "train", "valid" or "test". 30 | """ 31 | self.file_name = file_name 32 | self.label_filename = label_filename 33 | self.data_type = data_type 34 | 35 | if data_type == "train": 36 | self.train_datas, self.train_labels = self._load_datas() 37 | elif data_type == "valid": 38 | self.valid_datas, self.valid_labels = self._load_datas() 39 | elif data_type == "test": 40 | self.test_datas = self._load_test_datas() 41 | else: 42 | raise Exception("data type error") 43 | 44 | def __getitem__(self, idx): 45 | """通过idx索引到数据""" 46 | sample = {} 47 | if self.data_type == "train": 48 | data = torch.Tensor(self.train_datas[idx]) 49 | label = torch.LongTensor([self.train_labels[idx]]) 50 | sample = {"data": data, "label": label} 51 | elif self.data_type == "valid": 52 | data = torch.Tensor(self.valid_datas[idx]) 53 | label = torch.LongTensor([self.valid_labels[idx]]) 54 | sample = {"data": data, "label": label} 55 | elif self.data_type == "test": 56 | data = torch.Tensor(self.test_datas[idx]) 57 | sample = {"data": data} 58 | else: 59 | raise Exception("data type error") 60 | return sample 61 | 62 | def __len__(self): 63 | if self.data_type == "train": 64 | return len(self.train_datas) 65 | elif self.data_type == "valid": 66 | return len(self.valid_datas) 67 | elif self.data_type == "test": 68 | return len(self.test_datas) 69 | else: 70 | raise Exception("data type error") 71 | 72 | def _load_datas(self): 73 | """ 74 | load Train or valid datas. 75 | :return: 76 | """ 77 | with open(self.file_name, 'r') as csvfile: 78 | lines = csv.reader(csvfile) 79 | dataSet = list(lines) 80 | 81 | with open(self.label_filename, 'r') as f: 82 | lines = csv.reader(f) 83 | training_data_label = list(lines) 84 | 85 | # transfer label to 1 dim, char to num 86 | training_data_label = [int(la[0]) for la in training_data_label] 87 | 88 | # to numpy array 89 | datas, labels = np.array(dataSet, dtype='float64'), np.array(training_data_label) 90 | 91 | return datas, labels 92 | 93 | def _load_test_datas(self): 94 | with open(self.file_name, 'r') as csvfile: 95 | lines = csv.reader(csvfile) 96 | dataSet = list(lines) 97 | 98 | datas = np.array(dataSet, dtype='float64') 99 | # print("test data shape: ", datas.shape) 100 | return datas 101 | 102 | 103 | # some other functions. 104 | def load_mnist_data(file_name='./data/TrainSamples.csv', 105 | label_filename='./data/TrainLabels.csv', 106 | split_rate=None, shuffle=False): 107 | """ 108 | load mnist data. (support split automaticly) 109 | --------- 110 | data: numpy array [81, ]. 111 | label: int. 112 | :param file_name: data file name. 113 | :param label_filename: label file name. 114 | :return: 115 | """ 116 | with open(file_name, 'r') as csvfile: 117 | lines = csv.reader(csvfile) 118 | dataSet = list(lines) 119 | 120 | with open(label_filename, 'r') as f: 121 | lines = csv.reader(f) 122 | training_data_label = list(lines) 123 | 124 | # transfer label to 1 dim, char to num 125 | training_data_label = [int(la[0]) for la in training_data_label] 126 | 127 | # to numpy array 128 | datas, labels = np.array(dataSet, dtype='float64'), np.array(training_data_label) 129 | 130 | if split_rate is None: 131 | return datas, labels 132 | else: 133 | train_datas, train_labels, valid_datas, valid_labels = \ 134 | _split_datas(datas, labels, split_rate, shuffle=shuffle) 135 | write_to_csv(train_datas, 'data/train_data/TrainSamples') 136 | write_to_csv(train_labels, 'data/train_data/TrainLabels') 137 | write_to_csv(valid_datas, 'data/valid_data/ValidSamples') 138 | write_to_csv(valid_labels, 'data/valid_data/ValidLabels') 139 | return train_datas, train_labels, valid_datas, valid_labels 140 | 141 | 142 | def _split_datas(datas, labels, split_rate, shuffle=True): 143 | """ 144 | split the datas and labels. 145 | :param datas: 146 | :param labels: 147 | :param split_rate: 148 | :param shuffle: 149 | :return: 150 | """ 151 | assert len(datas) == len(labels), "the data length is not the same...." 152 | datas_labels = [(datas[i], labels[i]) for i in range(len(datas))] 153 | if shuffle: 154 | np.random.shuffle(datas_labels) 155 | split_num = int(len(datas)*split_rate) 156 | train_datas_labels = datas_labels[: split_num] 157 | valid_datas_labels = datas_labels[split_num:] 158 | 159 | train_datas, train_labels = [datas_labels[0] for datas_labels in 160 | train_datas_labels], [datas_labels[1] for datas_labels in train_datas_labels] 161 | valid_datas, valid_labels = [datas_labels[0] for datas_labels in 162 | valid_datas_labels], [datas_labels[1] for datas_labels in valid_datas_labels] 163 | return np.array(train_datas, dtype='float64'), np.array(train_labels), \ 164 | np.array(valid_datas, dtype='float64'), np.array(valid_labels) 165 | 166 | 167 | if __name__ == "__main__": 168 | # 加载并划分数据 169 | train_datas, train_labels, valid_datas, valid_labels = load_mnist_data() 170 | print("train data size: ", len(train_datas)) 171 | print("len(train_labels: )", len(train_labels), train_labels) 172 | print("-"*100) 173 | print("valid data size: ", len(valid_datas)) 174 | print("len(valid_lables: )", len(valid_labels), valid_labels) 175 | 176 | # show sample 177 | print("len(data)", len(train_datas[0])) 178 | train_image = train_datas[5].reshape(9, -1) 179 | plt.imshow(train_image, cmap='gray') 180 | plt.show() 181 | 182 | 183 | -------------------------------------------------------------------------------- /src/mnist_classify/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # coding:utf-8 3 | 4 | """ 5 | @author: yyhaker 6 | @contact: 572176750@qq.com 7 | @file: main.py 8 | @time: 2018/10/16 18:58 9 | """ 10 | import torch 11 | import torch.nn as nn 12 | from torch.autograd import Variable 13 | from torch.utils.data import Dataset 14 | from torch.utils.data import DataLoader 15 | import numpy as np 16 | import argparse 17 | 18 | from dataHelper import load_mnist_data, MnistDataSet 19 | from models import MultiLayersNetwork 20 | from myutils import write_data_to_file, write_to_csv, calc_acc 21 | 22 | device = torch.device("cuda: 0" if torch.cuda.is_available() else "cpu") 23 | 24 | 25 | def train(train_dataloaders, model, criterion, optimizer, epoch): 26 | """ 27 | train the model for one epoch! 28 | :param train_dataloaders: 29 | :param model: 30 | :param criterion: 31 | :param optimizer: 32 | :param epoch: 33 | :return: 34 | """ 35 | train_loss = [] 36 | train_acc = [] 37 | model.train() 38 | for i, sample in enumerate(train_dataloaders): 39 | input = Variable(sample['data']).to(device) 40 | target = Variable(sample['label']).view(-1).to(device) 41 | 42 | # print("target size: ", target.size()) 43 | # compute output 44 | output = model(input) 45 | loss = criterion(output, target) 46 | acc = accuracy(output, target) 47 | 48 | # compute gradient and SGD step 49 | optimizer.zero_grad() 50 | loss.backward() 51 | optimizer.step() 52 | 53 | train_loss.append(loss.item()) 54 | train_acc.append(acc) 55 | 56 | if i % 10000 == 0: 57 | print("epoch: {}, iteration: {}, loss: {}, acc: {}".format(epoch, i, loss, acc)) 58 | return np.mean(train_loss), np.mean(train_acc) 59 | 60 | 61 | def evaluate(valid_dataloaders, model, criterion, epoch): 62 | valid_loss = [] 63 | valid_acc = [] 64 | model.eval() 65 | for i, sample in enumerate(valid_dataloaders): 66 | input = Variable(sample['data']).to(device) 67 | target = Variable(sample['label']).view(-1).to(device) 68 | 69 | # compute output 70 | output = model(input) 71 | loss = criterion(output, target) 72 | acc = accuracy(output, target) 73 | 74 | valid_loss.append(loss.item()) 75 | valid_acc.append(acc) 76 | return np.mean(valid_loss), np.mean(valid_acc) 77 | 78 | 79 | def accuracy(output, target): 80 | """Compute the accuracy. 81 | :param output: [b, c] 82 | :param target: [b] 83 | :return: 84 | """ 85 | with torch.no_grad(): 86 | batch_size = target.size(0) 87 | pred = torch.argmax(output, 1) 88 | correct = pred.eq(target) 89 | acc = correct.view(-1).float().sum() / batch_size 90 | return acc 91 | 92 | 93 | def main(args): 94 | # load data 95 | print("loading datas......") 96 | train_datas = MnistDataSet(file_name=args.trainSamples, label_filename=args.trainLabels, data_type="train") 97 | valid_datas = MnistDataSet(file_name=args.validSamples, label_filename=args.validLabels, data_type="valid") 98 | train_dataloaders = DataLoader(train_datas, batch_size=args.batch_size, shuffle=True) 99 | valid_dataloaders = DataLoader(valid_datas, batch_size=args.batch_size, shuffle=True) 100 | print("train data size: ", len(train_datas)) 101 | print("valid data size: ", len(valid_datas)) 102 | 103 | # create models 104 | print("create models....") 105 | model = nn.Sequential( 106 | nn.Linear(81, 800), 107 | nn.BatchNorm1d(800), 108 | nn.Dropout(p=args.drop_out), 109 | nn.ReLU(), 110 | nn.Linear(800, 500), 111 | nn.BatchNorm1d(500), 112 | nn.Dropout(p=args.drop_out), 113 | nn.ReLU(), 114 | nn.Linear(500, 200), 115 | nn.BatchNorm1d(200), 116 | nn.Dropout(p=args.drop_out), 117 | nn.ReLU(), 118 | nn.Linear(200, 10) 119 | ) 120 | # model = MultiLayersNetwork(81, 100, 60, 10) 121 | print(model) 122 | model.to(device) 123 | 124 | # define loss function 125 | criterion = nn.CrossEntropyLoss() 126 | 127 | # optimizer 128 | if args.optim == "momentum": 129 | optimizer = torch.optim.SGD(model.parameters(), args.lr, 130 | momentum=args.momentum, 131 | weight_decay=args.weight_decay) 132 | elif args.optim == "adam": 133 | optimizer = torch.optim.Adam(model.parameters(), args.lr, 134 | weight_decay=args.weight_decay) 135 | elif args.optim == "adadelta": 136 | optimizer = torch.optim.Adadelta(model.parameters(), args.lr, 137 | weight_decay=args.weight_decay) 138 | 139 | # begin train 140 | # data to plot 141 | loss_dict = {"train_loss": [], "valid_loss": []} 142 | acc_dict = {"train_acc": [], "valid_acc": []} 143 | best_train_acc, best_valid_acc = 0., 0. 144 | for epoch in range(args.epochs): 145 | # train for one epoch 146 | train_loss, train_acc = train(train_dataloaders, model, criterion, optimizer, epoch) 147 | print("Epoch: {} done, loss: {}, train acc: {}".format(epoch, train_loss, train_acc)) 148 | # valid for one epoch 149 | valid_loss, valid_acc = evaluate(valid_dataloaders, model, criterion, epoch) 150 | print("valid the model: loss: {}, valid acc: {}".format(valid_loss, valid_acc)) 151 | 152 | # save data to plot 153 | loss_dict["train_loss"].append(train_loss) 154 | loss_dict["valid_loss"].append(valid_loss) 155 | acc_dict["train_acc"].append(train_acc) 156 | acc_dict["valid_acc"].append(valid_acc) 157 | 158 | # save current best model(s.t. valid acc) 159 | if best_valid_acc < valid_acc: 160 | best_valid_acc = valid_acc 161 | best_train_acc = train_acc 162 | torch.save(model.state_dict(), args.model_path) 163 | # train done 164 | print("train is done!") 165 | print("for the best model, train acc is: {}, valid acc is: {}".format(best_train_acc, best_valid_acc)) 166 | # write data to file 167 | write_data_to_file(loss_dict, "result/loss_dict.pkl") 168 | write_data_to_file(acc_dict, "result/acc_dict.pkl") 169 | 170 | 171 | def predict(args): 172 | # load test data 173 | print("load test data....") 174 | test_datas = MnistDataSet(file_name='./data/test_data/TestSamples.csv', 175 | data_type="test") 176 | test_dataloader = DataLoader(test_datas, batch_size=1) 177 | print("training data size: ", len(test_datas)) 178 | 179 | # load model 180 | print("loading models....") 181 | model = nn.Sequential( 182 | nn.Linear(81, 500), 183 | nn.BatchNorm1d(500), 184 | nn.Dropout(p=args.drop_out), 185 | nn.ReLU(), 186 | nn.Linear(500, 300), 187 | nn.BatchNorm1d(300), 188 | nn.Dropout(p=args.drop_out), 189 | nn.ReLU(), 190 | nn.Linear(300, 10) 191 | ) 192 | model.to(device) 193 | state_dict = torch.load(args.model_path, map_location=lambda storage, loc: storage) 194 | model.load_state_dict(state_dict) 195 | # set to eval mode 196 | model.eval() 197 | 198 | res_list = [] 199 | print("begin predict....") 200 | for idx, sample in enumerate(test_dataloader): 201 | data = Variable(sample['data']).to(device) 202 | 203 | output = model(data) 204 | predict = torch.argmax(output) 205 | # print("predict: ", predict.item()) 206 | res_list.append(predict.item()) 207 | 208 | # write res to csv 209 | write_to_csv(res_list, args.predict_path) 210 | print("write done!") 211 | 212 | # calc acc. 213 | # acc = calc_acc(args.predict_path, 'data/test_data/TestLabels.csv') 214 | # print("acc is: {}".format(acc)) 215 | 216 | 217 | if __name__ == "__main__": 218 | parser = argparse.ArgumentParser(description='PyTorch fine tune MNIST data Training') 219 | 220 | # mode params 221 | parser.add_argument("--train", dest='train', action='store_true', 222 | help='use model to do train') 223 | parser.add_argument('--evaluate', dest='evaluate', action='store_true', 224 | help='evaluate model on validation set') 225 | parser.add_argument('--predict', dest='predict', action='store_true', 226 | help='use model to do prediction') 227 | 228 | # data path 229 | parser.add_argument('--trainSamples', default='data/train_data/TrainSamples', 230 | type=str, help="train datas path") 231 | parser.add_argument('--trainLabels', default='data/train_data/TrainLabels', 232 | type=str, help="train labels path") 233 | parser.add_argument('--validSamples', default='data/valid_data/ValidSamples', 234 | type=str, help="valid datas path") 235 | parser.add_argument('--validLabels', default='data/valid_data/ValidLabels', 236 | type=str, help="valid labels path") 237 | 238 | # model params 239 | parser.add_argument('--epochs', default=50, type=int, metavar='N', 240 | help='number of total epochs to run (default: 50)') 241 | parser.add_argument('--batch_size', default=64, type=int, 242 | metavar='N', help='mini-batch size (default: 64)') 243 | parser.add_argument('--lr', '--learning_rate', default=0.00001, type=float, 244 | metavar='LR', help='initial learning rate (default 0.0001)') 245 | parser.add_argument('-momentum', default=0.9, type=float, metavar='M', 246 | help='momentum (default: 0.9)') 247 | parser.add_argument('--weight_decay', '--wd', default=1e-4, type=float, 248 | metavar='W', help='weight decay (default: 1e-4)') 249 | parser.add_argument('--drop_out', default=0.1, type=float, 250 | help='drop out rate') 251 | parser.add_argument("--optim", '--op', default='momentum', type=str, 252 | help='use what optimizer (default: momentum)') 253 | 254 | # log params 255 | parser.add_argument('--print_freq', '-p', default=104, type=int, 256 | metavar='N', help='print frequency (default: 104 batch)') 257 | 258 | # save params 259 | parser.add_argument("--model_path", default="result/best_model.pkl", 260 | help="current best model path") 261 | parser.add_argument("--predict_path", default='data/test_data/Result.csv', type=str, 262 | help='test data predict file path') 263 | 264 | args = parser.parse_args() 265 | # predict(args) 266 | if args.train: 267 | main(args) 268 | elif args.predict: 269 | predict(args) 270 | else: 271 | print("invalid args") 272 | 273 | 274 | 275 | 276 | -------------------------------------------------------------------------------- /src/mnist_classify/models.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # coding:utf-8 3 | 4 | """ 5 | @author: yyhaker 6 | @contact: 572176750@qq.com 7 | @file: models.py 8 | @time: 2018/10/16 18:50 9 | """ 10 | import torch 11 | import torch.nn as nn 12 | import torch.nn.functional as F 13 | 14 | 15 | class MultiLayersNetwork(nn.Module): 16 | """ 17 | Multi-layers Network. 18 | """ 19 | def __init__(self, n_features, hidden_1, hidden_2, n_output): 20 | super(MultiLayersNetwork, self).__init__() 21 | self.hidden1 = nn.Linear(n_features, hidden_1) # hidden layer1 22 | self.hidden2 = nn.Linear(hidden_1, hidden_2) 23 | self.output = nn.Linear(hidden_2, n_output) # output layer 24 | 25 | def forward(self, x): 26 | x = F.dropout(F.relu(self.hidden1(x))) 27 | x = F.dropout(F.relu(self.hidden2(x))) 28 | x = self.output(x) 29 | return x 30 | -------------------------------------------------------------------------------- /src/mnist_classify/myutils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # coding:utf-8 3 | 4 | """ 5 | @author: yyhaker 6 | @contact: 572176750@qq.com 7 | @file: myutils.py 8 | @time: 2018/10/17 14:19 9 | """ 10 | import pickle 11 | import csv 12 | import numpy as np 13 | 14 | 15 | def load_data_from_file(path): 16 | """ 17 | :param path: the store path 18 | :return: 19 | """ 20 | data_obj = None 21 | with open(path, 'rb') as f: 22 | data_obj = pickle.load(f) 23 | return data_obj 24 | 25 | 26 | def write_data_to_file(data, path): 27 | """ 28 | :param data: the data obj 29 | :param path: the store path 30 | :return: 31 | """ 32 | with open(path, 'wb') as f: 33 | pickle.dump(data, f) 34 | 35 | 36 | def write_to_csv(datas, path): 37 | """ 38 | :param datas: a list of data. 39 | :param path: path 40 | :return: 41 | """ 42 | datas = np.array(datas) 43 | if len(datas.shape) < 2: 44 | datas = np.reshape(datas, (len(datas), 1)) 45 | # 用csv一行一行的写入, 46 | with open(path, 'w') as csv_file: 47 | writer = csv.writer(csv_file) 48 | writer.writerows(datas) 49 | 50 | 51 | def read_from_csv(path): 52 | """ 53 | :param path: path. 54 | :return: lines. 55 | """ 56 | with open(path, 'r') as csv_file: 57 | reader = csv.reader(csv_file) 58 | lines = list(reader) 59 | return lines 60 | 61 | 62 | def calc_acc(csv1, csv2): 63 | """ 64 | compare two files, calc acc. 65 | :param csv1: path 66 | :param csv2: path 67 | :return: 68 | """ 69 | count = 0. 70 | lines1 = read_from_csv(csv1) 71 | lines2 = read_from_csv(csv2) 72 | for i, j in zip(lines1, lines2): 73 | if int(i[0]) == int(j[0]): 74 | count += 1 75 | return count/len(lines1) 76 | 77 | -------------------------------------------------------------------------------- /src/mnist_classify/plot_result.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # coding:utf-8 3 | 4 | """ 5 | @author: yyhaker 6 | @contact: 572176750@qq.com 7 | @file: plot_result.py 8 | @time: 2018/10/17 14:18 9 | """ 10 | # -*- coding:utf-8 -*- 11 | """ 12 | plot the result. 13 | losses_dict = {"train_loss": [], "valid_loss": []} 14 | acc_dic = {"train_acc": [], "valid_acc": []} 15 | """ 16 | import numpy as np 17 | import matplotlib.pyplot as plt 18 | from myutils import load_data_from_file 19 | 20 | losses_dict = load_data_from_file("result/loss_dict.pkl") 21 | acc_dict = load_data_from_file("result/acc_dict.pkl") 22 | 23 | train_loss, valid_loss = losses_dict["train_loss"], losses_dict["valid_loss"] 24 | train_acc, valid_acc = acc_dict['train_acc'], acc_dict['valid_acc'] 25 | print("len(train_loss): ", len(train_loss)) 26 | assert len(train_loss) == len(valid_loss) and len(train_acc) == len(valid_acc) 27 | # plot data 28 | epoches = np.arange(1, len(train_loss)+1) 29 | 30 | plt.figure() 31 | plt.plot(epoches, train_loss, label="train_loss") 32 | plt.plot(epoches, valid_loss, color='red', linewidth=1.0, linestyle='--', label="valid_loss") 33 | plt.legend() 34 | plt.xlabel("EPOCH") 35 | plt.ylabel("loss") 36 | plt.title("train and valid loss") 37 | plt.show() 38 | 39 | plt.figure() 40 | plt.plot(epoches, train_acc, label="train_acc") 41 | plt.plot(epoches, valid_acc, label="valid_acc") 42 | plt.legend() 43 | plt.xlabel("EPOCH") 44 | plt.ylabel("accuracy") 45 | plt.title("train and valid accuracy") 46 | plt.show() 47 | -------------------------------------------------------------------------------- /src/mnist_classify/readme.md: -------------------------------------------------------------------------------- 1 | # MNIST手写数字分类任务 2 | 使用机器学习的方法来分类手写数字识别,该数据集总共有20000个,包含10个类别。 3 | 每个样本数据是压缩过后的数据,有81维,用灰度图像看看不清楚! 4 | 5 | # 数据集划分 6 | Total data size|Train data size|Valid data size 7 | ------------|-----------|---------------- 8 | 20000 | 16000 | 4000 9 | 10 | # 模型与结果 11 | 12 | * 方法一: K-NN 13 | 14 | models | train accuracy| test accuracy 15 | --------|---------------|----------------- 16 | KNN+std|0.943 | 0.9065 17 | KNN| 0.9757 | 0.958 18 | 19 | * 方法二:朴素贝叶斯NB 20 | 21 | models | train accuracy| test accuracy 22 | --------|---------------|----------------- 23 | NB| 0.881 | 0.873 24 | NB+std|0.881 | 0.873 25 | 26 | * 方法三:支持向量机SVM 27 | 28 | models | train accuracy| test accuracy 29 | --------|---------------|----------------- 30 | SVM| 1.0 | 0.113 31 | SVM+std| 1.0 | 0.966 32 | 33 | 34 | * 方法四:神经网络(DNN) 35 | 36 | models | train accuracy| valid accuracy| test accuracy|iteration epochs 37 | --------|---------------|-----------------|---------------|----------------- 38 | DNN[100, 10]| 0.995 | 0.9317 | | 15 39 | DNN[500,300,10]+BN |0.9971 | 0.9692 | | 150 40 | DNN[500,300,10]+BN+drop_out[0.1]| 0.9847 | 0.9655 | | 150 41 | DNN[500,300,10]+BN+drop_out[0.3]| 0.9702 | 0.9617 | |200 42 | DNN[500,300,100,10]+BN+drop_out[0.3]| 0.9748 | 0.9702 | |300 43 | DNN[500,300,200,10]+BN+drop_out[0.3]| 0.9767 | 0.9710 | |300 44 | DNN[500,300,300,10]+BN+drop_out[0.3]| 0.9765 | 0.9691 | |300 45 | DNN[600,300,200,10]+BN+drop_out[0.3]| 0.9799 | 0.9711 | |300 46 | DNN[800,300,200,10]+BN+drop_out[0.3]| 0.9830 | 0.9732 | |300 47 | DNN[800,500,200,10]+BN+drop_out[0.3]| 0.99234 | 0.9755 | |350 48 | 49 | 50 | 51 | ## 最好的结果 52 | 训练正确率变化 53 | ![acc](/src/mnist_classify/result/acc.png) 54 | 55 | 56 | 训练loss变化 57 | ![loss](/src/mnist_classify/result/loss.png) 58 | 59 | -------------------------------------------------------------------------------- /src/mnist_classify/result/acc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/mnist_classify/result/acc.png -------------------------------------------------------------------------------- /src/mnist_classify/result/acc_dict.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/mnist_classify/result/acc_dict.pkl -------------------------------------------------------------------------------- /src/mnist_classify/result/best_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/mnist_classify/result/best_model.pkl -------------------------------------------------------------------------------- /src/mnist_classify/result/loss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/mnist_classify/result/loss.png -------------------------------------------------------------------------------- /src/mnist_classify/result/loss_dict.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/mnist_classify/result/loss_dict.pkl -------------------------------------------------------------------------------- /src/perceptron/data/Samples.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/perceptron/data/Samples.mat -------------------------------------------------------------------------------- /src/perceptron/data_helper.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import numpy as np 3 | import csv 4 | 5 | 6 | def load_sample_data(): 7 | """ 8 | load sample data. 9 | :return: 10 | """ 11 | datas = [ 12 | [1, 1], [2, 2], [2, 0], 13 | [0, 0], [1, 0], [0, 1], 14 | ] 15 | labels = [1, 1, 1, 2, 2, 2] 16 | return np.array(datas, dtype='float64'), np.array(labels) 17 | 18 | 19 | def load_mnist_data(filename='./data/TestSamples.csv', 20 | label_filename='./data/TrueLabels.csv'): 21 | """ 22 | load mnist data 23 | :param filename: 24 | :param label_filename: 25 | :return: 26 | """ 27 | 28 | with open(filename, 'r') as csvfile: 29 | lines = csv.reader(csvfile) 30 | dataSet = list(lines) 31 | 32 | with open(label_filename, 'r') as f: 33 | lines = csv.reader(f) 34 | training_data_label = list(lines) 35 | 36 | # transfer label to 1 dim, char to num 37 | training_data_label = [int(la[0]) for la in training_data_label] 38 | return np.array(dataSet, dtype='float64'), np.array(training_data_label) 39 | 40 | 41 | if __name__ == "__main__": 42 | datas, labels = load_sample_data() 43 | print(datas) 44 | print(labels) 45 | -------------------------------------------------------------------------------- /src/perceptron/perceptron.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import numpy as np 3 | from data_helper import load_sample_data, load_mnist_data 4 | import matplotlib.pyplot as plt 5 | 6 | 7 | class Perceptron(object): 8 | def __init__(self): 9 | pass 10 | 11 | def predict(self, data, alpha): 12 | """ 13 | predict the label of the sample data. 14 | :param data: 增广后的数据 15 | :param alpha: alpha 16 | :return: 17 | 'label': 1 or 2. (类别) 18 | """ 19 | res = np.dot(alpha, data) 20 | if res > 0: 21 | return 1 22 | else: 23 | return 2 24 | 25 | def isMisClassified(self, data, alpha): 26 | """ 27 | 判断感知器是否将数据错误分类. 28 | :param data: 增广后的数据. 29 | :param alpha: alpha 30 | :return: True or False. 31 | """ 32 | res = np.dot(alpha, data) 33 | if res > 0: 34 | return False 35 | else: 36 | return True 37 | 38 | def train(self, datas, eta=1., theta=1e-4, another=3, mode='single'): 39 | """ 40 | train the perceptron. 41 | :param datas: numpy array, (n, d) 42 | :param eta: 43 | :param theta: 44 | :param another: another class from idx. 45 | :param mode: 'single' or 'batch' 46 | :return: 47 | 'alpha': numpy array, (1+d) 48 | """ 49 | # nxd 50 | n, d = datas.shape 51 | # aug datas (n, d) -> (n, 1+d) 52 | ones = np.ones(n) 53 | datas = np.insert(datas, 0, values=ones, axis=1) 54 | # 第二种类别乘以-1 55 | datas[another:] = datas[another:] * (-1) 56 | 57 | # initialize alpha, eta, theta 58 | b = np.ones(d) 59 | alpha = np.concatenate(([0.], b)) 60 | step = np.array(np.inf * (1+d)) 61 | # print("init alpha: ", alpha) 62 | 63 | # 单样本调整版本的感知器算法 64 | if mode == 'single': 65 | while True: 66 | count = 0 67 | for idx, data in enumerate(datas): 68 | if self.isMisClassified(data, alpha): 69 | step = eta * data 70 | alpha = alpha + step 71 | # print("current alpha: ", alpha) 72 | else: 73 | count += 1 74 | # 所有的样本正确分类 75 | if count == n: 76 | break 77 | # 批量调整版本的感知器算法 78 | elif mode == 'batch': 79 | while True: 80 | error_samples = np.zeros((1+d)) 81 | for idx, data in enumerate(datas): 82 | # 收集错误分类的样本 83 | if self.isMisClassified(data, alpha): 84 | error_samples += data 85 | # print("error samples: ", error_samples) 86 | # calc step 87 | step = eta * error_samples 88 | # update params 89 | alpha += step 90 | print("current step: ", step, "alpha: ", alpha) 91 | # 收敛条件 92 | if np.linalg.norm(step, ord=1) < theta: 93 | break 94 | return alpha 95 | 96 | def plot_result(self, datas, alpha): 97 | """ 98 | plot the res. 99 | :param datas: n x d. 100 | :param alpha: 1+d 101 | :return: 102 | """ 103 | colorMark = ['or', 'dg'] 104 | for idx, data in enumerate(datas): 105 | plt.plot(data[0], data[1], colorMark[idx >= 3]) 106 | x = np.linspace(-1, 3, 1000) 107 | y = -(alpha[0] + alpha[1]*x) / alpha[2] 108 | plt.plot(x, y, color='blue') 109 | plt.show() 110 | 111 | 112 | def experiment1(): 113 | """ 114 | 单样本调整版本的感知器算法. 115 | :return: 116 | """ 117 | datas, labels = load_sample_data() 118 | perceptron = Perceptron() 119 | alpha = perceptron.train(datas, labels) 120 | print("last alpha: ", alpha) 121 | perceptron.plot_result(datas, alpha) 122 | 123 | 124 | def experiment2(): 125 | """ 126 | 批量调整版本的感知器算法. 127 | :return: 128 | """ 129 | datas, labels = load_sample_data() 130 | perceptron = Perceptron() 131 | alpha = perceptron.train(datas, labels, eta=0.01, theta=1e-4, mode='batch') 132 | print("last alpha: ", alpha) 133 | perceptron.plot_result(datas, alpha) 134 | 135 | 136 | def experiment3(): 137 | """ 138 | 使用感知器算法分类多类样本.(线性不可分,无法收敛) 139 | ------ 140 | 1. 数据集归类 141 | 2. 每两类训练一个感知器模型,得到参数alpha,这样总共得到c(c-1)/2个 142 | 3. 对于测试样本x, 如果g_{ij}(x)>=0, 对于任意j不等于i,则x属于w_i. 143 | :return: 144 | """ 145 | # 数据集归类 146 | train_datas, train_labels = load_mnist_data() 147 | n, d = train_datas.shape 148 | print("total train datas is {}, dim is: {}".format(n, d)) 149 | datas = {} 150 | for idx, j in enumerate(train_labels): 151 | if j not in datas.keys(): 152 | datas[j] = [] 153 | datas[j].append(train_datas[idx]) 154 | c = len(datas.keys()) 155 | 156 | # 每两类训练一个感知器模型 157 | alphas = np.zeros((c, c, 1+d)) 158 | combines = [] 159 | for i in datas.keys(): 160 | for j in datas.keys(): 161 | if i != j: 162 | combines.append((i, j)) 163 | 164 | for i, j in combines: 165 | dataij = np.concatenate((datas[i], datas[j]), axis=0) 166 | # print(len(dataij), len(datas[i]), len(datas[j])) 167 | perceptron = Perceptron() 168 | alphas[i, j] = perceptron.train(dataij, another=len(datas[i])) 169 | print("=========>>> alpha[i. j] is {}".format(alphas[i, j])) 170 | 171 | # 对于测试样本x, 如果g_{ij}(x)>=0, 对于任意j不等于i,则x属于w_i. 172 | test_datas, test_labels = load_mnist_data(filename='./data/TestSamples.csv', 173 | label_filename='./data/TestLabels.csv') 174 | test_n, test_dim = test_datas.shape 175 | print("total test datas is: {}, dim is: {}".format(test_n, test_dim)) 176 | count = 0 177 | test_datas = np.insert(test_datas, 0, values=np.ones(test_n), axis=1) 178 | perceptron = Perceptron() 179 | for idx, data in enumerate(test_datas): 180 | p_lbl = -1 181 | for i in range(c): 182 | flag = True 183 | for j in range(c): 184 | if (i, j) in combines: 185 | if np.dot(data, alphas[i, j]) < 0: 186 | flag = False 187 | break 188 | if flag: 189 | p_lbl = i 190 | if p_lbl == test_labels[idx]: 191 | count += 1 192 | print("total test acc is {} / {} = {}".format(count, test_n, (count + 0.0)/test_n)) 193 | 194 | 195 | 196 | 197 | if __name__ == "__main__": 198 | experiment3() 199 | 200 | 201 | -------------------------------------------------------------------------------- /src/perceptron/pictures/perceptron_batch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/perceptron/pictures/perceptron_batch.png -------------------------------------------------------------------------------- /src/perceptron/pictures/perceptron_rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/perceptron/pictures/perceptron_rule.png -------------------------------------------------------------------------------- /src/perceptron/pictures/perceptron_single.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyHaker/MachineLearning/HEAD/src/perceptron/pictures/perceptron_single.png -------------------------------------------------------------------------------- /src/perceptron/readme.md: -------------------------------------------------------------------------------- 1 | # perceptron 2 | 感知器算法是一种可以直接得到线性判别函数的线性分类方法,它采用最直观的准则,即最小错分样本数, 3 | 将错分样本到判别界面的距离之和作为准则,称为感知器准则。表示如下: 4 | ![perceptron rule](/src/perceptron/pictures/perceptron_rule.png) 5 | 6 | 7 | ## result 8 | 1. 使用单样本调整版本的感知器算法分类如下结果 9 | 10 | ![perceptron single result](/src/perceptron/pictures/perceptron_single.png) 11 | 12 | 2. 使用批量调整版本的感知器算法分类如下效果 13 | 14 | ![perceptron batch result](/src/perceptron/pictures/perceptron_batch.png) 15 | 16 | 3. 使用感知器算法解决多分类问题 17 | 18 | 每两个训练一个分类器,总共有c(c-1)/2个分类器,测试时候如果对任意j != i,有gij(x) >= 0,则决策属于wi;其它情况,则拒识。 19 | 20 | 注意:如果数据集线性不可分,感知器无法收敛! 21 | --------------------------------------------------------------------------------