├── SM3algorithm ├── SM3密码杂凑算法.pdf └── SM3算法实现.ipynb ├── LinearRegressionalgorithm ├── RSB_DataSet.csv └── LinearRegression algorithm.ipynb ├── SM4algorithm ├── SM4--无线局域网产品使用的 SMS4 密码算法.pdf └── sm4-algorithm.ipynb ├── KNNalgorithm ├── Iris.csv └── KNN algorithm.ipynb ├── 常用的机器学习评估指标和损失函数 └── common-evaluation-metrics-and-loss-functions.ipynb ├── perceptronalgorithm └── perceptron-algorithm-from-scratch.ipynb ├── sha256 algorithm └── sha256算法实现.ipynb └── naivebayesclassifier ├── naivebayesclassifier algorithm.ipynb └── sample_submission.csv /SM3algorithm/SM3密码杂凑算法.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yunsuxiaozi/Implementing-algorithms-from-scratch/main/SM3algorithm/SM3密码杂凑算法.pdf -------------------------------------------------------------------------------- /LinearRegressionalgorithm/RSB_DataSet.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yunsuxiaozi/Implementing-algorithms-from-scratch/main/LinearRegressionalgorithm/RSB_DataSet.csv -------------------------------------------------------------------------------- /SM4algorithm/SM4--无线局域网产品使用的 SMS4 密码算法.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yunsuxiaozi/Implementing-algorithms-from-scratch/main/SM4algorithm/SM4--无线局域网产品使用的 SMS4 密码算法.pdf -------------------------------------------------------------------------------- /KNNalgorithm/Iris.csv: -------------------------------------------------------------------------------- 1 | Id,SepalLengthCm,SepalWidthCm,PetalLengthCm,PetalWidthCm,Species 2 | 1,5.1,3.5,1.4,0.2,Iris-setosa 3 | 2,4.9,3.0,1.4,0.2,Iris-setosa 4 | 3,4.7,3.2,1.3,0.2,Iris-setosa 5 | 4,4.6,3.1,1.5,0.2,Iris-setosa 6 | 5,5.0,3.6,1.4,0.2,Iris-setosa 7 | 6,5.4,3.9,1.7,0.4,Iris-setosa 8 | 7,4.6,3.4,1.4,0.3,Iris-setosa 9 | 8,5.0,3.4,1.5,0.2,Iris-setosa 10 | 9,4.4,2.9,1.4,0.2,Iris-setosa 11 | 10,4.9,3.1,1.5,0.1,Iris-setosa 12 | 11,5.4,3.7,1.5,0.2,Iris-setosa 13 | 12,4.8,3.4,1.6,0.2,Iris-setosa 14 | 13,4.8,3.0,1.4,0.1,Iris-setosa 15 | 14,4.3,3.0,1.1,0.1,Iris-setosa 16 | 15,5.8,4.0,1.2,0.2,Iris-setosa 17 | 16,5.7,4.4,1.5,0.4,Iris-setosa 18 | 17,5.4,3.9,1.3,0.4,Iris-setosa 19 | 18,5.1,3.5,1.4,0.3,Iris-setosa 20 | 19,5.7,3.8,1.7,0.3,Iris-setosa 21 | 20,5.1,3.8,1.5,0.3,Iris-setosa 22 | 21,5.4,3.4,1.7,0.2,Iris-setosa 23 | 22,5.1,3.7,1.5,0.4,Iris-setosa 24 | 23,4.6,3.6,1.0,0.2,Iris-setosa 25 | 24,5.1,3.3,1.7,0.5,Iris-setosa 26 | 25,4.8,3.4,1.9,0.2,Iris-setosa 27 | 26,5.0,3.0,1.6,0.2,Iris-setosa 28 | 27,5.0,3.4,1.6,0.4,Iris-setosa 29 | 28,5.2,3.5,1.5,0.2,Iris-setosa 30 | 29,5.2,3.4,1.4,0.2,Iris-setosa 31 | 30,4.7,3.2,1.6,0.2,Iris-setosa 32 | 31,4.8,3.1,1.6,0.2,Iris-setosa 33 | 32,5.4,3.4,1.5,0.4,Iris-setosa 34 | 33,5.2,4.1,1.5,0.1,Iris-setosa 35 | 34,5.5,4.2,1.4,0.2,Iris-setosa 36 | 35,4.9,3.1,1.5,0.1,Iris-setosa 37 | 36,5.0,3.2,1.2,0.2,Iris-setosa 38 | 37,5.5,3.5,1.3,0.2,Iris-setosa 39 | 38,4.9,3.1,1.5,0.1,Iris-setosa 40 | 39,4.4,3.0,1.3,0.2,Iris-setosa 41 | 40,5.1,3.4,1.5,0.2,Iris-setosa 42 | 41,5.0,3.5,1.3,0.3,Iris-setosa 43 | 42,4.5,2.3,1.3,0.3,Iris-setosa 44 | 43,4.4,3.2,1.3,0.2,Iris-setosa 45 | 44,5.0,3.5,1.6,0.6,Iris-setosa 46 | 45,5.1,3.8,1.9,0.4,Iris-setosa 47 | 46,4.8,3.0,1.4,0.3,Iris-setosa 48 | 47,5.1,3.8,1.6,0.2,Iris-setosa 49 | 48,4.6,3.2,1.4,0.2,Iris-setosa 50 | 49,5.3,3.7,1.5,0.2,Iris-setosa 51 | 50,5.0,3.3,1.4,0.2,Iris-setosa 52 | 51,7.0,3.2,4.7,1.4,Iris-versicolor 53 | 52,6.4,3.2,4.5,1.5,Iris-versicolor 54 | 53,6.9,3.1,4.9,1.5,Iris-versicolor 55 | 54,5.5,2.3,4.0,1.3,Iris-versicolor 56 | 55,6.5,2.8,4.6,1.5,Iris-versicolor 57 | 56,5.7,2.8,4.5,1.3,Iris-versicolor 58 | 57,6.3,3.3,4.7,1.6,Iris-versicolor 59 | 58,4.9,2.4,3.3,1.0,Iris-versicolor 60 | 59,6.6,2.9,4.6,1.3,Iris-versicolor 61 | 60,5.2,2.7,3.9,1.4,Iris-versicolor 62 | 61,5.0,2.0,3.5,1.0,Iris-versicolor 63 | 62,5.9,3.0,4.2,1.5,Iris-versicolor 64 | 63,6.0,2.2,4.0,1.0,Iris-versicolor 65 | 64,6.1,2.9,4.7,1.4,Iris-versicolor 66 | 65,5.6,2.9,3.6,1.3,Iris-versicolor 67 | 66,6.7,3.1,4.4,1.4,Iris-versicolor 68 | 67,5.6,3.0,4.5,1.5,Iris-versicolor 69 | 68,5.8,2.7,4.1,1.0,Iris-versicolor 70 | 69,6.2,2.2,4.5,1.5,Iris-versicolor 71 | 70,5.6,2.5,3.9,1.1,Iris-versicolor 72 | 71,5.9,3.2,4.8,1.8,Iris-versicolor 73 | 72,6.1,2.8,4.0,1.3,Iris-versicolor 74 | 73,6.3,2.5,4.9,1.5,Iris-versicolor 75 | 74,6.1,2.8,4.7,1.2,Iris-versicolor 76 | 75,6.4,2.9,4.3,1.3,Iris-versicolor 77 | 76,6.6,3.0,4.4,1.4,Iris-versicolor 78 | 77,6.8,2.8,4.8,1.4,Iris-versicolor 79 | 78,6.7,3.0,5.0,1.7,Iris-versicolor 80 | 79,6.0,2.9,4.5,1.5,Iris-versicolor 81 | 80,5.7,2.6,3.5,1.0,Iris-versicolor 82 | 81,5.5,2.4,3.8,1.1,Iris-versicolor 83 | 82,5.5,2.4,3.7,1.0,Iris-versicolor 84 | 83,5.8,2.7,3.9,1.2,Iris-versicolor 85 | 84,6.0,2.7,5.1,1.6,Iris-versicolor 86 | 85,5.4,3.0,4.5,1.5,Iris-versicolor 87 | 86,6.0,3.4,4.5,1.6,Iris-versicolor 88 | 87,6.7,3.1,4.7,1.5,Iris-versicolor 89 | 88,6.3,2.3,4.4,1.3,Iris-versicolor 90 | 89,5.6,3.0,4.1,1.3,Iris-versicolor 91 | 90,5.5,2.5,4.0,1.3,Iris-versicolor 92 | 91,5.5,2.6,4.4,1.2,Iris-versicolor 93 | 92,6.1,3.0,4.6,1.4,Iris-versicolor 94 | 93,5.8,2.6,4.0,1.2,Iris-versicolor 95 | 94,5.0,2.3,3.3,1.0,Iris-versicolor 96 | 95,5.6,2.7,4.2,1.3,Iris-versicolor 97 | 96,5.7,3.0,4.2,1.2,Iris-versicolor 98 | 97,5.7,2.9,4.2,1.3,Iris-versicolor 99 | 98,6.2,2.9,4.3,1.3,Iris-versicolor 100 | 99,5.1,2.5,3.0,1.1,Iris-versicolor 101 | 100,5.7,2.8,4.1,1.3,Iris-versicolor 102 | 101,6.3,3.3,6.0,2.5,Iris-virginica 103 | 102,5.8,2.7,5.1,1.9,Iris-virginica 104 | 103,7.1,3.0,5.9,2.1,Iris-virginica 105 | 104,6.3,2.9,5.6,1.8,Iris-virginica 106 | 105,6.5,3.0,5.8,2.2,Iris-virginica 107 | 106,7.6,3.0,6.6,2.1,Iris-virginica 108 | 107,4.9,2.5,4.5,1.7,Iris-virginica 109 | 108,7.3,2.9,6.3,1.8,Iris-virginica 110 | 109,6.7,2.5,5.8,1.8,Iris-virginica 111 | 110,7.2,3.6,6.1,2.5,Iris-virginica 112 | 111,6.5,3.2,5.1,2.0,Iris-virginica 113 | 112,6.4,2.7,5.3,1.9,Iris-virginica 114 | 113,6.8,3.0,5.5,2.1,Iris-virginica 115 | 114,5.7,2.5,5.0,2.0,Iris-virginica 116 | 115,5.8,2.8,5.1,2.4,Iris-virginica 117 | 116,6.4,3.2,5.3,2.3,Iris-virginica 118 | 117,6.5,3.0,5.5,1.8,Iris-virginica 119 | 118,7.7,3.8,6.7,2.2,Iris-virginica 120 | 119,7.7,2.6,6.9,2.3,Iris-virginica 121 | 120,6.0,2.2,5.0,1.5,Iris-virginica 122 | 121,6.9,3.2,5.7,2.3,Iris-virginica 123 | 122,5.6,2.8,4.9,2.0,Iris-virginica 124 | 123,7.7,2.8,6.7,2.0,Iris-virginica 125 | 124,6.3,2.7,4.9,1.8,Iris-virginica 126 | 125,6.7,3.3,5.7,2.1,Iris-virginica 127 | 126,7.2,3.2,6.0,1.8,Iris-virginica 128 | 127,6.2,2.8,4.8,1.8,Iris-virginica 129 | 128,6.1,3.0,4.9,1.8,Iris-virginica 130 | 129,6.4,2.8,5.6,2.1,Iris-virginica 131 | 130,7.2,3.0,5.8,1.6,Iris-virginica 132 | 131,7.4,2.8,6.1,1.9,Iris-virginica 133 | 132,7.9,3.8,6.4,2.0,Iris-virginica 134 | 133,6.4,2.8,5.6,2.2,Iris-virginica 135 | 134,6.3,2.8,5.1,1.5,Iris-virginica 136 | 135,6.1,2.6,5.6,1.4,Iris-virginica 137 | 136,7.7,3.0,6.1,2.3,Iris-virginica 138 | 137,6.3,3.4,5.6,2.4,Iris-virginica 139 | 138,6.4,3.1,5.5,1.8,Iris-virginica 140 | 139,6.0,3.0,4.8,1.8,Iris-virginica 141 | 140,6.9,3.1,5.4,2.1,Iris-virginica 142 | 141,6.7,3.1,5.6,2.4,Iris-virginica 143 | 142,6.9,3.1,5.1,2.3,Iris-virginica 144 | 143,5.8,2.7,5.1,1.9,Iris-virginica 145 | 144,6.8,3.2,5.9,2.3,Iris-virginica 146 | 145,6.7,3.3,5.7,2.5,Iris-virginica 147 | 146,6.7,3.0,5.2,2.3,Iris-virginica 148 | 147,6.3,2.5,5.0,1.9,Iris-virginica 149 | 148,6.5,3.0,5.2,2.0,Iris-virginica 150 | 149,6.2,3.4,5.4,2.3,Iris-virginica 151 | 150,5.9,3.0,5.1,1.8,Iris-virginica 152 | -------------------------------------------------------------------------------- /常用的机器学习评估指标和损失函数/common-evaluation-metrics-and-loss-functions.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "5ec51196", 6 | "metadata": { 7 | "papermill": { 8 | "duration": 0.002654, 9 | "end_time": "2024-03-12T12:04:23.502557", 10 | "exception": false, 11 | "start_time": "2024-03-12T12:04:23.499903", 12 | "status": "completed" 13 | }, 14 | "tags": [] 15 | }, 16 | "source": [ 17 | "## Created by yunsuxiaozi 2024/3/21\n", 18 | "\n", 19 | "### 这里实现了机器学习一些比较常用的评估指标和损失函数,并且给出了对应的比赛链接,各位可以通过比赛来了解这些评估指标的使用。后续可能会更新更多机器学习中常用的评估指标和损失函数." 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": 1, 25 | "id": "85a71a45", 26 | "metadata": { 27 | "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", 28 | "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5", 29 | "execution": { 30 | "iopub.execute_input": "2024-03-12T12:04:23.509121Z", 31 | "iopub.status.busy": "2024-03-12T12:04:23.508673Z", 32 | "iopub.status.idle": "2024-03-12T12:04:27.350840Z", 33 | "shell.execute_reply": "2024-03-12T12:04:27.349422Z" 34 | }, 35 | "papermill": { 36 | "duration": 3.848903, 37 | "end_time": "2024-03-12T12:04:27.353776", 38 | "exception": false, 39 | "start_time": "2024-03-12T12:04:23.504873", 40 | "status": "completed" 41 | }, 42 | "tags": [] 43 | }, 44 | "outputs": [ 45 | { 46 | "name": "stdout", 47 | "output_type": "stream", 48 | "text": [ 49 | "Regression\n", 50 | "-------MSE--------\n", 51 | "-------MAE--------\n", 52 | "-------MedAE--------competition:https://www.kaggle.com/competitions/playground-series-s3e25\n", 53 | "-------RMSE--------competition:https://www.kaggle.com/competitions/linking-writing-processes-to-writing-quality\n", 54 | "-------RMSLE--------competition:https://www.kaggle.com/competitions/store-sales-time-series-forecasting\n", 55 | "classification\n", 56 | "-------logloss--------competition:https://www.kaggle.com/competitions/playground-series-s3e26\n", 57 | "-------accuracy--------competition:https://www.kaggle.com/competitions/ml-olympiad-toxic-language-ptbr-detection\n", 58 | "-------roc_auc--------competition:https://www.kaggle.com/competitions/playground-series-s4e3\n", 59 | "-------KL_divergence--------competition:https://www.kaggle.com/competitions/hms-harmful-brain-activity-classification\n", 60 | "-------cross_entropy_loss--------competition:https://www.kaggle.com/competitions/digit-recognizer\n" 61 | ] 62 | } 63 | ], 64 | "source": [ 65 | "import numpy as np#进行矩阵运算的库\n", 66 | "import torch #一个深度学习的库Pytorch\n", 67 | "import torch.nn as nn#neural network,神经网络\n", 68 | "import torch.nn.functional as F#神经网络函数库\n", 69 | "\n", 70 | "print(\"Regression\")\n", 71 | "print(f\"-------MSE--------\")\n", 72 | "def MSE(y_true,y_pred):\n", 73 | " return np.mean((y_true-y_pred)**2)\n", 74 | "print(f\"-------MAE--------\")\n", 75 | "def MAE(y_true,y_pred):\n", 76 | " return np.mean(np.abs(y_true-y_pred))\n", 77 | "print(f\"-------MedAE--------competition:https://www.kaggle.com/competitions/playground-series-s3e25\")\n", 78 | "def MedAE(y_true,y_pred):\n", 79 | " return np.median(np.abs(y_true-y_pred)) \n", 80 | "print(f\"-------RMSE--------competition:https://www.kaggle.com/competitions/linking-writing-processes-to-writing-quality\")\n", 81 | "def RMSE(y_true,y_pred):\n", 82 | " return np.sqrt(np.mean((y_true-y_pred)**2))\n", 83 | "print(f\"-------RMSLE--------competition:https://www.kaggle.com/competitions/store-sales-time-series-forecasting\")\n", 84 | "def RMSLE(y_true,y_pred):\n", 85 | " return np.sqrt(np.mean((np.log1p(y_pred)-np.log1p(y_true))**2))\n", 86 | "\n", 87 | "print(\"classification\")\n", 88 | "print(f\"-------logloss--------competition:https://www.kaggle.com/competitions/playground-series-s3e26\")\n", 89 | "#评估指标是log_loss\n", 90 | "def log_loss(y_true,y_pred,eps=10**(-15)):\n", 91 | " y_true=np.clip(y_true,eps,1-eps)\n", 92 | " y_pred=np.clip(y_pred,eps,1-eps)\n", 93 | " return -np.mean(np.sum(y_true*np.log(y_pred),axis=-1))\n", 94 | "print(f\"-------accuracy--------competition:https://www.kaggle.com/competitions/ml-olympiad-toxic-language-ptbr-detection\")\n", 95 | "def accuracy(y_true,y_pred):\n", 96 | " return np.mean(y_true==y_pred)\n", 97 | "print(f\"-------roc_auc--------competition:https://www.kaggle.com/competitions/playground-series-s4e3\")\n", 98 | "def roc_auc(y_true,y_pro):#y_true是真实标签,y_pro是预测的概率值.\n", 99 | " steps=10000\n", 100 | " x=[]\n", 101 | " y=[]\n", 102 | " for step in range(steps):\n", 103 | " step_idx=step/steps\n", 104 | " y_pred=np.where(y_pro>=step_idx,1,0)\n", 105 | " #查全率(Recall),真正例(True Positive Rate,TPR):在所有真实的正例中,预测为正例的比例 \n", 106 | " TPR=np.sum(np.where(y_true+y_pred==2,1,0))/np.sum(y_true)\n", 107 | " #假正例(False Positive Rate,FPR),表示所有负例中,预测为正例的比例:\n", 108 | " FPR=np.sum((y_true==0)&(y_pred==1))/np.sum(y_true==0)\n", 109 | " x.append(FPR)\n", 110 | " y.append(TPR)\n", 111 | " #希尔排序算法(nlogn)\n", 112 | " mid=steps//2\n", 113 | " while(mid):\n", 114 | " for i in range(0,mid):\n", 115 | " for j in range(i+mid,steps,mid):\n", 116 | " if x[j]=mid)&(x[k]<=x[k-mid])):\n", 119 | " if x[k]\n", 113 | "\n", 126 | "\n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | "
SepalLengthCmSepalWidthCmPetalLengthCmPetalWidthCmSpecies
05.13.51.40.2Iris-setosa
14.93.01.40.2Iris-setosa
24.73.21.30.2Iris-setosa
34.63.11.50.2Iris-setosa
45.03.61.40.2Iris-setosa
\n", 180 | "" 181 | ], 182 | "text/plain": [ 183 | " SepalLengthCm SepalWidthCm PetalLengthCm PetalWidthCm Species\n", 184 | "0 5.1 3.5 1.4 0.2 Iris-setosa\n", 185 | "1 4.9 3.0 1.4 0.2 Iris-setosa\n", 186 | "2 4.7 3.2 1.3 0.2 Iris-setosa\n", 187 | "3 4.6 3.1 1.5 0.2 Iris-setosa\n", 188 | "4 5.0 3.6 1.4 0.2 Iris-setosa" 189 | ] 190 | }, 191 | "execution_count": 2, 192 | "metadata": {}, 193 | "output_type": "execute_result" 194 | } 195 | ], 196 | "source": [ 197 | "train_df=pd.read_csv(\"Iris.csv\")\n", 198 | "train_df.drop(['Id'],axis=1,inplace=True)\n", 199 | "train_df.head()" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "execution_count": 3, 205 | "id": "fb6814b0", 206 | "metadata": { 207 | "execution": { 208 | "iopub.execute_input": "2024-03-19T11:11:51.148846Z", 209 | "iopub.status.busy": "2024-03-19T11:11:51.148431Z", 210 | "iopub.status.idle": "2024-03-19T11:11:51.342405Z", 211 | "shell.execute_reply": "2024-03-19T11:11:51.341015Z" 212 | }, 213 | "papermill": { 214 | "duration": 0.201134, 215 | "end_time": "2024-03-19T11:11:51.345337", 216 | "exception": false, 217 | "start_time": "2024-03-19T11:11:51.144203", 218 | "status": "completed" 219 | }, 220 | "tags": [] 221 | }, 222 | "outputs": [ 223 | { 224 | "name": "stdout", 225 | "output_type": "stream", 226 | "text": [ 227 | "train_accuracy:0.9533333333333334\n" 228 | ] 229 | } 230 | ], 231 | "source": [ 232 | "#评估指标选择准确率\n", 233 | "def accuracy(y_true,y_pred):\n", 234 | " return np.mean(y_true==y_pred)\n", 235 | "train_X=train_df.drop(['Species'],axis=1).values\n", 236 | "train_y=train_df['Species'].values\n", 237 | "model=KNNClassifier(n_neighbors=5)\n", 238 | "model.fit(train_X,train_y)\n", 239 | "train_pred=model.predict(train_X)\n", 240 | "print(f\"train_accuracy:{accuracy(train_y,train_pred)}\")" 241 | ] 242 | } 243 | ], 244 | "metadata": { 245 | "kaggle": { 246 | "accelerator": "none", 247 | "dataSources": [ 248 | { 249 | "datasetId": 19, 250 | "sourceId": 420, 251 | "sourceType": "datasetVersion" 252 | } 253 | ], 254 | "dockerImageVersionId": 30664, 255 | "isGpuEnabled": false, 256 | "isInternetEnabled": true, 257 | "language": "python", 258 | "sourceType": "notebook" 259 | }, 260 | "kernelspec": { 261 | "display_name": "Python 3 (ipykernel)", 262 | "language": "python", 263 | "name": "python3" 264 | }, 265 | "language_info": { 266 | "codemirror_mode": { 267 | "name": "ipython", 268 | "version": 3 269 | }, 270 | "file_extension": ".py", 271 | "mimetype": "text/x-python", 272 | "name": "python", 273 | "nbconvert_exporter": "python", 274 | "pygments_lexer": "ipython3", 275 | "version": "3.8.5" 276 | }, 277 | "papermill": { 278 | "default_parameters": {}, 279 | "duration": 4.801503, 280 | "end_time": "2024-03-19T11:11:51.869050", 281 | "environment_variables": {}, 282 | "exception": null, 283 | "input_path": "__notebook__.ipynb", 284 | "output_path": "__notebook__.ipynb", 285 | "parameters": {}, 286 | "start_time": "2024-03-19T11:11:47.067547", 287 | "version": "2.5.0" 288 | } 289 | }, 290 | "nbformat": 4, 291 | "nbformat_minor": 5 292 | } 293 | -------------------------------------------------------------------------------- /SM3algorithm/SM3算法实现.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "6099c311", 6 | "metadata": { 7 | "papermill": { 8 | "duration": 0.004332, 9 | "end_time": "2024-03-12T03:18:10.711497", 10 | "exception": false, 11 | "start_time": "2024-03-12T03:18:10.707165", 12 | "status": "completed" 13 | }, 14 | "tags": [] 15 | }, 16 | "source": [ 17 | "## Created by yunsuxiaozi 2024/3/12\n", 18 | "### 这里将实现SM3密码杂凑算法.关于算法的详细介绍可以看PDF,我这里也是看PDF慢慢写出来的,并且用后面的测试样例来测试,能通过就基本没有问题了.SM3算法和SHA256算法大体的步骤非常类似,在实现的细节上不同.\n", 19 | "\n", 20 | "### 无法连接到github可以尝试这个命令: cmd: ipconfig /flushdns\n", 21 | "\n", 22 | "### 本地的代码上传到github后删除掉,需要 git reset +git checkout .这两个命令将仓库的文件下载到本地后再git add新的文件,commit(修改信息) push(上传)." 23 | ] 24 | }, 25 | { 26 | "cell_type": "markdown", 27 | "id": "91a5b200", 28 | "metadata": { 29 | "papermill": { 30 | "duration": 0.003298, 31 | "end_time": "2024-03-12T03:18:10.718685", 32 | "exception": false, 33 | "start_time": "2024-03-12T03:18:10.715387", 34 | "status": "completed" 35 | }, 36 | "tags": [] 37 | }, 38 | "source": [ 39 | "#### 这是循环左移的函数" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 1, 45 | "id": "929fe116", 46 | "metadata": { 47 | "execution": { 48 | "iopub.execute_input": "2024-03-12T03:18:10.728661Z", 49 | "iopub.status.busy": "2024-03-12T03:18:10.727690Z", 50 | "iopub.status.idle": "2024-03-12T03:18:10.743471Z", 51 | "shell.execute_reply": "2024-03-12T03:18:10.742471Z" 52 | }, 53 | "papermill": { 54 | "duration": 0.024332, 55 | "end_time": "2024-03-12T03:18:10.746448", 56 | "exception": false, 57 | "start_time": "2024-03-12T03:18:10.722116", 58 | "status": "completed" 59 | }, 60 | "tags": [] 61 | }, 62 | "outputs": [], 63 | "source": [ 64 | "\"\"\"\n", 65 | "^(按位与)的python符号是&.\n", 66 | "√(按位或)的python符号是|\n", 67 | "⊕(异或)的python符号是^.\n", 68 | "\"\"\"\n", 69 | "inf=0xFFFFFFFF#32位无符号整数的最大值(2^32-1)\n", 70 | "#循环左移 x=[a1,a2,……,a32] \n", 71 | "def ROTL(x, n):\n", 72 | " x=x&inf#如果输入的数据太大,会限制到2^32-1的范围内.\n", 73 | " n=n%32#如果n>32,则限制到32以内的范围.\n", 74 | " #x=[a1,a2,……,a32] 则x>>(32-n) =[0,0,……,0,a1,a2,……,an] \n", 75 | " #x<<(n) =[an+1,……a32,0,0,……,0]\n", 76 | " x = ((x << n) | (x >> (32 - n)))&inf\n", 77 | " return x" 78 | ] 79 | }, 80 | { 81 | "cell_type": "markdown", 82 | "id": "d0d52b54", 83 | "metadata": { 84 | "papermill": { 85 | "duration": 0.003368, 86 | "end_time": "2024-03-12T03:18:10.753650", 87 | "exception": false, 88 | "start_time": "2024-03-12T03:18:10.750282", 89 | "status": "completed" 90 | }, 91 | "tags": [] 92 | }, 93 | "source": [ 94 | "#### 这是根据PDF实现的,我也不知道算法是怎么设计出来的,同时这个算法和sha256算法非常类似,如果有需要可以看看sha256算法中我对算法的理解.这个算法我是昨天晚上花了2个小时写出来的,也没有像sha256算法思考的那么久." 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": 2, 100 | "id": "1354317c", 101 | "metadata": { 102 | "execution": { 103 | "iopub.execute_input": "2024-03-12T03:18:10.763543Z", 104 | "iopub.status.busy": "2024-03-12T03:18:10.762796Z", 105 | "iopub.status.idle": "2024-03-12T03:18:10.792815Z", 106 | "shell.execute_reply": "2024-03-12T03:18:10.791286Z" 107 | }, 108 | "papermill": { 109 | "duration": 0.038966, 110 | "end_time": "2024-03-12T03:18:10.796206", 111 | "exception": false, 112 | "start_time": "2024-03-12T03:18:10.757240", 113 | "status": "completed" 114 | }, 115 | "tags": [] 116 | }, 117 | "outputs": [], 118 | "source": [ 119 | "def FF(j,X,Y,Z):\n", 120 | " X,Y,Z=(X&inf),(Y&inf),(Z&inf)\n", 121 | " if j<16:\n", 122 | " return (X^Y^Z &inf)\n", 123 | " else:\n", 124 | " return ((X & Y)|( X & Z)|(Y&Z)&inf)\n", 125 | "\n", 126 | "def GG(j,X,Y,Z):\n", 127 | " X,Y,Z=(X&inf),(Y&inf),(Z&inf)\n", 128 | " if j<16:\n", 129 | " return (X^Y^Z&inf)\n", 130 | " else:\n", 131 | " return ((X & Y)|(~X & Z)&inf)\n", 132 | "\n", 133 | "def P0(X):\n", 134 | " X=X&inf\n", 135 | " return ((X^ROTL(X,9)&inf)^ROTL(X,17))&inf\n", 136 | "def P1(X):\n", 137 | " X=X&inf\n", 138 | " return ((X^ROTL(X,15)&inf)^ROTL(X,23))&inf\n", 139 | "\n", 140 | "def SM3(origin_str='helloworld'):\n", 141 | " V=[0x7380166f,0x4914b2b9,0x172442d7,0xda8a0600,0xa96f30bc,0x163138aa,0xe38dee4d,0xb0fb0e4e]\n", 142 | " T=[0x79cc4519 if j<16 else 0x7a879d8a for j in range(0,64)]\n", 143 | " #utf-8 能够表示世界上几乎所有的字符系统,无论原始字符串是什么,都能够得到一个统一的二进制表示.\n", 144 | " binaries = origin_str.encode('utf8')\n", 145 | " \"\"\"\n", 146 | " \\x80(16进制)=128(10进制)=1000 0000(2进制,8位)\n", 147 | " b'\\x00'=00000000(2进制 8位)\n", 148 | " len(binaries)是字节串的长度,即有多少字节,*8是每个字节由8位组成,转换成位长度\n", 149 | " to_bytes(8)转换成8字节或者说64位的字节串.byteorder='big'是大端字节序(就是从头到尾存储).\n", 150 | "\n", 151 | " 位长度: len(binaries)*8+8位+8位*(64-len(binaries)-1-8)+64位=512.\n", 152 | "\n", 153 | " \"\"\"\n", 154 | " churks=1#M是512的多少倍\n", 155 | "\n", 156 | " while 64*churks-len(binaries)-9<0:\n", 157 | " churks+=1\n", 158 | " #M是512的整数倍\n", 159 | " M = binaries + b'\\x80' + b'\\x00'*(64*churks-len(binaries)-1-8) + (len(binaries)<<3).to_bytes(8, byteorder='big')\n", 160 | "\n", 161 | " for churk in range(churks):\n", 162 | " M_copy=M[churk*64:(churk+1)*64]\n", 163 | " W=[0]*68\n", 164 | " W1=[0]*64\n", 165 | " #W[0]~W[15] 这里已经把 这个churk的二进制转成整数\n", 166 | " for j in range(0, 16):\n", 167 | " W[j] = M_copy[j*4:(j+1)*4]#4*8=32位长度.\n", 168 | " #W[t]转成16进制再转成10进制.\n", 169 | " W[j] = int(W[j].hex(), 16)#2^32的整数.\n", 170 | " for j in range(16,68):\n", 171 | " W[j]=(P1( W[j-16] ^ W[j-9] ^ROTL(W[j-3],15)) ) ^ROTL(W[j-13],7)^(W[j-6]&inf)\n", 172 | " \n", 173 | " for j in range(0,64):\n", 174 | " W1[j]=(W[j]^W[j+4])&inf\n", 175 | " \n", 176 | " a,b,c,d,e,f,g,h=V\n", 177 | " for j in range(64):#\n", 178 | " SS1=( ROTL( ( ROTL(a,12)+e+ROTL(T[j],j))&inf ,7) ) &inf\n", 179 | " SS2=(SS1^ROTL(a,12))&inf\n", 180 | " TT1=(FF(j,a,b,c)+d+SS2+W1[j])&inf\n", 181 | " TT2=(GG(j,e,f,g)+h+SS1+W[j])&inf\n", 182 | " d=c\n", 183 | " c=ROTL(b,9)\n", 184 | " b=a\n", 185 | " a=TT1\n", 186 | " h=g\n", 187 | " g=ROTL(f,19)\n", 188 | " f=e\n", 189 | " e=P0(TT2)\n", 190 | " #print(f\"j:{j},a:{hex(a)},b:{hex(b)},c:{hex(c)},d:{hex(d)},e:{hex(e)},f:{hex(f)},g:{hex(g)},h:{hex(h)}\")\n", 191 | " V[0]=a^V[0]&inf\n", 192 | " V[1]=b^V[1]&inf\n", 193 | " V[2]=c^V[2]&inf\n", 194 | " V[3]=d^V[3]&inf\n", 195 | " V[4]=e^V[4]&inf\n", 196 | " V[5]=f^V[5]&inf\n", 197 | " V[6]=g^V[6]&inf\n", 198 | " V[7]=h^V[7]&inf\n", 199 | " \n", 200 | " SM3 = ''\n", 201 | " for idx in range(len(V)):\n", 202 | " #将整数转换成4个字节(4*8=32位)的二进制数据,然后再转成十六进制数据(hex)\n", 203 | " SM3 = SM3+ V[idx].to_bytes(4, byteorder='big').hex()\n", 204 | " return SM3" 205 | ] 206 | }, 207 | { 208 | "cell_type": "markdown", 209 | "id": "06b4634a", 210 | "metadata": { 211 | "papermill": { 212 | "duration": 0.003513, 213 | "end_time": "2024-03-12T03:18:10.803905", 214 | "exception": false, 215 | "start_time": "2024-03-12T03:18:10.800392", 216 | "status": "completed" 217 | }, 218 | "tags": [] 219 | }, 220 | "source": [ 221 | "#### SM3是我国实现的算法,接下来我们来看看手写的算法对比python标准库的准确率." 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": 3, 227 | "id": "7a271aa0", 228 | "metadata": { 229 | "execution": { 230 | "iopub.execute_input": "2024-03-12T03:18:10.813949Z", 231 | "iopub.status.busy": "2024-03-12T03:18:10.813445Z", 232 | "iopub.status.idle": "2024-03-12T03:18:30.107239Z", 233 | "shell.execute_reply": "2024-03-12T03:18:30.104998Z" 234 | }, 235 | "papermill": { 236 | "duration": 19.303449, 237 | "end_time": "2024-03-12T03:18:30.111259", 238 | "exception": false, 239 | "start_time": "2024-03-12T03:18:10.807810", 240 | "status": "completed" 241 | }, 242 | "tags": [] 243 | }, 244 | "outputs": [], 245 | "source": [ 246 | "#!pip install是安装python库 -q:减少输出信息,gmssl是密码工具库,支持中国的国家商用密码(国密)算法.\n", 247 | "!pip install -q gmssl" 248 | ] 249 | }, 250 | { 251 | "cell_type": "code", 252 | "execution_count": 4, 253 | "id": "04bf8c8c", 254 | "metadata": { 255 | "execution": { 256 | "iopub.execute_input": "2024-03-12T03:18:30.122203Z", 257 | "iopub.status.busy": "2024-03-12T03:18:30.121696Z", 258 | "iopub.status.idle": "2024-03-12T03:19:50.681592Z", 259 | "shell.execute_reply": "2024-03-12T03:19:50.680073Z" 260 | }, 261 | "papermill": { 262 | "duration": 80.572482, 263 | "end_time": "2024-03-12T03:19:50.687889", 264 | "exception": false, 265 | "start_time": "2024-03-12T03:18:30.115407", 266 | "status": "completed" 267 | }, 268 | "tags": [] 269 | }, 270 | "outputs": [ 271 | { 272 | "name": "stdout", 273 | "output_type": "stream", 274 | "text": [ 275 | "accuracy:1.0\n" 276 | ] 277 | } 278 | ], 279 | "source": [ 280 | "from gmssl import sm3, func\n", 281 | "\n", 282 | "import random#用于生成随机数的库\n", 283 | "seed=2024\n", 284 | "random.seed(seed)\n", 285 | "num_string=10000\n", 286 | "char_num=\"abcdefghijklmnopqrstuvwxyz0123456789\"#可供选择的字符是a~z加上数字\n", 287 | "random_strings = []#存储随机生成的字符串\n", 288 | "for _ in range(num_string):\n", 289 | " str_len = random.randint(10, 500) #生成长度为10到500的字符\n", 290 | " random_string = ''.join(random.choices(char_num, k=str_len))\n", 291 | " random_strings.append(random_string)\n", 292 | " \n", 293 | "true_cnt=0#手写算法正确的个数\n", 294 | "for idx in range(num_string):\n", 295 | " origin_str=random_strings[idx]\n", 296 | " if SM3(origin_str) == sm3.sm3_hash(func.bytes_to_list(origin_str.encode('utf8'))):\n", 297 | " true_cnt+=1\n", 298 | "print(f\"accuracy:{true_cnt/num_string}\")" 299 | ] 300 | } 301 | ], 302 | "metadata": { 303 | "kaggle": { 304 | "accelerator": "none", 305 | "dataSources": [ 306 | { 307 | "datasetId": 4477849, 308 | "sourceId": 7676268, 309 | "sourceType": "datasetVersion" 310 | } 311 | ], 312 | "dockerImageVersionId": 30664, 313 | "isGpuEnabled": false, 314 | "isInternetEnabled": true, 315 | "language": "python", 316 | "sourceType": "notebook" 317 | }, 318 | "kernelspec": { 319 | "display_name": "Python 3", 320 | "language": "python", 321 | "name": "python3" 322 | }, 323 | "language_info": { 324 | "codemirror_mode": { 325 | "name": "ipython", 326 | "version": 3 327 | }, 328 | "file_extension": ".py", 329 | "mimetype": "text/x-python", 330 | "name": "python", 331 | "nbconvert_exporter": "python", 332 | "pygments_lexer": "ipython3", 333 | "version": "3.10.13" 334 | }, 335 | "papermill": { 336 | "default_parameters": {}, 337 | "duration": 104.200312, 338 | "end_time": "2024-03-12T03:19:51.314207", 339 | "environment_variables": {}, 340 | "exception": null, 341 | "input_path": "__notebook__.ipynb", 342 | "output_path": "__notebook__.ipynb", 343 | "parameters": {}, 344 | "start_time": "2024-03-12T03:18:07.113895", 345 | "version": "2.5.0" 346 | } 347 | }, 348 | "nbformat": 4, 349 | "nbformat_minor": 5 350 | } 351 | -------------------------------------------------------------------------------- /perceptronalgorithm/perceptron-algorithm-from-scratch.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "d003c2b7", 6 | "metadata": { 7 | "papermill": { 8 | "duration": 0.00323, 9 | "end_time": "2024-05-02T02:09:42.208412", 10 | "exception": false, 11 | "start_time": "2024-05-02T02:09:42.205182", 12 | "status": "completed" 13 | }, 14 | "tags": [] 15 | }, 16 | "source": [ 17 | "## Created by yunsuxiaozi 2024/5/2\n", 18 | "\n", 19 | "### 感知机算法说的简单点就是用线性回归做分类,比如做二分类任务,先给数据打上1和-1的标签,然后用线性回归来拟合,大于0的数据分为1这类,小于0的分为-1这类.关于线性回归的介绍可以看这篇文章Linear Regression algorithm from scratch\n", 20 | "\n", 21 | "### 这里选择的数据集是鸢尾花数据集Iris." 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 1, 27 | "id": "71b9e51e", 28 | "metadata": { 29 | "execution": { 30 | "iopub.execute_input": "2024-05-02T02:09:42.216801Z", 31 | "iopub.status.busy": "2024-05-02T02:09:42.216300Z", 32 | "iopub.status.idle": "2024-05-02T02:09:43.096675Z", 33 | "shell.execute_reply": "2024-05-02T02:09:43.095734Z" 34 | }, 35 | "papermill": { 36 | "duration": 0.887501, 37 | "end_time": "2024-05-02T02:09:43.099265", 38 | "exception": false, 39 | "start_time": "2024-05-02T02:09:42.211764", 40 | "status": "completed" 41 | }, 42 | "tags": [] 43 | }, 44 | "outputs": [], 45 | "source": [ 46 | "import pandas as pd#处理表格数据的库\n", 47 | "import numpy as np#进行矩阵运算的库\n", 48 | "import random#提供了一些用于生成随机数的函数\n", 49 | "#设置随机种子,保证模型可以复现\n", 50 | "def seed_everything(seed):\n", 51 | " np.random.seed(seed)#numpy的随机种子\n", 52 | " random.seed(seed)#python内置的随机种子\n", 53 | "seed_everything(seed=2024)" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 2, 59 | "id": "3064e48e", 60 | "metadata": { 61 | "execution": { 62 | "iopub.execute_input": "2024-05-02T02:09:43.107036Z", 63 | "iopub.status.busy": "2024-05-02T02:09:43.106180Z", 64 | "iopub.status.idle": "2024-05-02T02:09:43.157821Z", 65 | "shell.execute_reply": "2024-05-02T02:09:43.156831Z" 66 | }, 67 | "papermill": { 68 | "duration": 0.058892, 69 | "end_time": "2024-05-02T02:09:43.161182", 70 | "exception": false, 71 | "start_time": "2024-05-02T02:09:43.102290", 72 | "status": "completed" 73 | }, 74 | "tags": [] 75 | }, 76 | "outputs": [ 77 | { 78 | "name": "stdout", 79 | "output_type": "stream", 80 | "text": [ 81 | "len(dataset):150\n" 82 | ] 83 | }, 84 | { 85 | "data": { 86 | "text/html": [ 87 | "
\n", 88 | "\n", 101 | "\n", 102 | " \n", 103 | " \n", 104 | " \n", 105 | " \n", 106 | " \n", 107 | " \n", 108 | " \n", 109 | " \n", 110 | " \n", 111 | " \n", 112 | " \n", 113 | " \n", 114 | " \n", 115 | " \n", 116 | " \n", 117 | " \n", 118 | " \n", 119 | " \n", 120 | " \n", 121 | " \n", 122 | " \n", 123 | " \n", 124 | " \n", 125 | " \n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | "
SepalLengthCmSepalWidthCmPetalLengthCmPetalWidthCmSpecies
05.13.51.40.21
14.93.01.40.21
24.73.21.30.21
34.63.11.50.21
45.03.61.40.21
\n", 155 | "
" 156 | ], 157 | "text/plain": [ 158 | " SepalLengthCm SepalWidthCm PetalLengthCm PetalWidthCm Species\n", 159 | "0 5.1 3.5 1.4 0.2 1\n", 160 | "1 4.9 3.0 1.4 0.2 1\n", 161 | "2 4.7 3.2 1.3 0.2 1\n", 162 | "3 4.6 3.1 1.5 0.2 1\n", 163 | "4 5.0 3.6 1.4 0.2 1" 164 | ] 165 | }, 166 | "execution_count": 2, 167 | "metadata": {}, 168 | "output_type": "execute_result" 169 | } 170 | ], 171 | "source": [ 172 | "dataset=pd.read_csv(\"/kaggle/input/iris/Iris.csv\")\n", 173 | "print(f\"len(dataset):{len(dataset)}\")\n", 174 | "dataset.drop(['Id'],axis=1,inplace=True)\n", 175 | "#将label打上1和-1的标签\n", 176 | "dataset['Species']=(dataset['Species']=='Iris-setosa').astype(int)*2-1\n", 177 | "dataset.head()" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": 3, 183 | "id": "6c1d2009", 184 | "metadata": { 185 | "execution": { 186 | "iopub.execute_input": "2024-05-02T02:09:43.170407Z", 187 | "iopub.status.busy": "2024-05-02T02:09:43.169332Z", 188 | "iopub.status.idle": "2024-05-02T02:09:43.175055Z", 189 | "shell.execute_reply": "2024-05-02T02:09:43.174210Z" 190 | }, 191 | "papermill": { 192 | "duration": 0.012474, 193 | "end_time": "2024-05-02T02:09:43.177255", 194 | "exception": false, 195 | "start_time": "2024-05-02T02:09:43.164781", 196 | "status": "completed" 197 | }, 198 | "tags": [] 199 | }, 200 | "outputs": [], 201 | "source": [ 202 | "X=dataset.drop(['Species'],axis=1).values\n", 203 | "y=dataset['Species'].values" 204 | ] 205 | }, 206 | { 207 | "cell_type": "code", 208 | "execution_count": 4, 209 | "id": "45fc5453", 210 | "metadata": { 211 | "execution": { 212 | "iopub.execute_input": "2024-05-02T02:09:43.185940Z", 213 | "iopub.status.busy": "2024-05-02T02:09:43.185325Z", 214 | "iopub.status.idle": "2024-05-02T02:09:43.201754Z", 215 | "shell.execute_reply": "2024-05-02T02:09:43.200541Z" 216 | }, 217 | "papermill": { 218 | "duration": 0.023837, 219 | "end_time": "2024-05-02T02:09:43.204570", 220 | "exception": false, 221 | "start_time": "2024-05-02T02:09:43.180733", 222 | "status": "completed" 223 | }, 224 | "tags": [] 225 | }, 226 | "outputs": [], 227 | "source": [ 228 | "class Perceptron():\n", 229 | " def __init__(self,n_iterators=50,batch_size=100000,lr=0.01):\n", 230 | " self.n_iterators=n_iterators#迭代多少次\n", 231 | " self.batch_size=batch_size#用迭代算法每次传入的批次数量\n", 232 | " self.lr=lr#学习率\n", 233 | " \n", 234 | " def fit(self,train_X,train_y):\n", 235 | " \"\"\"\n", 236 | " train_X.shape:(num_data,num_features)\n", 237 | " train_y.shape:(num_data,y.shape[1])\n", 238 | " self.W.shape:(num_features,y.shape[1])\n", 239 | " self.b.shape:(1,y.shape[1])\n", 240 | " \"\"\"\n", 241 | " if len(train_y.shape)==1:\n", 242 | " train_y=train_y.reshape(-1,1)\n", 243 | " self.W=np.random.randn(train_X.shape[1],train_y.shape[1])\n", 244 | " self.b=np.random.randn(1,train_y.shape[1])\n", 245 | " for iterator in range(self.n_iterators): \n", 246 | " random_number=np.arange(len(train_X))\n", 247 | " np.random.shuffle(random_number)\n", 248 | " train_X=train_X[random_number]\n", 249 | " train_y=train_y[random_number]\n", 250 | " for idx in range(0,len(train_X),self.batch_size):\n", 251 | " train_X1=train_X[idx:idx+self.batch_size]\n", 252 | " train_y1=train_y[idx:idx+self.batch_size]\n", 253 | " train_pred=train_X1.dot(self.W)+self.b\n", 254 | " temp_b=np.tile(self.b,(train_X1.shape[0],1))\n", 255 | " #更新参数\n", 256 | " self.W=self.W-2*self.lr*(train_X1.T).dot(train_pred-train_y1)/len(train_X1)\n", 257 | " self.b=self.b-2*self.lr*np.mean(train_pred-train_y1,axis=0)\n", 258 | "\n", 259 | " def predict(self,test_X):\n", 260 | " test_pred=np.zeros((len(test_X),self.b.shape[1]))\n", 261 | " for idx in range(0,len(test_X),self.batch_size):\n", 262 | " test_X1=test_X[idx:idx+self.batch_size]\n", 263 | " test_pred[idx:idx+len(test_X1)]=test_X1.dot(self.W)+self.b\n", 264 | " return np.where(test_pred.reshape(-1)>=0,1,-1)" 265 | ] 266 | }, 267 | { 268 | "cell_type": "code", 269 | "execution_count": 5, 270 | "id": "0c8ccd87", 271 | "metadata": { 272 | "execution": { 273 | "iopub.execute_input": "2024-05-02T02:09:43.213386Z", 274 | "iopub.status.busy": "2024-05-02T02:09:43.212998Z", 275 | "iopub.status.idle": "2024-05-02T02:09:43.225009Z", 276 | "shell.execute_reply": "2024-05-02T02:09:43.223524Z" 277 | }, 278 | "papermill": { 279 | "duration": 0.019111, 280 | "end_time": "2024-05-02T02:09:43.227292", 281 | "exception": false, 282 | "start_time": "2024-05-02T02:09:43.208181", 283 | "status": "completed" 284 | }, 285 | "tags": [] 286 | }, 287 | "outputs": [ 288 | { 289 | "name": "stdout", 290 | "output_type": "stream", 291 | "text": [ 292 | "accuracy:1.0\n" 293 | ] 294 | } 295 | ], 296 | "source": [ 297 | "model=Perceptron()\n", 298 | "model.fit(X,y)\n", 299 | "y_pred=model.predict(X)\n", 300 | "print(f\"accuracy:{np.mean(y==y_pred)}\")" 301 | ] 302 | } 303 | ], 304 | "metadata": { 305 | "kaggle": { 306 | "accelerator": "none", 307 | "dataSources": [ 308 | { 309 | "datasetId": 19, 310 | "sourceId": 420, 311 | "sourceType": "datasetVersion" 312 | } 313 | ], 314 | "dockerImageVersionId": 30698, 315 | "isGpuEnabled": false, 316 | "isInternetEnabled": true, 317 | "language": "python", 318 | "sourceType": "notebook" 319 | }, 320 | "kernelspec": { 321 | "display_name": "Python 3", 322 | "language": "python", 323 | "name": "python3" 324 | }, 325 | "language_info": { 326 | "codemirror_mode": { 327 | "name": "ipython", 328 | "version": 3 329 | }, 330 | "file_extension": ".py", 331 | "mimetype": "text/x-python", 332 | "name": "python", 333 | "nbconvert_exporter": "python", 334 | "pygments_lexer": "ipython3", 335 | "version": "3.10.13" 336 | }, 337 | "papermill": { 338 | "default_parameters": {}, 339 | "duration": 4.562226, 340 | "end_time": "2024-05-02T02:09:43.752025", 341 | "environment_variables": {}, 342 | "exception": null, 343 | "input_path": "__notebook__.ipynb", 344 | "output_path": "__notebook__.ipynb", 345 | "parameters": {}, 346 | "start_time": "2024-05-02T02:09:39.189799", 347 | "version": "2.5.0" 348 | } 349 | }, 350 | "nbformat": 4, 351 | "nbformat_minor": 5 352 | } 353 | -------------------------------------------------------------------------------- /sha256 algorithm/sha256算法实现.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "2d21c605", 6 | "metadata": { 7 | "papermill": { 8 | "duration": 0.003022, 9 | "end_time": "2024-03-11T12:46:01.902263", 10 | "exception": false, 11 | "start_time": "2024-03-11T12:46:01.899241", 12 | "status": "completed" 13 | }, 14 | "tags": [] 15 | }, 16 | "source": [ 17 | "## Created by yunsuxiaozi 2024/3/11\n", 18 | "### 这里将实现sha256算法.\n", 19 | "#### github 常用命令\n", 20 | "(https://zhuanlan.zhihu.com/p/637271164?utm_id=0)\n", 21 | "\n", 22 | "git init\n", 23 | "\n", 24 | "git config user.email \"helloworld@hh.com\"\n", 25 | "\n", 26 | "git config user.name \"yunsuxiaozi\"\n", 27 | "\n", 28 | "git add .\n", 29 | "\n", 30 | "git commit -m \"sha256\"\n", 31 | "\n", 32 | "git branch -M main\n", 33 | "\n", 34 | "git remote add algorithm https://github.com/yunsuxiaozi/Implementing-algorithms-from-scratch.git\n", 35 | "\n", 36 | "git push -u algorithm main" 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "id": "ca2f5070", 42 | "metadata": { 43 | "papermill": { 44 | "duration": 0.002184, 45 | "end_time": "2024-03-11T12:46:01.907353", 46 | "exception": false, 47 | "start_time": "2024-03-11T12:46:01.905169", 48 | "status": "completed" 49 | }, 50 | "tags": [] 51 | }, 52 | "source": [ 53 | "#### 这里是循环右移的函数,比如 x=1000 0000 0000 0000 0000 0000 0000 0000 右移4位变成 0000 1000 0000 0000 0000 0000 0000 0000,即:ROTR(x,n=4)" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 1, 59 | "id": "6fe0789c", 60 | "metadata": { 61 | "execution": { 62 | "iopub.execute_input": "2024-03-11T12:46:01.913709Z", 63 | "iopub.status.busy": "2024-03-11T12:46:01.913344Z", 64 | "iopub.status.idle": "2024-03-11T12:46:01.926005Z", 65 | "shell.execute_reply": "2024-03-11T12:46:01.925050Z" 66 | }, 67 | "papermill": { 68 | "duration": 0.01898, 69 | "end_time": "2024-03-11T12:46:01.928779", 70 | "exception": false, 71 | "start_time": "2024-03-11T12:46:01.909799", 72 | "status": "completed" 73 | }, 74 | "tags": [] 75 | }, 76 | "outputs": [], 77 | "source": [ 78 | "#这是循环右移的函数.\n", 79 | "inf=0xFFFFFFFF#32位无符号整数的最大值(2^32-1)\n", 80 | "def ROTR(x, n):#Rotate Right\n", 81 | " x=x&inf#如果输入的数据太大,会限制到2^32-1的范围内.\n", 82 | " n=n%32#如果n>32,则限制到32以内的范围.\n", 83 | " #x=[a1,a2,……,a32] 则x>>n =[0,0,……,0,a1,a2,……,a32-n] \n", 84 | " #x<<(32-n) =[a32-n+1,……a32,0,0,……,0]\n", 85 | " x = (x >> n) | (x << (32 - n))\n", 86 | " return x" 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "id": "61d04b87", 92 | "metadata": { 93 | "papermill": { 94 | "duration": 0.00334, 95 | "end_time": "2024-03-11T12:46:01.935928", 96 | "exception": false, 97 | "start_time": "2024-03-11T12:46:01.932588", 98 | "status": "completed" 99 | }, 100 | "tags": [] 101 | }, 102 | "source": [ 103 | "#### sha256算法实现细节:\n", 104 | "\n", 105 | "##### 1.初始哈希值H取自自然数中前面8个素数(2,3,5,7,11,13,17,19)的平方根的小数部分, 并且取前面的32位.固定常数K,取自自然数中前面64个素数的立方根的小数部分的前32位.这里可以通过注释掉的代码进行验证.\n", 106 | "\n", 107 | "##### 2.utf-8 能够表示世界上几乎所有的字符系统,将字符串表示成二进制的数字,因为计算机只能处理数字.\n", 108 | "\n", 109 | "##### 3.数据的padding.由于之后对数据需要按512位分块处理,所以需要将数据padding成512位的倍数.字符串本身的信息占位为$len(binaries)*8$,b'\\x80' 是8位,b'\\x00'\\*(64\\*chunks-len(binaries)-1-8) 是8\\*(64\\*chunks-len(binaries)-1-8)位,最后的字符串的长度信息(这里不是字符串的信息)为64位(2^64-1),计算可以发现得到的M为512的倍数.\n", 110 | "\n", 111 | "##### 4.最后对每个chunk进行处理,先将M存储进W[0:16],进行一大堆逻辑运算的操作将字符串的信息进行混合,然后将字符串的信息和初始哈希值的信息进行交互得到混合的信息,我没有仔细思考过这个算法是为什么这样设计的,目前我感觉只是通过复杂性保证了安全性.\n", 112 | "\n", 113 | "##### 如果还有其他细节,读者可以看代码理解." 114 | ] 115 | }, 116 | { 117 | "cell_type": "code", 118 | "execution_count": 2, 119 | "id": "912d8f0a", 120 | "metadata": { 121 | "execution": { 122 | "iopub.execute_input": "2024-03-11T12:46:01.945558Z", 123 | "iopub.status.busy": "2024-03-11T12:46:01.944891Z", 124 | "iopub.status.idle": "2024-03-11T12:46:01.963197Z", 125 | "shell.execute_reply": "2024-03-11T12:46:01.962013Z" 126 | }, 127 | "papermill": { 128 | "duration": 0.026647, 129 | "end_time": "2024-03-11T12:46:01.966259", 130 | "exception": false, 131 | "start_time": "2024-03-11T12:46:01.939612", 132 | "status": "completed" 133 | }, 134 | "tags": [] 135 | }, 136 | "outputs": [], 137 | "source": [ 138 | "def sha_256(origin_str=''):\n", 139 | " #初始哈希值取自自然数中前面8个素数(2,3,5,7,11,13,17,19)的平方根的小数部分, 并且取前面的32位.\n", 140 | " H = [0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19]\n", 141 | " # prime=[2,3,5,7,11,13,17,19]\n", 142 | " # for idx in range(len(prime)):\n", 143 | " # num=(prime[idx])**(1/2)\n", 144 | " # dot=num-int(num)\n", 145 | " # print(dot,H[idx]/2**32)\n", 146 | " \n", 147 | " #固定常数,取自自然数中前面64个素数的立方根的小数部分的前32位\n", 148 | " K = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n", 149 | " 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n", 150 | " 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n", 151 | " 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n", 152 | " 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n", 153 | " 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n", 154 | " 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n", 155 | " 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2]\n", 156 | " \n", 157 | " # prime=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29,\n", 158 | " # 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,\n", 159 | " # 73, 79, 83, 89, 97, 101, 103, 107, 109, 113,\n", 160 | " # 127, 131, 137, 139, 149, 151, 157, 163, 167, 173,\n", 161 | " # 179, 181, 191, 193, 197, 199, 211, 223, 227, 229]\n", 162 | " # for idx in range(len(prime)):\n", 163 | " # num=(prime[idx])**(1/3)\n", 164 | " # dot=num-int(num)\n", 165 | " # print(dot,K[idx]/2**32)\n", 166 | " \n", 167 | " #utf-8 能够表示世界上几乎所有的字符系统.\n", 168 | " binaries = origin_str.encode('utf8')\n", 169 | " \n", 170 | " \"\"\"\n", 171 | " \\x80(16进制)=128(10进制)=1000 0000(2进制,8位)\n", 172 | " b'\\x00'=00000000(2进制 8位)\n", 173 | " len(binaries)是字节串的长度,即有多少字节,*8是每个字节由8位组成,转换成位长度\n", 174 | " to_bytes(8)转换成8字节或者说64位的字节串.byteorder='big'是大端字节序(就是从头到尾存储).\n", 175 | "\n", 176 | " 位长度: len(binaries)*8+8位+8位*(64-len(binaries)-1-8)+64位=512.\n", 177 | "\n", 178 | " \"\"\"\n", 179 | " chunks=1#M是512的多少倍\n", 180 | "\n", 181 | " while 64*chunks-len(binaries)-9<0:\n", 182 | " chunks+=1\n", 183 | " #M是512的整数倍\n", 184 | " M = binaries + b'\\x80' + b'\\x00'*(64*chunks-len(binaries)-1-8) + (len(binaries)<<3).to_bytes(8, byteorder='big')\n", 185 | " \n", 186 | " for chunk in range(chunks):\n", 187 | " M_copy=M[chunk*64:(chunk+1)*64]\n", 188 | " W = [0] * 64#用于存储16个32位字(每个字占用4个字节),初始化为0.\n", 189 | " #W[0]~W[15] 这里已经把 这个chunk的二进制转成整数\n", 190 | " for t in range(0, 16):\n", 191 | " W[t] = M_copy[t*4:(t+1)*4]#4*8=32位长度.\n", 192 | " #W[t]转成16进制再转成10进制.\n", 193 | " W[t] = int(W[t].hex(), 16)#2^32的整数.\n", 194 | "\n", 195 | " for t in range(16, 64):\n", 196 | " #^异或,位上数字相同为0,不同为1.它可以有效地混合数据,使得输出对输入的变化非常敏感\n", 197 | " #ROTR:这种操作有助于打乱数据,使得最终的哈希值更加均匀分布,从而提高安全性.\n", 198 | " # >> 这种操作进一步增加了数据的混合,有助于提高哈希函数的抗碰撞性。\n", 199 | " S1 = ROTR(W[t - 2], 17) ^ ROTR(W[t - 2], 19) ^ (W[t - 2]>>10)\n", 200 | " S0 = ROTR(W[t - 15], 7) ^ ROTR(W[t - 15], 18) ^ (W[t - 15]>>3)\n", 201 | " #这么多大数求和, 压缩为8位 & 0xFFFFFFFF\n", 202 | " W[t] = (S1+W[t-7]+S0+W[t-16]) & inf\n", 203 | " # 为什么要进行压缩?因为运算的时候超过8位16进制数字了\n", 204 | " # 压缩的目的是去掉8位前多余的数值\n", 205 | "\n", 206 | " a,b,c,d,e,f,g,h=H#取出初始哈希值\n", 207 | "\n", 208 | " for t in range(0, 64):\n", 209 | " S1 = ROTR(e, 6) ^ ROTR(e, 11) ^ ROTR(e, 25)\n", 210 | " Ch = (e & f) ^ ((~e) & g)\n", 211 | " S0 = ROTR(a, 2) ^ ROTR(a, 13) ^ ROTR(a, 22)\n", 212 | " Maj = (a & b) ^ (a & c) ^ (b & c)\n", 213 | " T1 = h + S1 + Ch + K[t] + W[t]\n", 214 | " T2 = S0 + Maj\n", 215 | " h = g\n", 216 | " g = f\n", 217 | " f = e\n", 218 | " e = (d + T1) & inf\n", 219 | " d = c\n", 220 | " c = b\n", 221 | " b = a\n", 222 | " a = (T1 + T2) & inf\n", 223 | "\n", 224 | " H[0] = a + H[0] & inf\n", 225 | " H[1] = b + H[1] & inf\n", 226 | " H[2] = c + H[2] & inf\n", 227 | " H[3] = d + H[3] & inf\n", 228 | " H[4] = e + H[4] & inf\n", 229 | " H[5] = f + H[5] & inf\n", 230 | " H[6] = g + H[6] & inf\n", 231 | " H[7] = h + H[7] & inf\n", 232 | " sha256 = ''\n", 233 | " for idx in range(len(H)):\n", 234 | " #将整数转换成4个字节(4*8=32位)的二进制数据,然后再转成十六进制数据(hex)\n", 235 | " sha256 = sha256 + H[idx].to_bytes(4, byteorder='big').hex()\n", 236 | " return sha256" 237 | ] 238 | }, 239 | { 240 | "cell_type": "markdown", 241 | "id": "62ca8a55", 242 | "metadata": { 243 | "papermill": { 244 | "duration": 0.003582, 245 | "end_time": "2024-03-11T12:46:01.973732", 246 | "exception": false, 247 | "start_time": "2024-03-11T12:46:01.970150", 248 | "status": "completed" 249 | }, 250 | "tags": [] 251 | }, 252 | "source": [ 253 | "##### 算法的检验:算法的检验比较简单粗暴,就是随机生成一大堆数据,用手写的算法和标准库的算法进行比较,如果准确率为1的话就没有问题了.目前在小范围测试是没有问题的." 254 | ] 255 | }, 256 | { 257 | "cell_type": "code", 258 | "execution_count": 3, 259 | "id": "837a4a20", 260 | "metadata": { 261 | "execution": { 262 | "iopub.execute_input": "2024-03-11T12:46:01.983536Z", 263 | "iopub.status.busy": "2024-03-11T12:46:01.982505Z", 264 | "iopub.status.idle": "2024-03-11T12:46:17.862531Z", 265 | "shell.execute_reply": "2024-03-11T12:46:17.861279Z" 266 | }, 267 | "papermill": { 268 | "duration": 15.887331, 269 | "end_time": "2024-03-11T12:46:17.864852", 270 | "exception": false, 271 | "start_time": "2024-03-11T12:46:01.977521", 272 | "status": "completed" 273 | }, 274 | "tags": [] 275 | }, 276 | "outputs": [ 277 | { 278 | "name": "stdout", 279 | "output_type": "stream", 280 | "text": [ 281 | "accuracy:1.0\n" 282 | ] 283 | } 284 | ], 285 | "source": [ 286 | "import random#用于生成随机数的库\n", 287 | "import hashlib#使用哈希算法对数据加密的库\n", 288 | "seed=2024\n", 289 | "random.seed(seed)\n", 290 | "num_string=10000\n", 291 | "char_num=\"abcdefghijklmnopqrstuvwxyz0123456789\"#可供选择的字符是a~z加上数字\n", 292 | "random_strings = []#存储随机生成的字符串\n", 293 | "\n", 294 | "for _ in range(num_string):\n", 295 | " str_len = random.randint(10, 500) #生成长度为10到500的字符\n", 296 | " random_string = ''.join(random.choices(char_num, k=str_len))\n", 297 | " random_strings.append(random_string)\n", 298 | "true_cnt=0#手写算法正确的个数\n", 299 | "for idx in range(num_string):\n", 300 | " origin_str=random_strings[idx]\n", 301 | " #hashlib.sha256(binaries).hexdigest() 对二进制数据binaries经过sha-256算法计算后的十六进制哈希值\n", 302 | " if sha_256(origin_str) == hashlib.sha256(origin_str.encode('utf8')).hexdigest():\n", 303 | " true_cnt+=1\n", 304 | "print(f\"accuracy:{true_cnt/num_string}\")" 305 | ] 306 | } 307 | ], 308 | "metadata": { 309 | "kaggle": { 310 | "accelerator": "none", 311 | "dataSources": [ 312 | { 313 | "datasetId": 4477849, 314 | "sourceId": 7676268, 315 | "sourceType": "datasetVersion" 316 | } 317 | ], 318 | "dockerImageVersionId": 30664, 319 | "isGpuEnabled": false, 320 | "isInternetEnabled": true, 321 | "language": "python", 322 | "sourceType": "notebook" 323 | }, 324 | "kernelspec": { 325 | "display_name": "Python 3 (ipykernel)", 326 | "language": "python", 327 | "name": "python3" 328 | }, 329 | "language_info": { 330 | "codemirror_mode": { 331 | "name": "ipython", 332 | "version": 3 333 | }, 334 | "file_extension": ".py", 335 | "mimetype": "text/x-python", 336 | "name": "python", 337 | "nbconvert_exporter": "python", 338 | "pygments_lexer": "ipython3", 339 | "version": "3.8.5" 340 | }, 341 | "papermill": { 342 | "default_parameters": {}, 343 | "duration": 19.166671, 344 | "end_time": "2024-03-11T12:46:18.287762", 345 | "environment_variables": {}, 346 | "exception": null, 347 | "input_path": "__notebook__.ipynb", 348 | "output_path": "__notebook__.ipynb", 349 | "parameters": {}, 350 | "start_time": "2024-03-11T12:45:59.121091", 351 | "version": "2.5.0" 352 | } 353 | }, 354 | "nbformat": 4, 355 | "nbformat_minor": 5 356 | } 357 | -------------------------------------------------------------------------------- /SM4algorithm/sm4-algorithm.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "ecd00fab", 6 | "metadata": { 7 | "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", 8 | "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5", 9 | "papermill": { 10 | "duration": 0.003479, 11 | "end_time": "2024-03-21T12:18:55.519081", 12 | "exception": false, 13 | "start_time": "2024-03-21T12:18:55.515602", 14 | "status": "completed" 15 | }, 16 | "tags": [] 17 | }, 18 | "source": [ 19 | "## Created by yunsuxiaozi 2024/4/7\n", 20 | "\n", 21 | "### 这里主要实现的是SM4算法,这个算法和之前实现的sha256和SM3算法差别有点大.具体实现的代码可以参考PDF来实现,PDF中没有提到对字符串进行padding的方法,网上查到主流的算法有PKCS5padding和PKCS7padding算法,这里实现的是PKCS7padding.笔者对于算法也没有深入了解,目前只是实现了算法.本文后面也有验证我的算法正确性的方法.\n", 22 | "\n", 23 | "### 首先是我实现的算法,这里不多做解释." 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 1, 29 | "id": "7b2ecdd0", 30 | "metadata": { 31 | "execution": { 32 | "iopub.execute_input": "2024-03-21T12:18:55.527735Z", 33 | "iopub.status.busy": "2024-03-21T12:18:55.527348Z", 34 | "iopub.status.idle": "2024-03-21T12:18:55.565180Z", 35 | "shell.execute_reply": "2024-03-21T12:18:55.563881Z" 36 | }, 37 | "papermill": { 38 | "duration": 0.045799, 39 | "end_time": "2024-03-21T12:18:55.567934", 40 | "exception": false, 41 | "start_time": "2024-03-21T12:18:55.522135", 42 | "status": "completed" 43 | }, 44 | "tags": [] 45 | }, 46 | "outputs": [], 47 | "source": [ 48 | "\"\"\"\n", 49 | "^(按位与)的python符号是&.\n", 50 | "√(按位或)的python符号是|\n", 51 | "⊕(异或)的python符号是^.\n", 52 | "\"\"\"\n", 53 | "inf=0xFFFFFFFF#32位无符号整数的最大值(2^32-1)\n", 54 | "#循环左移 x=[a1,a2,……,a32] \n", 55 | "def ROTL(x, n):\n", 56 | " x=x&inf#如果输入的数据太大,会限制到2^32-1的范围内.\n", 57 | " n=n%32#如果n>32,则限制到32以内的范围.\n", 58 | " #x=[a1,a2,……,a32] 则x>>(32-n) =[0,0,……,0,a1,a2,……,an] \n", 59 | " #x<<(n) =[an+1,……a32,0,0,……,0]\n", 60 | " x = ((x << n) | (x >> (32 - n)))&inf\n", 61 | " return x\n", 62 | "def T(x):\n", 63 | " x=x&inf\n", 64 | " return L(tau(x))\n", 65 | "def T_(x):\n", 66 | " x=x&inf\n", 67 | " return L_(tau(x)) \n", 68 | "#系统参数FK\n", 69 | "FK=[0xA3B1BAC6,0x56AA3350,0x677D9197,0xB27022DC]\n", 70 | "#S盒\n", 71 | "s_box=['d690e9fecce13db716b614c228fb2c05',\n", 72 | " '2b679a762abe04c3aa44132649860699',\n", 73 | " '9c4250f491ef987a33540b43edcfac62',\n", 74 | " 'e4b31ca9c908e89580df94fa758f3fa6',\n", 75 | " '4707a7fcf37317ba83593c19e6854fa8',\n", 76 | " '686b81b27164da8bf8eb0f4b70569d35',\n", 77 | " '1e240e5e6358d1a225227c3b01217887',\n", 78 | " 'd40046579fd327524c3602e7a0c4c89e',\n", 79 | " 'eabf8ad240c738b5a3f7f2cef96115a1',\n", 80 | " 'e0ae5da49b341a55ad933230f58cb1e3',\n", 81 | " '1df6e22e8266ca60c02923ab0d534e6f',\n", 82 | " 'd5db3745defd8e2f03ff6a726d6c5b51',\n", 83 | " '8d1baf92bbddbc7f11d95c411f105ad8',\n", 84 | " '0ac13188a5cd7bbd2d74d012b8e5b4b0',\n", 85 | " '8969974a0c96777e65b9f109c56ec684',\n", 86 | " '18f07dec3adc4d2079ee5f3ed7cb3948']\n", 87 | "\n", 88 | "# ck=[]\n", 89 | "# for i in range(32):\n", 90 | "# cki=[]\n", 91 | "# for j in range(4):\n", 92 | "# cki.append('{:02x}'.format(((4*i+j)*7)%256))\n", 93 | "# ck.append(int(''.join(cki),16))\n", 94 | "#固定参数CK的取值方法\n", 95 | "CK=[0x00070e15, 0x1c232a31, 0x383f464d, 0x545b6269, \n", 96 | "0x70777e85, 0x8c939aa1, 0xa8afb6bd, 0xc4cbd2d9, \n", 97 | "0xe0e7eef5, 0xfc030a11, 0x181f262d, 0x343b4249, \n", 98 | "0x50575e65, 0x6c737a81, 0x888f969d, 0xa4abb2b9, \n", 99 | "0xc0c7ced5, 0xdce3eaf1, 0xf8ff060d, 0x141b2229, \n", 100 | "0x30373e45, 0x4c535a61, 0x686f767d, 0x848b9299, \n", 101 | "0xa0a7aeb5, 0xbcc3cad1, 0xd8dfe6ed, 0xf4fb0209, \n", 102 | "0x10171e25, 0x2c333a41, 0x484f565d, 0x646b7279]\n", 103 | "def L(B):\n", 104 | " B=B&inf\n", 105 | " return B^ROTL(B,2)^ROTL(B,10)^ROTL(B,18)^ROTL(B,24)\n", 106 | "#L'(B)函数\n", 107 | "def L_(B):#13+23=36\n", 108 | " B=B&inf\n", 109 | " return B^ROTL(B,13)^ROTL(B,23)\n", 110 | "\n", 111 | "block_size=32#origin_str应该以128比特为块进行处理,先要进行padding.\n", 112 | "\n", 113 | "def tau(A):\n", 114 | " A=A&inf\n", 115 | " A='{:032b}'.format(A)\n", 116 | " b=\"\"\n", 117 | " for idx in range(4):\n", 118 | " a_idx=A[idx*8:(idx+1)*8]\n", 119 | " a_idx1,a_idx2=int(a_idx[:4], 2),int(a_idx[4:],2)\n", 120 | " b+=(s_box[a_idx1][2*a_idx2:2*(a_idx2+1)])\n", 121 | " return int(b,16)\n", 122 | " \n", 123 | "#轮函数F\n", 124 | "def F(x0,x1,x2,x3,rk):\n", 125 | " x0=x0&inf\n", 126 | " x1=x1&inf\n", 127 | " x2=x2&inf\n", 128 | " x3=x3&inf\n", 129 | " rk=rk&inf\n", 130 | " return x0^T(x1^x2^x3^rk)\n", 131 | "def round_key(MK):\n", 132 | " K=[0]*36\n", 133 | " K[0],K[1]=int(MK[:block_size//4],16)^FK[0],int(MK[block_size//4:block_size//2], 16)^FK[1]\n", 134 | " K[2],K[3]=int(MK[block_size//2:3*block_size//4],16)^FK[2],int(MK[3*block_size//4:], 16)^FK[3]\n", 135 | " #前4个没有问题\n", 136 | " for idx in range(32):\n", 137 | " K[idx+4]=(K[idx]^T_(K[idx+1]^K[idx+2]^K[idx+3]^CK[idx]))\n", 138 | " return K[4:]\n", 139 | " \n", 140 | "#这里实现SM4算法的主体框架,SM4算法分组长度为128比特,即16个字节,每个字节对应2个十六进制字符.即32个字符为一组.\n", 141 | "def SM4_encode(key='0123456789abcdeffedcba9876543210',origin_str=\"hello\"):#加密秘钥和明文的16进制表示\n", 142 | " padding_size=(block_size-2*len(origin_str)%block_size)%block_size//2\n", 143 | " origin_str=(origin_str+bytes([padding_size]*padding_size)).decode('utf-8') \n", 144 | " encode_str=\"\"\n", 145 | " for idx in range(0,len(origin_str),block_size):\n", 146 | " group=origin_str[idx:idx+block_size]#一组128比特的数据\n", 147 | " X=[0]*36\n", 148 | " X[0],X[1]=int(group[:block_size//4],16),int(group[block_size//4:block_size//2],16)\n", 149 | " X[2],X[3]=int(group[block_size//2:3*block_size//4], 16),int(group[3*block_size//4:], 16)\n", 150 | " rk=round_key(key)\n", 151 | " for idx in range(len(rk)):\n", 152 | " X[idx+4]=F(X[idx],X[idx+1],X[idx+2],X[idx+3],rk[idx])\n", 153 | " y=X[32:][::-1]\n", 154 | " for i in range(len(y)):\n", 155 | " y[i]=str(hex(y[i]))[2:]\n", 156 | " if len(y[i])<8:\n", 157 | " y[i]=(8-len(y[i]))*\"0\"+y[i]\n", 158 | " encode_str+=\"\".join(y)\n", 159 | " return encode_str\n", 160 | "def SM4_decode(key='0123456789abcdeffedcba9876543210',origin_str=\"hello\"):#加密秘钥和明文的16进制表示\n", 161 | " decode_str=\"\"\n", 162 | " for idx in range(0,len(origin_str),block_size):\n", 163 | " group=origin_str[idx:idx+block_size]#一组128比特的数据\n", 164 | " X=[0]*36\n", 165 | " X[0],X[1]=int(group[:block_size//4],16),int(group[block_size//4:block_size//2],16)\n", 166 | " X[2],X[3]=int(group[block_size//2:3*block_size//4], 16),int(group[3*block_size//4:], 16)\n", 167 | " rk=round_key(key)\n", 168 | " for idx in range(len(rk)):\n", 169 | " X[idx+4]=F(X[idx],X[idx+1],X[idx+2],X[idx+3],rk[-1-idx])\n", 170 | " y=X[32:][::-1]\n", 171 | " for i in range(len(y)):\n", 172 | " y[i]=str(hex(y[i]))[2:]\n", 173 | " if len(y[i])<8:\n", 174 | " y[i]=(8-len(y[i]))*\"0\"+y[i]\n", 175 | " decode_str+=\"\".join(y)\n", 176 | " return decode_str" 177 | ] 178 | }, 179 | { 180 | "cell_type": "markdown", 181 | "id": "533cf836", 182 | "metadata": { 183 | "papermill": { 184 | "duration": 0.002605, 185 | "end_time": "2024-03-21T12:18:55.573649", 186 | "exception": false, 187 | "start_time": "2024-03-21T12:18:55.571044", 188 | "status": "completed" 189 | }, 190 | "tags": [] 191 | }, 192 | "source": [ 193 | "### 这次没有随机生成一大批样例和标准的算法框架比较看输出结果是否相同,因为没找到现成的框架.问了一些AI也没给出满意的答案.\n", 194 | "\n", 195 | "### 这里验证算法准确性的方法是通过和我学习的代码进行比较,用PDF的样例加密1000000次,看输出结果是否相同.\n", 196 | "\n", 197 | "### 学习链接如下:https://blog.csdn.net/qq_33439662/article/details/125461587\n" 198 | ] 199 | }, 200 | { 201 | "cell_type": "code", 202 | "execution_count": 2, 203 | "id": "08e4228b", 204 | "metadata": { 205 | "execution": { 206 | "iopub.execute_input": "2024-03-21T12:18:55.581356Z", 207 | "iopub.status.busy": "2024-03-21T12:18:55.580950Z", 208 | "iopub.status.idle": "2024-03-21T12:18:55.604386Z", 209 | "shell.execute_reply": "2024-03-21T12:18:55.603424Z" 210 | }, 211 | "papermill": { 212 | "duration": 0.030125, 213 | "end_time": "2024-03-21T12:18:55.606579", 214 | "exception": false, 215 | "start_time": "2024-03-21T12:18:55.576454", 216 | "status": "completed" 217 | }, 218 | "tags": [] 219 | }, 220 | "outputs": [], 221 | "source": [ 222 | "def sbox(a):\n", 223 | " s=['d690e9fecce13db716b614c228fb2c05',\n", 224 | " '2b679a762abe04c3aa44132649860699',\n", 225 | " '9c4250f491ef987a33540b43edcfac62',\n", 226 | " 'e4b31ca9c908e89580df94fa758f3fa6',\n", 227 | " '4707a7fcf37317ba83593c19e6854fa8',\n", 228 | " '686b81b27164da8bf8eb0f4b70569d35',\n", 229 | " '1e240e5e6358d1a225227c3b01217887',\n", 230 | " 'd40046579fd327524c3602e7a0c4c89e',\n", 231 | " 'eabf8ad240c738b5a3f7f2cef96115a1',\n", 232 | " 'e0ae5da49b341a55ad933230f58cb1e3',\n", 233 | " '1df6e22e8266ca60c02923ab0d534e6f',\n", 234 | " 'd5db3745defd8e2f03ff6a726d6c5b51',\n", 235 | " '8d1baf92bbddbc7f11d95c411f105ad8',\n", 236 | " '0ac13188a5cd7bbd2d74d012b8e5b4b0',\n", 237 | " '8969974a0c96777e65b9f109c56ec684',\n", 238 | " '18f07dec3adc4d2079ee5f3ed7cb3948']\n", 239 | " b=''\n", 240 | " for i in range(4):\n", 241 | " r=int(a[2*i],16)\n", 242 | " c=int(a[2*i+1],16)\n", 243 | " b=b+s[r][c*2:(c+1)*2]\n", 244 | " return int(b,16)\n", 245 | "\n", 246 | "def cl(x,i):#Cycle left\n", 247 | " x='{:032b}'.format(x)\n", 248 | " i=i%32\n", 249 | " x=x[i:]+x[:i]\n", 250 | " return int(x,2)\n", 251 | "\n", 252 | "fk=[int('A3B1BAC6',16),int('56AA3350',16),int('677D9197',16),int('B27022DC',16)]\n", 253 | "ck=[]\n", 254 | "for i in range(32):\n", 255 | " cki=[]\n", 256 | " for j in range(4):\n", 257 | " cki.append('{:02x}'.format(((4*i+j)*7)%256))\n", 258 | " ck.append(int(''.join(cki),16))\n", 259 | "'''\n", 260 | "ck=['00070e15','1c232a31','383f464d','545b6269',\n", 261 | " '70777e85','8c939aa1','a8afb6bd','c4cbd2d9',\n", 262 | " 'e0e7eef5','fc030a11','181f262d','343b4249',\n", 263 | " '50575e65','6c737a81','888f969d','a4abb2b9',\n", 264 | " 'c0c7ced5','dce3eaf1','f8ff060d','141b2229',\n", 265 | " '30373e45','4c535a61','686f767d','848b9299',\n", 266 | " 'a0a7aeb5','bcc3cad1','d8dfe6ed','f4fb0209',\n", 267 | " '10171e25','2c333a41','484f565d','646b7279']\n", 268 | "'''\n", 269 | "def f(x,rk,i):\n", 270 | " return x[i]^t(x[i+1]^x[i+2]^x[i+3]^rk)\n", 271 | "\n", 272 | "def t(x):\n", 273 | " return l(tau(x))\n", 274 | "def t_(x):#t'\n", 275 | " return l_(tau(x))\n", 276 | "\n", 277 | "def tau(a):\n", 278 | " a='{:08x}'.format(a)\n", 279 | " b=sbox(a)\n", 280 | " return b\n", 281 | "\n", 282 | "def l(b):\n", 283 | " c=b^cl(b, 2)^cl(b, 10)^cl(b, 18)^cl(b, 24)\n", 284 | " return c\n", 285 | "def l_(b):#l'\n", 286 | " c=b^cl(b, 13)^cl(b, 23)\n", 287 | " return c\n", 288 | "\n", 289 | "def enc(x,mk):\n", 290 | " if len(x)!=32:\n", 291 | " x=(32-len(x))*'0'+x\n", 292 | " p=[x[:8],x[8:16],x[16:24],x[24:]]\n", 293 | " x=p\n", 294 | " for i in range(len(x)):\n", 295 | " x[i]=int(x[i],16)\n", 296 | " rk=kea(mk, fk, ck)\n", 297 | " for i in range(32):\n", 298 | " x.append(f(x,rk[i],i))\n", 299 | " y=x[32:][::-1]\n", 300 | " for i in range(len(y)):\n", 301 | " y[i]='{:08x}'.format(y[i])\n", 302 | " y=''.join(y)\n", 303 | " return y\n", 304 | "\n", 305 | "def kea(mk,fk,ck):#Key extension algorithm\n", 306 | " if len(mk)!=32:\n", 307 | " mk=(32-len(mk))*'0'+mk\n", 308 | " p=[mk[:8],mk[8:16],mk[16:24],mk[24:]]\n", 309 | " mk=p\n", 310 | " for i in range(len(mk)):\n", 311 | " mk[i]=int(mk[i],16)\n", 312 | " k=[]\n", 313 | " for i in range(4):\n", 314 | " k.append(mk[i]^fk[i])\n", 315 | " for i in range(32):\n", 316 | " k.append(k[i]^t_(k[i+1]^k[i+2]^k[i+3]^ck[i]))\n", 317 | " rk=k[4:]\n", 318 | " return rk" 319 | ] 320 | }, 321 | { 322 | "cell_type": "code", 323 | "execution_count": 3, 324 | "id": "aa56562a", 325 | "metadata": { 326 | "execution": { 327 | "iopub.execute_input": "2024-03-21T12:18:55.614854Z", 328 | "iopub.status.busy": "2024-03-21T12:18:55.614238Z", 329 | "iopub.status.idle": "2024-03-21T12:21:16.504866Z", 330 | "shell.execute_reply": "2024-03-21T12:21:16.503581Z" 331 | }, 332 | "papermill": { 333 | "duration": 140.901269, 334 | "end_time": "2024-03-21T12:21:16.510905", 335 | "exception": false, 336 | "start_time": "2024-03-21T12:18:55.609636", 337 | "status": "completed" 338 | }, 339 | "scrolled": true, 340 | "tags": [] 341 | }, 342 | "outputs": [ 343 | { 344 | "name": "stdout", 345 | "output_type": "stream", 346 | "text": [ 347 | "my algorithm\n", 348 | "other algorithm\n", 349 | "accuracy:1.0\n", 350 | "my_algorithm:595298c7c6fd271f0402f804c33d3f66,other_algorithm:595298c7c6fd271f0402f804c33d3f66\n" 351 | ] 352 | } 353 | ], 354 | "source": [ 355 | "num_epochs=1000000#加密1000000次\n", 356 | "print(f\"my algorithm\")\n", 357 | "my_list=[]#我自己加密的结果\n", 358 | "origin_str=b'0123456789abcdeffedcba9876543210'\n", 359 | "for i in range(num_epochs):\n", 360 | " origin_str=SM4_encode(key='0123456789abcdeffedcba9876543210',origin_str=origin_str)\n", 361 | " my_list.append(origin_str)\n", 362 | " origin_str=origin_str.encode('utf-8')\n", 363 | "\n", 364 | "print(f\"other algorithm\")\n", 365 | "other_list=[]#别人代码的加密结果\n", 366 | "p='0123456789abcdeffedcba9876543210'\n", 367 | "for i in range(num_epochs):\n", 368 | " mk='0123456789abcdeffedcba9876543210'\n", 369 | " y=enc(p, mk)\n", 370 | " encoder_str=\"\"\n", 371 | " for j in range(4):\n", 372 | " encoder_str+=(y[j*8:(j+1)*8])\n", 373 | " p=encoder_str\n", 374 | " other_list.append(p)\n", 375 | " \n", 376 | "acc_cnt=0\n", 377 | "for i in range(num_epochs):\n", 378 | " acc_cnt+=(my_list[i]==other_list[i])\n", 379 | "print(f\"accuracy:{acc_cnt/num_epochs}\")\n", 380 | "print(f\"my_algorithm:{my_list[-1]},other_algorithm:{other_list[-1]}\")" 381 | ] 382 | }, 383 | { 384 | "cell_type": "markdown", 385 | "id": "eecc6ba7", 386 | "metadata": {}, 387 | "source": [ 388 | "### 最后来测试一下SM4的加解密算法." 389 | ] 390 | }, 391 | { 392 | "cell_type": "code", 393 | "execution_count": 4, 394 | "id": "d968c359", 395 | "metadata": {}, 396 | "outputs": [ 397 | { 398 | "data": { 399 | "text/plain": [ 400 | "'0123456789abcdeffedcba9876543210'" 401 | ] 402 | }, 403 | "execution_count": 4, 404 | "metadata": {}, 405 | "output_type": "execute_result" 406 | } 407 | ], 408 | "source": [ 409 | "key='0123456789abcdeffedcba9876543210'\n", 410 | "origin_str=b'0123456789abcdeffedcba9876543210'\n", 411 | "encode_str=SM4_encode(key=key,origin_str=origin_str).encode('utf-8')\n", 412 | "decode_str=SM4_decode(key=key,origin_str=encode_str)\n", 413 | "decode_str" 414 | ] 415 | }, 416 | { 417 | "cell_type": "code", 418 | "execution_count": null, 419 | "id": "01423e0d", 420 | "metadata": {}, 421 | "outputs": [], 422 | "source": [] 423 | } 424 | ], 425 | "metadata": { 426 | "kaggle": { 427 | "accelerator": "none", 428 | "dataSources": [ 429 | { 430 | "databundleVersionId": 7921029, 431 | "sourceId": 50160, 432 | "sourceType": "competition" 433 | } 434 | ], 435 | "dockerImageVersionId": 30673, 436 | "isGpuEnabled": false, 437 | "isInternetEnabled": true, 438 | "language": "python", 439 | "sourceType": "notebook" 440 | }, 441 | "kernelspec": { 442 | "display_name": "Python 3 (ipykernel)", 443 | "language": "python", 444 | "name": "python3" 445 | }, 446 | "language_info": { 447 | "codemirror_mode": { 448 | "name": "ipython", 449 | "version": 3 450 | }, 451 | "file_extension": ".py", 452 | "mimetype": "text/x-python", 453 | "name": "python", 454 | "nbconvert_exporter": "python", 455 | "pygments_lexer": "ipython3", 456 | "version": "3.8.5" 457 | }, 458 | "papermill": { 459 | "default_parameters": {}, 460 | "duration": 144.920909, 461 | "end_time": "2024-03-21T12:21:16.936280", 462 | "environment_variables": {}, 463 | "exception": null, 464 | "input_path": "__notebook__.ipynb", 465 | "output_path": "__notebook__.ipynb", 466 | "parameters": {}, 467 | "start_time": "2024-03-21T12:18:52.015371", 468 | "version": "2.5.0" 469 | } 470 | }, 471 | "nbformat": 4, 472 | "nbformat_minor": 5 473 | } 474 | -------------------------------------------------------------------------------- /naivebayesclassifier/naivebayesclassifier algorithm.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "e4d1cb47", 6 | "metadata": { 7 | "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", 8 | "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5", 9 | "papermill": { 10 | "duration": 0.005932, 11 | "end_time": "2024-03-26T05:55:38.957554", 12 | "exception": false, 13 | "start_time": "2024-03-26T05:55:38.951622", 14 | "status": "completed" 15 | }, 16 | "tags": [] 17 | }, 18 | "source": [ 19 | "## Created by yunsuxiaozi 2024/3/26\n", 20 | "\n", 21 | "### 在这个notebook中,我们将介绍朴素贝叶斯算法的数学原理和代码实现,并使用Kaggle上的数据集来测试算法的效果,最后和开源库的效果进行比较.\n", 22 | "\n", 23 | "## 数学原理:\n", 24 | "\n", 25 | "### 首先是$P(A|B)P(B)=P(B|A)P(A)$,直接看公式可能不舒服,我解释一下.$P(B)$是B事件发生的概率,$P(A|B)$是B事件发生的情况下A事件发生的概率.所以$P(A|B)P(B)$是A,B事件同时发生的概率.后半部分也是A,B事件同时发生的概率,故相等.\n", 26 | "\n", 27 | "### 我们可以将这个公式变成:$P(A|B)=\\frac{P(B|A)P(A)}{P(B)}$.\n", 28 | "\n", 29 | "### 我们一般用朴素贝叶斯是做分类任务的,比如我们想知道当$X=X0$时,$y=y0$的概率是多大,用公式表示就是$P(y=y0|X=X0)=\\frac{P(X=X0|y=y0)P(y=y0)}{P(X=X0)}$\n", 30 | "\n", 31 | "### 这里我们$X$的每个特征(每列)都是类别型变量,同时朴素贝叶斯是假设每个特征都是独立的,即:$P(X0[0],X0[1],……,X0[n]|y0)=P(X0[0]|y=y0)P(X0[1]|y0)……P(X0[n]|y=y0)$\n", 32 | "\n", 33 | "### 所以,$P(y=y0|X=X0)=\\frac{P(X0[0]|y=y0)P(X0[1]|y=y0)……P(X0[n]|y=y0)P(y=y0)}{P(X=X0)}$.这就是朴素贝叶斯分类器的原理.\n", 34 | "\n", 35 | "### 接下来来仔细研究一下公式每部分:\n", 36 | "\n", 37 | "- 分母是P(X=X0).这个其实是个定值,因为当训练数据确定,比如总共有2个特征,第1个特征2个类别,第2个特征3个类别,那么X的取值就有6种,X0无论是其中任意一种,$P(X=X0)=\\frac{1}{6}$.由于这个值是定值,所以在算法实现上可以去掉.\n", 38 | "\n", 39 | "- 分子中P(y=y0):这个其实就是y取某个类别的概率,这个取决于训练数据target的数据分布.\n", 40 | "\n", 41 | "- 分子中P(X0[0]|y=y0)P(X0[1]|y=y0)……P(X0[n]|y=y0):其实就是在y=y0时那些数据中X的第i个特征取到X0[i]的概率.\n", 42 | "\n", 43 | "### 在算法的实现上,P(X=X0)这部分可以去掉,还需要考虑到预测概率的归一化.最后实现算法的时候是P(y=y0|X=X0):= P(X0[0]|y=y0)P(X0[1]|y=y0)……P(X0[n]|y=y0)P(y=y0),由于是一堆概率相乘,而概率值又是0到1之间的数,所以之后的概率肯定会非常小,我们在做多分类任务的时候要考虑将概率值进行归一化,使它最终的预测概率求和等于1.这里用P/sum(P)来进行归一化.\n", 44 | "\n", 45 | "### 下面我们通过Kaggle上入门自然语言处理的比赛数据来实现算法,并和python现有库进行比较." 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "id": "4fd1ff92", 51 | "metadata": { 52 | "papermill": { 53 | "duration": 0.005128, 54 | "end_time": "2024-03-26T05:55:38.968366", 55 | "exception": false, 56 | "start_time": "2024-03-26T05:55:38.963238", 57 | "status": "completed" 58 | }, 59 | "tags": [] 60 | }, 61 | "source": [ 62 | "### 导入必要的python库,并固定随机种子,保证模型可以复现." 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 1, 68 | "id": "0244f1c4", 69 | "metadata": { 70 | "execution": { 71 | "iopub.execute_input": "2024-03-26T05:55:38.982068Z", 72 | "iopub.status.busy": "2024-03-26T05:55:38.981028Z", 73 | "iopub.status.idle": "2024-03-26T05:55:40.059558Z", 74 | "shell.execute_reply": "2024-03-26T05:55:40.058299Z" 75 | }, 76 | "papermill": { 77 | "duration": 1.088981, 78 | "end_time": "2024-03-26T05:55:40.062687", 79 | "exception": false, 80 | "start_time": "2024-03-26T05:55:38.973706", 81 | "status": "completed" 82 | }, 83 | "tags": [] 84 | }, 85 | "outputs": [], 86 | "source": [ 87 | "import pandas as pd#导入csv文件的库\n", 88 | "import numpy as np#进行矩阵运算的库\n", 89 | "import re#用于正则表达式提取\n", 90 | "import warnings#避免一些可以忽略的报错\n", 91 | "warnings.filterwarnings('ignore')#filterwarnings()方法是用于设置警告过滤器的方法,它可以控制警告信息的输出方式和级别。\n", 92 | "\n", 93 | "import random#提供了一些用于生成随机数的函数\n", 94 | "class Config():\n", 95 | " seed=2024\n", 96 | " word_count=1000#统计出现最多的几个词\n", 97 | " train_path=\"/kaggle/input/nlp-getting-started/train.csv\"\n", 98 | " test_path=\"/kaggle/input/nlp-getting-started/test.csv\"\n", 99 | "#设置随机种子,保证模型可以复现\n", 100 | "def seed_everything(seed):\n", 101 | " np.random.seed(seed)#numpy的随机种子\n", 102 | " random.seed(seed)#python内置的随机种子\n", 103 | "seed_everything(seed=Config.seed)" 104 | ] 105 | }, 106 | { 107 | "cell_type": "markdown", 108 | "id": "28eb857d", 109 | "metadata": { 110 | "papermill": { 111 | "duration": 0.005166, 112 | "end_time": "2024-03-26T05:55:40.073628", 113 | "exception": false, 114 | "start_time": "2024-03-26T05:55:40.068462", 115 | "status": "completed" 116 | }, 117 | "tags": [] 118 | }, 119 | "source": [ 120 | "### 这里是导入训练数据,并对数据进行了一些清洗." 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": 2, 126 | "id": "715bb4a1", 127 | "metadata": { 128 | "execution": { 129 | "iopub.execute_input": "2024-03-26T05:55:40.087545Z", 130 | "iopub.status.busy": "2024-03-26T05:55:40.086515Z", 131 | "iopub.status.idle": "2024-03-26T05:55:50.271395Z", 132 | "shell.execute_reply": "2024-03-26T05:55:50.267910Z" 133 | }, 134 | "papermill": { 135 | "duration": 10.195548, 136 | "end_time": "2024-03-26T05:55:50.274620", 137 | "exception": false, 138 | "start_time": "2024-03-26T05:55:40.079072", 139 | "status": "completed" 140 | }, 141 | "tags": [] 142 | }, 143 | "outputs": [ 144 | { 145 | "name": "stdout", 146 | "output_type": "stream", 147 | "text": [ 148 | "CPU times: user 3 µs, sys: 1 µs, total: 4 µs\n", 149 | "Wall time: 8.82 µs\n", 150 | "len(train_df):7613\n", 151 | "len(test_df):3263\n" 152 | ] 153 | }, 154 | { 155 | "data": { 156 | "text/html": [ 157 | "
\n", 158 | "\n", 171 | "\n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | " \n", 189 | " \n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | "
idkeywordlocationtext
00NaNNaN[happenedterrible, car, crash]
12NaNNaN[heard, earthquake, different, cities, stay, s...
23NaNNaN[isforest, fire, spot, pond, geese, fleeing, a...
39NaNNaN[apocalypse, lighting, spokane, wildfires]
411NaNNaN[typhoon, soudelor, kills, china, taiwan]
\n", 219 | "
" 220 | ], 221 | "text/plain": [ 222 | " id keyword location text\n", 223 | "0 0 NaN NaN [happenedterrible, car, crash]\n", 224 | "1 2 NaN NaN [heard, earthquake, different, cities, stay, s...\n", 225 | "2 3 NaN NaN [isforest, fire, spot, pond, geese, fleeing, a...\n", 226 | "3 9 NaN NaN [apocalypse, lighting, spokane, wildfires]\n", 227 | "4 11 NaN NaN [typhoon, soudelor, kills, china, taiwan]" 228 | ] 229 | }, 230 | "execution_count": 2, 231 | "metadata": {}, 232 | "output_type": "execute_result" 233 | } 234 | ], 235 | "source": [ 236 | "%time\n", 237 | "import nltk#Natural Language Tokens 强大的自然语言处理库\n", 238 | "from nltk.corpus import stopwords#导入英语的停用词表\n", 239 | "import re#正则表达式操作的库\n", 240 | "import emoji#处理字符串中的表情符号\n", 241 | "#去除html标签的函数\n", 242 | "def removeHTML(x):\n", 243 | " #用正则表达式提取例如

,

之类的标签\n", 244 | " html=re.compile(r'<.*?>')\n", 245 | " #用空字符串去替代这些标签.\n", 246 | " return html.sub(r'',x)\n", 247 | "#对文本数据进行数据预处理,去除对于情感分析没有用的词.\n", 248 | "def dataPreprocessing(x): \n", 249 | " #导入英文的停用词\n", 250 | " stopword = stopwords.words('english')#导入英文的停用词\n", 251 | " #将字符串转成小写字母\n", 252 | " x = x.lower()\n", 253 | " #将字符串去除html标签\n", 254 | " x = removeHTML(x)\n", 255 | " #将文本中的表情符号(emoji)转换为文本文本形式。例如,将表示笑脸的\" \"表情符号转换为\":face_with_tears_of_joy:\"。delimiters=(\" \", \" \")是分隔符.\n", 256 | " x = emoji.demojize(x, delimiters=(\" \", \" \"))\n", 257 | " #将评论中“@匀速小子”之类的字母、数字或下划线(\\w)替换成空格.\n", 258 | " x = re.sub(\"@\\w+\", '',x)\n", 259 | " #删除评论中带单引号的数字\n", 260 | " x = re.sub(\"'\\d+\", '',x)\n", 261 | " #删除评论中所有的数字\n", 262 | " x = re.sub(\"\\d+\", '',x)\n", 263 | " #删除评论中的标点符号和特征字符,将不是(^)字母、数字或下划线(\\w)或者空格(\\s)的字符替换成空格.\n", 264 | " x = re.sub(r\"[^\\w\\s]\", '',x)\n", 265 | " #删除url:http格式的\n", 266 | " x = re.sub(\"http\\w+\", '',x)\n", 267 | " #将单个的小写字母替换成空格\n", 268 | " x = re.sub(\"\\s[a-z]\\s\", '',x)\n", 269 | " #删除字符串开头和结尾的空格字符\n", 270 | " x = x.strip()\n", 271 | " #将文本分割成单词或者标点符号(tokenization)\n", 272 | " tokens=nltk.word_tokenize(x)\n", 273 | " tokens=[token for token in tokens if token not in stopword] \n", 274 | " #返回处理好的字符串\n", 275 | " return tokens\n", 276 | "train_df=pd.read_csv(Config.train_path)\n", 277 | "train_df['text']=train_df['text'].apply(dataPreprocessing)\n", 278 | "print(f\"len(train_df):{len(train_df)}\")\n", 279 | "\n", 280 | "test_df=pd.read_csv(Config.test_path)\n", 281 | "test_df['text']=test_df['text'].apply(dataPreprocessing)\n", 282 | "print(f\"len(test_df):{len(test_df)}\")\n", 283 | "test_df.head()" 284 | ] 285 | }, 286 | { 287 | "cell_type": "markdown", 288 | "id": "acf83442", 289 | "metadata": { 290 | "papermill": { 291 | "duration": 0.005942, 292 | "end_time": "2024-03-26T05:55:50.287338", 293 | "exception": false, 294 | "start_time": "2024-03-26T05:55:50.281396", 295 | "status": "completed" 296 | }, 297 | "tags": [] 298 | }, 299 | "source": [ 300 | "### 这里将训练数据的文本统计成字典,并选择出现次数最多的1000个词." 301 | ] 302 | }, 303 | { 304 | "cell_type": "code", 305 | "execution_count": 3, 306 | "id": "e1ac0aac", 307 | "metadata": { 308 | "execution": { 309 | "iopub.execute_input": "2024-03-26T05:55:50.301747Z", 310 | "iopub.status.busy": "2024-03-26T05:55:50.301291Z", 311 | "iopub.status.idle": "2024-03-26T05:55:50.383600Z", 312 | "shell.execute_reply": "2024-03-26T05:55:50.382379Z" 313 | }, 314 | "papermill": { 315 | "duration": 0.092925, 316 | "end_time": "2024-03-26T05:55:50.386441", 317 | "exception": false, 318 | "start_time": "2024-03-26T05:55:50.293516", 319 | "status": "completed" 320 | }, 321 | "tags": [] 322 | }, 323 | "outputs": [ 324 | { 325 | "data": { 326 | "text/plain": [ 327 | "['amp', 'im', 'like', 'fire', 'via', 'new', 'news', 'get', 'one', 'people']" 328 | ] 329 | }, 330 | "execution_count": 3, 331 | "metadata": {}, 332 | "output_type": "execute_result" 333 | } 334 | ], 335 | "source": [ 336 | "text=train_df['text'].values\n", 337 | "word_dict={}\n", 338 | "for i in range(len(text)):\n", 339 | " for j in range(len(text[i])):\n", 340 | " if text[i][j] in word_dict:\n", 341 | " word_dict[text[i][j]]+=1\n", 342 | " else:\n", 343 | " word_dict[text[i][j]]=1\n", 344 | "#word_dict.items() 是key和value,sorted是排序,按照-value按照从小到大排序\n", 345 | "sorted_items = sorted(word_dict.items(), key=lambda x: -x[1])\n", 346 | "\n", 347 | "sorted_list = list(sorted_items)\n", 348 | "top_words=[value[0] for value in sorted_list[:Config.word_count]]\n", 349 | "top_words[:10]" 350 | ] 351 | }, 352 | { 353 | "cell_type": "markdown", 354 | "id": "7b6e4a1c", 355 | "metadata": { 356 | "papermill": { 357 | "duration": 0.006087, 358 | "end_time": "2024-03-26T05:55:50.399011", 359 | "exception": false, 360 | "start_time": "2024-03-26T05:55:50.392924", 361 | "status": "completed" 362 | }, 363 | "tags": [] 364 | }, 365 | "source": [ 366 | "### 构造训练数据和测试数据" 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "execution_count": 4, 372 | "id": "0d4a30a4", 373 | "metadata": { 374 | "execution": { 375 | "iopub.execute_input": "2024-03-26T05:55:50.414659Z", 376 | "iopub.status.busy": "2024-03-26T05:55:50.414263Z", 377 | "iopub.status.idle": "2024-03-26T05:55:54.484832Z", 378 | "shell.execute_reply": "2024-03-26T05:55:54.483286Z" 379 | }, 380 | "papermill": { 381 | "duration": 4.081873, 382 | "end_time": "2024-03-26T05:55:54.487701", 383 | "exception": false, 384 | "start_time": "2024-03-26T05:55:50.405828", 385 | "status": "completed" 386 | }, 387 | "tags": [] 388 | }, 389 | "outputs": [ 390 | { 391 | "name": "stdout", 392 | "output_type": "stream", 393 | "text": [ 394 | "X.shape:(7613, 1000),y.shape:(7613,)\n" 395 | ] 396 | } 397 | ], 398 | "source": [ 399 | "train_text=train_df['text'].values\n", 400 | "test_text=test_df['text'].values\n", 401 | "X=np.array([[int(top_word in text) for top_word in top_words] for text in train_text])\n", 402 | "y=train_df['target'].values\n", 403 | "test_X=np.array([[int(top_word in text) for top_word in top_words] for text in test_text])\n", 404 | "print(f\"X.shape:{X.shape},y.shape:{y.shape}\")" 405 | ] 406 | }, 407 | { 408 | "cell_type": "markdown", 409 | "id": "f054e112", 410 | "metadata": { 411 | "papermill": { 412 | "duration": 0.008344, 413 | "end_time": "2024-03-26T05:55:54.502821", 414 | "exception": false, 415 | "start_time": "2024-03-26T05:55:54.494477", 416 | "status": "completed" 417 | }, 418 | "tags": [] 419 | }, 420 | "source": [ 421 | "### 这里是我自己手写的朴素贝叶斯算法." 422 | ] 423 | }, 424 | { 425 | "cell_type": "code", 426 | "execution_count": 5, 427 | "id": "e1d2f073", 428 | "metadata": { 429 | "execution": { 430 | "iopub.execute_input": "2024-03-26T05:55:54.518073Z", 431 | "iopub.status.busy": "2024-03-26T05:55:54.517661Z", 432 | "iopub.status.idle": "2024-03-26T05:55:54.538312Z", 433 | "shell.execute_reply": "2024-03-26T05:55:54.536982Z" 434 | }, 435 | "papermill": { 436 | "duration": 0.031693, 437 | "end_time": "2024-03-26T05:55:54.541212", 438 | "exception": false, 439 | "start_time": "2024-03-26T05:55:54.509519", 440 | "status": "completed" 441 | }, 442 | "tags": [] 443 | }, 444 | "outputs": [], 445 | "source": [ 446 | "#朴素贝叶斯分类算法\n", 447 | "class NaiveBayesClassifier():\n", 448 | " \n", 449 | " def __init__(self,num_classes=2):\n", 450 | " self.num_classes=num_classes#我们假设是二分类任务\n", 451 | " self.Pa=np.ones(self.num_classes)/self.num_classes#初始化每个类别概率相等,后续需要考虑target的分布.\n", 452 | " self.target=np.arange(self.num_classes)#分类的几种类别是什么\n", 453 | " self.features=[]#X每列分别有哪些类别\n", 454 | " self.featureP=[]#y=target[i]时X的j列为第K种类别的概率\n", 455 | " self.eps=1e-15#防止被除数为0\n", 456 | " def fit(self,train_X,train_y):\n", 457 | " self.target=sorted(np.unique(train_y))#训练数据y中出现几种类别\n", 458 | " self.num_classes=len(self.target)#类别数为多少\n", 459 | " feature=train_X.T#第i行就是第i个特征\n", 460 | " #统计每个特征有哪几种类别\n", 461 | " for i in range(len(feature)):\n", 462 | " self.features.append(np.unique(feature[i]))\n", 463 | "\n", 464 | " #用来统计y为每个类别的概率\n", 465 | " Pa=[]\n", 466 | " for i in range(len(self.target)):\n", 467 | " Pa.append(np.mean(train_y==self.target[i]))\n", 468 | " self.Pa=Pa\n", 469 | " \n", 470 | " #统计y=target[i]时每个特征每个类别的概率\n", 471 | " for i in range(len(self.target)):\n", 472 | " #当y=target[i]的时候的训练数据\n", 473 | " target_X=train_X[np.where((y==self.target[i]))[0]]\n", 474 | " \n", 475 | " #统计所有特征每个类别的概率\n", 476 | " feature_X=target_X.T\n", 477 | " featurePs=[]#y=target时X每种概率的分布情况\n", 478 | " for j in range(len(feature_X)):#第j个feature有这几种类别:self.features[j]\n", 479 | " \n", 480 | " #统计train_X中第j个特征每个类别的概率\n", 481 | " featureP=[]\n", 482 | " for k in range(len(self.features[j])):\n", 483 | " featureP.append(np.mean(feature_X[j]==self.features[j][k]))\n", 484 | " \n", 485 | " featurePs.append(featureP)\n", 486 | " self.featureP.append(featurePs)\n", 487 | " \n", 488 | " def predict_proba(self,test_X):\n", 489 | " #每个数据每个类别的概率\n", 490 | " test_pros=np.zeros((len(test_X),self.num_classes))\n", 491 | " \n", 492 | " for i in range(len(test_X)):#test_X[i]是其中一个数据\n", 493 | " #数据text_X[i]统计每个类别的概率:P(X0[0]|y=y0)P(X0[1]|y=y0)……P(X0[n]|y=y0)P(y=y0)\n", 494 | " test_pro=np.zeros((self.num_classes))\n", 495 | " for j in range(self.num_classes):\n", 496 | " init_p=self.Pa[j]#P(y=y0)\n", 497 | " #找到text_X的第i个数据在y=target[j]时第k个特征的概率\n", 498 | " for k in range(len(test_X[i])):\n", 499 | " Pba=self.Pa[j]\n", 500 | " #找到第test_X的第i个数据的第K个特征是什么?\n", 501 | " for l in range(len(self.features[k])):\n", 502 | " if test_X[i][k]==self.features[k][l]:\n", 503 | " Pba=self.featureP[j][k][l] \n", 504 | " init_p*=Pba\n", 505 | " test_pro[j]=init_p\n", 506 | " test_pros[i]=test_pro\n", 507 | " #最后对预测的概率进行归一化的操作\n", 508 | " test_pros=test_pros/ (np.sum(test_pros,axis=1).reshape(-1,1)+self.eps)\n", 509 | " return test_pros\n", 510 | " \n", 511 | " def predict(self,test_X):\n", 512 | " test_pros=self.predict_proba(test_X)\n", 513 | " test_preds=np.argmax(test_pros,axis=1)\n", 514 | " return test_preds" 515 | ] 516 | }, 517 | { 518 | "cell_type": "markdown", 519 | "id": "498760cd", 520 | "metadata": { 521 | "papermill": { 522 | "duration": 0.006336, 523 | "end_time": "2024-03-26T05:55:54.554429", 524 | "exception": false, 525 | "start_time": "2024-03-26T05:55:54.548093", 526 | "status": "completed" 527 | }, 528 | "tags": [] 529 | }, 530 | "source": [ 531 | "### 如果单看训练数据,准确率达到了0.81,其实在测试数据上还是有0.78的准确率." 532 | ] 533 | }, 534 | { 535 | "cell_type": "code", 536 | "execution_count": 6, 537 | "id": "4ed17dbb", 538 | "metadata": { 539 | "execution": { 540 | "iopub.execute_input": "2024-03-26T05:55:54.569822Z", 541 | "iopub.status.busy": "2024-03-26T05:55:54.569354Z", 542 | "iopub.status.idle": "2024-03-26T05:56:58.342574Z", 543 | "shell.execute_reply": "2024-03-26T05:56:58.341312Z" 544 | }, 545 | "papermill": { 546 | "duration": 63.784601, 547 | "end_time": "2024-03-26T05:56:58.345623", 548 | "exception": false, 549 | "start_time": "2024-03-26T05:55:54.561022", 550 | "status": "completed" 551 | }, 552 | "tags": [] 553 | }, 554 | "outputs": [ 555 | { 556 | "name": "stdout", 557 | "output_type": "stream", 558 | "text": [ 559 | "accuracy:0.8122947589649284\n" 560 | ] 561 | } 562 | ], 563 | "source": [ 564 | "def accuracy(y_true,y_pred):\n", 565 | " return np.mean(y_true==y_pred)\n", 566 | "model=NaiveBayesClassifier()\n", 567 | "model.fit(X,y)\n", 568 | "y_pred=model.predict(X)\n", 569 | "print(f\"accuracy:{accuracy(y_pred,y)}\")\n", 570 | "test_pred=model.predict(test_X)" 571 | ] 572 | }, 573 | { 574 | "cell_type": "markdown", 575 | "id": "32ca68a4", 576 | "metadata": { 577 | "papermill": { 578 | "duration": 0.006413, 579 | "end_time": "2024-03-26T05:56:58.359097", 580 | "exception": false, 581 | "start_time": "2024-03-26T05:56:58.352684", 582 | "status": "completed" 583 | }, 584 | "tags": [] 585 | }, 586 | "source": [ 587 | "### 我们也可以看看python开源库的朴素贝叶斯分类器,效果比我的算法略好一点." 588 | ] 589 | }, 590 | { 591 | "cell_type": "code", 592 | "execution_count": 7, 593 | "id": "c8e25b67", 594 | "metadata": { 595 | "execution": { 596 | "iopub.execute_input": "2024-03-26T05:56:58.377452Z", 597 | "iopub.status.busy": "2024-03-26T05:56:58.376637Z", 598 | "iopub.status.idle": "2024-03-26T05:56:58.944560Z", 599 | "shell.execute_reply": "2024-03-26T05:56:58.943219Z" 600 | }, 601 | "papermill": { 602 | "duration": 0.580257, 603 | "end_time": "2024-03-26T05:56:58.947545", 604 | "exception": false, 605 | "start_time": "2024-03-26T05:56:58.367288", 606 | "status": "completed" 607 | }, 608 | "tags": [] 609 | }, 610 | "outputs": [ 611 | { 612 | "data": { 613 | "text/plain": [ 614 | "0.8128201760147117" 615 | ] 616 | }, 617 | "execution_count": 7, 618 | "metadata": {}, 619 | "output_type": "execute_result" 620 | } 621 | ], 622 | "source": [ 623 | "#https://www.kaggle.com/code/hadriencr/ml-olympiad-naivebayesclassifier\n", 624 | "from sklearn.naive_bayes import CategoricalNB\n", 625 | "\n", 626 | "classifier = CategoricalNB()\n", 627 | "classifier.fit(X,y)\n", 628 | "accuracy(classifier.predict(X),y)" 629 | ] 630 | }, 631 | { 632 | "cell_type": "markdown", 633 | "id": "77aace80", 634 | "metadata": { 635 | "papermill": { 636 | "duration": 0.00673, 637 | "end_time": "2024-03-26T05:56:58.961494", 638 | "exception": false, 639 | "start_time": "2024-03-26T05:56:58.954764", 640 | "status": "completed" 641 | }, 642 | "tags": [] 643 | }, 644 | "source": [ 645 | "### 这里就是把预测结果提交,看看成绩." 646 | ] 647 | }, 648 | { 649 | "cell_type": "code", 650 | "execution_count": 8, 651 | "id": "f897281b", 652 | "metadata": { 653 | "execution": { 654 | "iopub.execute_input": "2024-03-26T05:56:58.978297Z", 655 | "iopub.status.busy": "2024-03-26T05:56:58.977080Z", 656 | "iopub.status.idle": "2024-03-26T05:56:59.009467Z", 657 | "shell.execute_reply": "2024-03-26T05:56:59.008087Z" 658 | }, 659 | "papermill": { 660 | "duration": 0.043767, 661 | "end_time": "2024-03-26T05:56:59.012435", 662 | "exception": false, 663 | "start_time": "2024-03-26T05:56:58.968668", 664 | "status": "completed" 665 | }, 666 | "tags": [] 667 | }, 668 | "outputs": [ 669 | { 670 | "data": { 671 | "text/html": [ 672 | "
\n", 673 | "\n", 686 | "\n", 687 | " \n", 688 | " \n", 689 | " \n", 690 | " \n", 691 | " \n", 692 | " \n", 693 | " \n", 694 | " \n", 695 | " \n", 696 | " \n", 697 | " \n", 698 | " \n", 699 | " \n", 700 | " \n", 701 | " \n", 702 | " \n", 703 | " \n", 704 | " \n", 705 | " \n", 706 | " \n", 707 | " \n", 708 | " \n", 709 | " \n", 710 | " \n", 711 | " \n", 712 | " \n", 713 | " \n", 714 | " \n", 715 | " \n", 716 | " \n", 717 | " \n", 718 | " \n", 719 | " \n", 720 | " \n", 721 | "
idtarget
001
120
230
390
4111
\n", 722 | "
" 723 | ], 724 | "text/plain": [ 725 | " id target\n", 726 | "0 0 1\n", 727 | "1 2 0\n", 728 | "2 3 0\n", 729 | "3 9 0\n", 730 | "4 11 1" 731 | ] 732 | }, 733 | "execution_count": 8, 734 | "metadata": {}, 735 | "output_type": "execute_result" 736 | } 737 | ], 738 | "source": [ 739 | "submission=pd.read_csv(\"/kaggle/input/nlp-getting-started/sample_submission.csv\")\n", 740 | "submission['target']=test_pred\n", 741 | "submission.to_csv(\"submission.csv\",index=None)\n", 742 | "submission.head()" 743 | ] 744 | } 745 | ], 746 | "metadata": { 747 | "kaggle": { 748 | "accelerator": "none", 749 | "dataSources": [ 750 | { 751 | "databundleVersionId": 869809, 752 | "sourceId": 17777, 753 | "sourceType": "competition" 754 | } 755 | ], 756 | "dockerImageVersionId": 30673, 757 | "isGpuEnabled": false, 758 | "isInternetEnabled": true, 759 | "language": "python", 760 | "sourceType": "notebook" 761 | }, 762 | "kernelspec": { 763 | "display_name": "Python 3 (ipykernel)", 764 | "language": "python", 765 | "name": "python3" 766 | }, 767 | "language_info": { 768 | "codemirror_mode": { 769 | "name": "ipython", 770 | "version": 3 771 | }, 772 | "file_extension": ".py", 773 | "mimetype": "text/x-python", 774 | "name": "python", 775 | "nbconvert_exporter": "python", 776 | "pygments_lexer": "ipython3", 777 | "version": "3.8.5" 778 | }, 779 | "papermill": { 780 | "default_parameters": {}, 781 | "duration": 84.23559, 782 | "end_time": "2024-03-26T05:56:59.744079", 783 | "environment_variables": {}, 784 | "exception": null, 785 | "input_path": "__notebook__.ipynb", 786 | "output_path": "__notebook__.ipynb", 787 | "parameters": {}, 788 | "start_time": "2024-03-26T05:55:35.508489", 789 | "version": "2.5.0" 790 | } 791 | }, 792 | "nbformat": 4, 793 | "nbformat_minor": 5 794 | } 795 | -------------------------------------------------------------------------------- /LinearRegressionalgorithm/LinearRegression algorithm.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "230b3ab0", 6 | "metadata": { 7 | "papermill": { 8 | "duration": 0.00528, 9 | "end_time": "2024-03-24T01:50:47.067503", 10 | "exception": false, 11 | "start_time": "2024-03-24T01:50:47.062223", 12 | "status": "completed" 13 | }, 14 | "tags": [] 15 | }, 16 | "source": [ 17 | "## Created by yunsuxiaozi 2024/3/24\n", 18 | "\n", 19 | "### 相信对于大多数接触机器学习算法的人来说,线性回归算法应该是第一个接触的。\n", 20 | "\n", 21 | "### 线性回归是最简单的算法,但是并不代表它很差。在Kaggle最近举办的Home Credit - Credit Risk Model Stability 比赛中,我使用线性回归打败了大约40%的选手。Home Credit LinearRegression is all you need. 所以在这里,我将介绍一下线性回归算法的数学原理以及代码实现,并用一个数据集来比较我的算法和sklearn库的算法.\n", 22 | "\n", 23 | "### 线性回归就是$\\hat{y}=XW+b$.其中$\\hat{y}$是预测值,y是真实值.\n", 24 | "\n", 25 | "### 我们先来说明一下公式中出现的字母:\n", 26 | "\n", 27 | "- X:这是数据的特征.shape:(len(dataset),len(features))\n", 28 | "\n", 29 | "- y:这是需要预测的target.shape:(len(dataset),y.shape[1]),其中y.shape[1]一般为1.\n", 30 | "\n", 31 | "- W:是线性回归算法中X里每个特征的权重.shape:(len(features),y.shape[1]).\n", 32 | "\n", 33 | "- b:是线性回归的偏置.shape:(1,y.shape[1]).\n", 34 | "\n", 35 | "### 关于线性回归,如果数据量太小,或者说矩阵很小,可以用公式直接求解,想看公式推导可以看我以前写的文章n维线性回归模型。如果数据量太大,公式求解就显得不现实了,一方面公式中有矩阵求逆这个(On^3)的步骤,时间上不划算,另一方面如何存储这么大的矩阵也是个问题.这时就需要用迭代的方式来求解了.\n", 36 | "\n", 37 | "### 回归任务中常用的损失函数是$MSE=\\frac{(\\hat{y}-y)^2}{n}=\\frac{(XW+b-y)^2}{n}$,我们的目的就是让MSE最小.这里使用的迭代算法就是梯度下降法.此处梯度是高数的内容,在一元函数里就是导数.\n", 38 | "\n", 39 | "### 这里举个例子:$MSE=x^2$,我们随便设置一个初始点$x=1$,我们想到达最低点$x=0$,此处的导数为$2x=2$.如果往正方向走两步明显是往高处走,所以我们应该往导数的反方向走。如果我们往负数方向走长度2,会到达-1,此时已经经过最低点了,所以我们还需要控制步长,比如在导数前面乘一个$\\frac{1}{2}$,让它往负数方向走长度1,这样才能到达最低点0.这个控制步长的$\\frac{1}{2}$被叫做学习率.从初始位置每次沿着导数反方向走一定的距离最终到达最低点附近的方法就是梯度下降法.\n", 40 | "\n", 41 | "\n", 42 | "### 在线性回归的损失函数$MSE=\\frac{(XW+b-y)^2}{n}$中,X和y是训练数据和标签,这些是固定的,n是数据的数量,也是确定的.真正的参数是$W,b$,我们需要做的是对它们求偏导.\n", 43 | "\n", 44 | "### $MSE'_W=\\frac{1}{n}(2WXX+2Xb-2yX)=\\frac{1}{n}(2X(WX+b-y))=\\frac{1}{n}(2X(\\hat{y}-y))$\n", 45 | "\n", 46 | "### $MSE'_b=\\frac{1}{n}(2XW+2b-2y)=\\frac{2}{n}(\\hat{y}-y)$\n", 47 | "\n", 48 | "### 梯度下降法的迭代公式就是$W=W-lr*(\\frac{1}{n})(2X(\\hat{y}-y),b=b-lr*\\frac{2}{n}(\\hat{y}-y)$\n", 49 | "\n", 50 | "### 注:笔者不是数学专业的学生,对公式细节方面可能不会特别重视,矩阵的转置包括矩阵的先后顺序在公式里没有管。\n", 51 | "\n", 52 | "### 至于算法实现方面,由于我们考虑到矩阵可能会很大,需要将数据集分批次进行训练,比如我有一百万数据,我一次用1万数据进行迭代,迭代100次完成一个epoch.\n", 53 | "\n", 54 | "### 下面我们用一个数据集来实战一下吧:World Press Freedom Index 2023 Trends.这个数据集是我一年前学习线性回归的时候使用的,那时还是2022年版.下面将使用这个数据集来对我的算法和python开源的算法进行比较。" 55 | ] 56 | }, 57 | { 58 | "cell_type": "markdown", 59 | "id": "2aaadc99", 60 | "metadata": { 61 | "papermill": { 62 | "duration": 0.004328, 63 | "end_time": "2024-03-24T01:50:47.076963", 64 | "exception": false, 65 | "start_time": "2024-03-24T01:50:47.072635", 66 | "status": "completed" 67 | }, 68 | "tags": [] 69 | }, 70 | "source": [ 71 | "#### 导入一些python库并固定随机种子" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 1, 77 | "id": "5df6edc8", 78 | "metadata": { 79 | "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", 80 | "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5", 81 | "execution": { 82 | "iopub.execute_input": "2024-03-24T01:50:47.089030Z", 83 | "iopub.status.busy": "2024-03-24T01:50:47.088054Z", 84 | "iopub.status.idle": "2024-03-24T01:50:48.257006Z", 85 | "shell.execute_reply": "2024-03-24T01:50:48.255375Z" 86 | }, 87 | "papermill": { 88 | "duration": 1.178366, 89 | "end_time": "2024-03-24T01:50:48.259963", 90 | "exception": false, 91 | "start_time": "2024-03-24T01:50:47.081597", 92 | "status": "completed" 93 | }, 94 | "tags": [] 95 | }, 96 | "outputs": [], 97 | "source": [ 98 | "import pandas as pd#处理表格数据的库\n", 99 | "import numpy as np#进行矩阵运算的库\n", 100 | "import random#提供了一些用于生成随机数的函数\n", 101 | "#设置随机种子,保证模型可以复现\n", 102 | "def seed_everything(seed):\n", 103 | " np.random.seed(seed)#numpy的随机种子\n", 104 | " random.seed(seed)#python内置的随机种子\n", 105 | "seed_everything(seed=2024)" 106 | ] 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "id": "1e33db88", 111 | "metadata": { 112 | "papermill": { 113 | "duration": 0.004468, 114 | "end_time": "2024-03-24T01:50:48.269375", 115 | "exception": false, 116 | "start_time": "2024-03-24T01:50:48.264907", 117 | "status": "completed" 118 | }, 119 | "tags": [] 120 | }, 121 | "source": [ 122 | "#### 导入数据集." 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": 2, 128 | "id": "e8d1ad4e", 129 | "metadata": { 130 | "execution": { 131 | "iopub.execute_input": "2024-03-24T01:50:48.281362Z", 132 | "iopub.status.busy": "2024-03-24T01:50:48.280642Z", 133 | "iopub.status.idle": "2024-03-24T01:50:48.345827Z", 134 | "shell.execute_reply": "2024-03-24T01:50:48.344246Z" 135 | }, 136 | "papermill": { 137 | "duration": 0.074265, 138 | "end_time": "2024-03-24T01:50:48.348384", 139 | "exception": false, 140 | "start_time": "2024-03-24T01:50:48.274119", 141 | "status": "completed" 142 | }, 143 | "tags": [] 144 | }, 145 | "outputs": [ 146 | { 147 | "name": "stdout", 148 | "output_type": "stream", 149 | "text": [ 150 | "len(dataset):180\n" 151 | ] 152 | }, 153 | { 154 | "data": { 155 | "text/html": [ 156 | "
\n", 157 | "\n", 170 | "\n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | " \n", 189 | " \n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | "
RankingCountryScorePolitical ContextEconomic ContextLegal FrameworkSafety ScoreSociocultural ContextDifference In Position From 2022
01Norway95.1896.5492.4694.9295.9895.980
12Ireland89.9193.9182.1182.5596.9494.034
23Denmark89.4891.9585.1787.5095.0087.78-1
34Sweden88.1592.5886.0888.7484.7288.64-1
45Finland87.9491.5583.8084.8690.3589.170
\n", 248 | "
" 249 | ], 250 | "text/plain": [ 251 | " Ranking Country Score Political Context Economic Context \\\n", 252 | "0 1 Norway 95.18 96.54 92.46 \n", 253 | "1 2 Ireland 89.91 93.91 82.11 \n", 254 | "2 3 Denmark 89.48 91.95 85.17 \n", 255 | "3 4 Sweden 88.15 92.58 86.08 \n", 256 | "4 5 Finland 87.94 91.55 83.80 \n", 257 | "\n", 258 | " Legal Framework Safety Score Sociocultural Context \\\n", 259 | "0 94.92 95.98 95.98 \n", 260 | "1 82.55 96.94 94.03 \n", 261 | "2 87.50 95.00 87.78 \n", 262 | "3 88.74 84.72 88.64 \n", 263 | "4 84.86 90.35 89.17 \n", 264 | "\n", 265 | " Difference In Position From 2022 \n", 266 | "0 0 \n", 267 | "1 4 \n", 268 | "2 -1 \n", 269 | "3 -1 \n", 270 | "4 0 " 271 | ] 272 | }, 273 | "execution_count": 2, 274 | "metadata": {}, 275 | "output_type": "execute_result" 276 | } 277 | ], 278 | "source": [ 279 | "dataset=pd.read_csv(\"./RSB_DataSet.csv\",encoding='gbk')\n", 280 | "print(f\"len(dataset):{len(dataset)}\")\n", 281 | "dataset.head()" 282 | ] 283 | }, 284 | { 285 | "cell_type": "markdown", 286 | "id": "c653f0a8", 287 | "metadata": { 288 | "papermill": { 289 | "duration": 0.004858, 290 | "end_time": "2024-03-24T01:50:48.358370", 291 | "exception": false, 292 | "start_time": "2024-03-24T01:50:48.353512", 293 | "status": "completed" 294 | }, 295 | "tags": [] 296 | }, 297 | "source": [ 298 | "#### 我们看到中国在180个国家中位列倒数第2,仅次于朝鲜,可以说是遥遥领先." 299 | ] 300 | }, 301 | { 302 | "cell_type": "code", 303 | "execution_count": 3, 304 | "id": "78936c29", 305 | "metadata": { 306 | "execution": { 307 | "iopub.execute_input": "2024-03-24T01:50:48.371123Z", 308 | "iopub.status.busy": "2024-03-24T01:50:48.370628Z", 309 | "iopub.status.idle": "2024-03-24T01:50:48.390469Z", 310 | "shell.execute_reply": "2024-03-24T01:50:48.388744Z" 311 | }, 312 | "papermill": { 313 | "duration": 0.029613, 314 | "end_time": "2024-03-24T01:50:48.393256", 315 | "exception": false, 316 | "start_time": "2024-03-24T01:50:48.363643", 317 | "status": "completed" 318 | }, 319 | "tags": [] 320 | }, 321 | "outputs": [ 322 | { 323 | "data": { 324 | "text/html": [ 325 | "
\n", 326 | "\n", 339 | "\n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | " \n", 344 | " \n", 345 | " \n", 346 | " \n", 347 | " \n", 348 | " \n", 349 | " \n", 350 | " \n", 351 | " \n", 352 | " \n", 353 | " \n", 354 | " \n", 355 | " \n", 356 | " \n", 357 | " \n", 358 | " \n", 359 | " \n", 360 | " \n", 361 | " \n", 362 | " \n", 363 | " \n", 364 | " \n", 365 | " \n", 366 | " \n", 367 | " \n", 368 | " \n", 369 | " \n", 370 | " \n", 371 | " \n", 372 | " \n", 373 | " \n", 374 | " \n", 375 | " \n", 376 | " \n", 377 | " \n", 378 | " \n", 379 | " \n", 380 | " \n", 381 | " \n", 382 | " \n", 383 | " \n", 384 | " \n", 385 | " \n", 386 | " \n", 387 | " \n", 388 | " \n", 389 | " \n", 390 | " \n", 391 | " \n", 392 | " \n", 393 | " \n", 394 | " \n", 395 | " \n", 396 | " \n", 397 | " \n", 398 | " \n", 399 | " \n", 400 | " \n", 401 | " \n", 402 | " \n", 403 | " \n", 404 | " \n", 405 | " \n", 406 | " \n", 407 | " \n", 408 | " \n", 409 | " \n", 410 | " \n", 411 | " \n", 412 | " \n", 413 | " \n", 414 | " \n", 415 | " \n", 416 | "
RankingCountryScorePolitical ContextEconomic ContextLegal FrameworkSafety ScoreSociocultural ContextDifference In Position From 2022
175176Turkmenistan25.8223.2520.3929.6246.539.321
176177Iran24.8133.6730.5120.1723.6216.061
177178Vietnam24.5823.7517.1618.4030.6632.95-4
178179China22.9726.0629.5117.3624.8717.07-4
179180North Korea21.7226.5621.5722.6433.254.600
\n", 417 | "
" 418 | ], 419 | "text/plain": [ 420 | " Ranking Country Score Political Context Economic Context \\\n", 421 | "175 176 Turkmenistan 25.82 23.25 20.39 \n", 422 | "176 177 Iran 24.81 33.67 30.51 \n", 423 | "177 178 Vietnam 24.58 23.75 17.16 \n", 424 | "178 179 China 22.97 26.06 29.51 \n", 425 | "179 180 North Korea 21.72 26.56 21.57 \n", 426 | "\n", 427 | " Legal Framework Safety Score Sociocultural Context \\\n", 428 | "175 29.62 46.53 9.32 \n", 429 | "176 20.17 23.62 16.06 \n", 430 | "177 18.40 30.66 32.95 \n", 431 | "178 17.36 24.87 17.07 \n", 432 | "179 22.64 33.25 4.60 \n", 433 | "\n", 434 | " Difference In Position From 2022 \n", 435 | "175 1 \n", 436 | "176 1 \n", 437 | "177 -4 \n", 438 | "178 -4 \n", 439 | "179 0 " 440 | ] 441 | }, 442 | "execution_count": 3, 443 | "metadata": {}, 444 | "output_type": "execute_result" 445 | } 446 | ], 447 | "source": [ 448 | "dataset.tail()" 449 | ] 450 | }, 451 | { 452 | "cell_type": "markdown", 453 | "id": "6ac41052", 454 | "metadata": { 455 | "papermill": { 456 | "duration": 0.005384, 457 | "end_time": "2024-03-24T01:50:48.404456", 458 | "exception": false, 459 | "start_time": "2024-03-24T01:50:48.399072", 460 | "status": "completed" 461 | }, 462 | "tags": [] 463 | }, 464 | "source": [ 465 | "#### 这里是我手动实现的线性回归算法。" 466 | ] 467 | }, 468 | { 469 | "cell_type": "code", 470 | "execution_count": 4, 471 | "id": "edd61349", 472 | "metadata": { 473 | "execution": { 474 | "iopub.execute_input": "2024-03-24T01:50:48.418578Z", 475 | "iopub.status.busy": "2024-03-24T01:50:48.418033Z", 476 | "iopub.status.idle": "2024-03-24T01:50:48.442648Z", 477 | "shell.execute_reply": "2024-03-24T01:50:48.441379Z" 478 | }, 479 | "papermill": { 480 | "duration": 0.035189, 481 | "end_time": "2024-03-24T01:50:48.445710", 482 | "exception": false, 483 | "start_time": "2024-03-24T01:50:48.410521", 484 | "status": "completed" 485 | }, 486 | "tags": [] 487 | }, 488 | "outputs": [], 489 | "source": [ 490 | "class LinearRegression():\n", 491 | " def __init__(self,n_iterators=500,batch_size=100000,lr=0.02,metric='MSE'):\n", 492 | " self.n_iterators=n_iterators#迭代多少次\n", 493 | " self.batch_size=batch_size#用迭代算法每次传入的批次数量\n", 494 | " self.lr=lr#学习率\n", 495 | " self.metric=metric#用什么评估指标来评估模型的效果\n", 496 | " self.mean=0.0#均值\n", 497 | " self.std=1.0#方差\n", 498 | " \n", 499 | " def fit(self,train_X,train_y,is_standardization=True):\n", 500 | " \"\"\"\n", 501 | " train_X.shape:(num_data,num_features)\n", 502 | " train_y.shape:(num_data,y.shape[1])\n", 503 | " self.W.shape:(num_features,y.shape[1])\n", 504 | " self.b.shape:(1,y.shape[1])\n", 505 | " \"\"\"\n", 506 | " if len(train_y.shape)==1:\n", 507 | " train_y=train_y.reshape(-1,1)\n", 508 | " self.W=np.random.randn(train_X.shape[1],train_y.shape[1])\n", 509 | " self.b=np.random.randn(1,train_y.shape[1])\n", 510 | " if is_standardization:#如果对数据进行标准化的话,求出均值和方差\n", 511 | " self.mean=train_X.mean(axis=0)\n", 512 | " self.std=train_X.std(axis=0)\n", 513 | " train_X=(train_X-self.mean)/self.std\n", 514 | " for iterator in range(self.n_iterators): \n", 515 | " random_number=np.arange(len(train_X))\n", 516 | " np.random.shuffle(random_number)\n", 517 | " train_X=train_X[random_number]\n", 518 | " train_y=train_y[random_number]\n", 519 | " losses=[]\n", 520 | " for idx in range(0,len(train_X),self.batch_size):\n", 521 | " train_X1=train_X[idx:idx+self.batch_size]\n", 522 | " train_y1=train_y[idx:idx+self.batch_size]\n", 523 | " train_pred=train_X1.dot(self.W)+self.b\n", 524 | " loss=self.loss(train_y1,train_pred)\n", 525 | " temp_b=np.tile(self.b,(train_X1.shape[0],1))\n", 526 | " #更新参数\n", 527 | " self.W=self.W-2*self.lr*(train_X1.T).dot(train_pred-train_y1)/len(train_X1)\n", 528 | " self.b=self.b-2*self.lr*np.mean(train_pred-train_y1,axis=0)\n", 529 | " losses.append(loss)\n", 530 | " #print(f\"iterator:{iterator},loss:{np.mean(np.array(losses))}\")\n", 531 | " \n", 532 | " def predict(self,test_X):\n", 533 | " test_X=(test_X-self.mean)/self.std\n", 534 | " test_pred=np.zeros((len(test_X),self.b.shape[1]))\n", 535 | " for idx in range(0,len(test_X),self.batch_size):\n", 536 | " test_X1=test_X[idx:idx+self.batch_size]\n", 537 | " test_pred[idx:idx+len(test_X1)]=test_X1.dot(self.W)+self.b\n", 538 | " return test_pred.reshape(-1)\n", 539 | " \n", 540 | " def loss(self,y_true,y_pred):\n", 541 | " if self.metric.lower()=='mse':\n", 542 | " return self.MSE(y_true,y_pred)\n", 543 | " elif self.metric.lower()=='rmse':\n", 544 | " return self.RMSE(y_true,y_pred)\n", 545 | " elif self.metric.lower()=='mae':\n", 546 | " return self.MAE(y_true,y_pred)\n", 547 | " def MSE(self,y_true,y_pred):\n", 548 | " return np.mean((y_true-y_pred)**2)\n", 549 | " def MAE(self,y_true,y_pred):\n", 550 | " return np.mean(np.abs(y_true-y_pred))\n", 551 | " def RMSE(self,y_true,y_pred):\n", 552 | " return np.sqrt(np.mean((y_true-y_pred)**2))" 553 | ] 554 | }, 555 | { 556 | "cell_type": "markdown", 557 | "id": "3a7f25f2", 558 | "metadata": { 559 | "papermill": { 560 | "duration": 0.005438, 561 | "end_time": "2024-03-24T01:50:48.456852", 562 | "exception": false, 563 | "start_time": "2024-03-24T01:50:48.451414", 564 | "status": "completed" 565 | }, 566 | "tags": [] 567 | }, 568 | "source": [ 569 | "#### 我们按照8:2的比例划分训练集和测试集,并用线性回归模型进行训练和预测,MSE约为0.05." 570 | ] 571 | }, 572 | { 573 | "cell_type": "code", 574 | "execution_count": 5, 575 | "id": "6587325d", 576 | "metadata": { 577 | "execution": { 578 | "iopub.execute_input": "2024-03-24T01:50:48.470444Z", 579 | "iopub.status.busy": "2024-03-24T01:50:48.469971Z", 580 | "iopub.status.idle": "2024-03-24T01:50:48.553120Z", 581 | "shell.execute_reply": "2024-03-24T01:50:48.551477Z" 582 | }, 583 | "papermill": { 584 | "duration": 0.094098, 585 | "end_time": "2024-03-24T01:50:48.556641", 586 | "exception": false, 587 | "start_time": "2024-03-24T01:50:48.462543", 588 | "status": "completed" 589 | }, 590 | "tags": [] 591 | }, 592 | "outputs": [ 593 | { 594 | "name": "stdout", 595 | "output_type": "stream", 596 | "text": [ 597 | "MSE:0.056606730829491775,model.W:[[3.4523525 ]\n", 598 | " [3.16890065]\n", 599 | " [3.91554814]\n", 600 | " [4.60958612]\n", 601 | " [4.10433146]],model.b:[[58.61687492]]\n" 602 | ] 603 | } 604 | ], 605 | "source": [ 606 | "X=dataset[['Political Context', 'Economic Context','Legal Framework', \n", 607 | " 'Safety Score', 'Sociocultural Context']].values\n", 608 | "y=dataset['Score'].values\n", 609 | "#划分训练集和测试集的函数\n", 610 | "def train_test_split(dataX,datay,shuffle=True,percentage=0.8):\n", 611 | " \"\"\"\n", 612 | " 将训练数据X和标签y以numpy.array数组的形式传入\n", 613 | " 划分的比例定为训练集:测试集=8:2\n", 614 | " \"\"\"\n", 615 | " if shuffle:\n", 616 | " random_num=[index for index in range(len(dataX))]\n", 617 | " np.random.shuffle(random_num)\n", 618 | " dataX=dataX[random_num]\n", 619 | " datay=datay[random_num]\n", 620 | " split_num=int(len(dataX)*percentage)\n", 621 | " train_X=dataX[:split_num]\n", 622 | " train_y=datay[:split_num]\n", 623 | " test_X=dataX[split_num:]\n", 624 | " test_y=datay[split_num:]\n", 625 | " return train_X,train_y,test_X,test_y\n", 626 | "def MSE(y_true,y_pred):\n", 627 | " return np.mean((y_true-y_pred)**2)\n", 628 | "train_X,train_y,test_X,test_y=train_test_split(X,y,shuffle=True,percentage=0.8)\n", 629 | "model=LinearRegression()\n", 630 | "model.fit(train_X,train_y)\n", 631 | "test_pred=model.predict(test_X)\n", 632 | "print(f\"MSE:{MSE(test_y,test_pred)},model.W:{model.W},model.b:{model.b}\")" 633 | ] 634 | }, 635 | { 636 | "cell_type": "markdown", 637 | "id": "3f331597", 638 | "metadata": { 639 | "papermill": { 640 | "duration": 0.005596, 641 | "end_time": "2024-03-24T01:50:48.568314", 642 | "exception": false, 643 | "start_time": "2024-03-24T01:50:48.562718", 644 | "status": "completed" 645 | }, 646 | "tags": [] 647 | }, 648 | "source": [ 649 | "#### 接下来调用python的sklearn里的线性回归模型,我们可以看到MSE大约为0.05.我们可以看到两种算法效果还是差不多的.至于最后找到的参数不同是因为算法在实现细节上是不同的." 650 | ] 651 | }, 652 | { 653 | "cell_type": "code", 654 | "execution_count": 6, 655 | "id": "d8734f9c", 656 | "metadata": { 657 | "execution": { 658 | "iopub.execute_input": "2024-03-24T01:50:48.582601Z", 659 | "iopub.status.busy": "2024-03-24T01:50:48.582190Z", 660 | "iopub.status.idle": "2024-03-24T01:50:50.429760Z", 661 | "shell.execute_reply": "2024-03-24T01:50:50.428514Z" 662 | }, 663 | "papermill": { 664 | "duration": 1.858447, 665 | "end_time": "2024-03-24T01:50:50.432671", 666 | "exception": false, 667 | "start_time": "2024-03-24T01:50:48.574224", 668 | "status": "completed" 669 | }, 670 | "tags": [] 671 | }, 672 | "outputs": [ 673 | { 674 | "name": "stdout", 675 | "output_type": "stream", 676 | "text": [ 677 | "MSE:0.05745845678339052,model.coef_:[0.20004491 0.19992727 0.19996543 0.20000271 0.20004921], model.intercept_:-0.0003447826392246611 \n" 678 | ] 679 | } 680 | ], 681 | "source": [ 682 | "from sklearn.linear_model import LinearRegression\n", 683 | "model=LinearRegression()\n", 684 | "model.fit(train_X,train_y)\n", 685 | "test_pred=model.predict(test_X)\n", 686 | "print(f\"MSE:{MSE(test_y,test_pred)},model.coef_:{model.coef_}, model.intercept_:{model.intercept_} \")" 687 | ] 688 | }, 689 | { 690 | "cell_type": "markdown", 691 | "id": "aace412d", 692 | "metadata": { 693 | "papermill": { 694 | "duration": 0.006028, 695 | "end_time": "2024-03-24T01:50:50.445003", 696 | "exception": false, 697 | "start_time": "2024-03-24T01:50:50.438975", 698 | "status": "completed" 699 | }, 700 | "tags": [] 701 | }, 702 | "source": [ 703 | "#### 如果你觉得我的notebook对你有用的话,请给我点个赞,谢谢.如果你对我的notebook有什么想法或者建议也欢迎提出来,以便于我更好的完善." 704 | ] 705 | } 706 | ], 707 | "metadata": { 708 | "kaggle": { 709 | "accelerator": "none", 710 | "dataSources": [ 711 | { 712 | "datasetId": 3235463, 713 | "sourceId": 5627136, 714 | "sourceType": "datasetVersion" 715 | } 716 | ], 717 | "dockerImageVersionId": 30673, 718 | "isGpuEnabled": false, 719 | "isInternetEnabled": true, 720 | "language": "python", 721 | "sourceType": "notebook" 722 | }, 723 | "kernelspec": { 724 | "display_name": "Python 3 (ipykernel)", 725 | "language": "python", 726 | "name": "python3" 727 | }, 728 | "language_info": { 729 | "codemirror_mode": { 730 | "name": "ipython", 731 | "version": 3 732 | }, 733 | "file_extension": ".py", 734 | "mimetype": "text/x-python", 735 | "name": "python", 736 | "nbconvert_exporter": "python", 737 | "pygments_lexer": "ipython3", 738 | "version": "3.8.5" 739 | }, 740 | "papermill": { 741 | "default_parameters": {}, 742 | "duration": 7.880429, 743 | "end_time": "2024-03-24T01:50:51.378433", 744 | "environment_variables": {}, 745 | "exception": null, 746 | "input_path": "__notebook__.ipynb", 747 | "output_path": "__notebook__.ipynb", 748 | "parameters": {}, 749 | "start_time": "2024-03-24T01:50:43.498004", 750 | "version": "2.5.0" 751 | } 752 | }, 753 | "nbformat": 4, 754 | "nbformat_minor": 5 755 | } 756 | -------------------------------------------------------------------------------- /naivebayesclassifier/sample_submission.csv: -------------------------------------------------------------------------------- 1 | id,target 2 | 0,0 3 | 2,0 4 | 3,0 5 | 9,0 6 | 11,0 7 | 12,0 8 | 21,0 9 | 22,0 10 | 27,0 11 | 29,0 12 | 30,0 13 | 35,0 14 | 42,0 15 | 43,0 16 | 45,0 17 | 46,0 18 | 47,0 19 | 51,0 20 | 58,0 21 | 60,0 22 | 69,0 23 | 70,0 24 | 72,0 25 | 75,0 26 | 84,0 27 | 87,0 28 | 88,0 29 | 90,0 30 | 94,0 31 | 99,0 32 | 101,0 33 | 103,0 34 | 106,0 35 | 108,0 36 | 111,0 37 | 115,0 38 | 116,0 39 | 122,0 40 | 123,0 41 | 124,0 42 | 125,0 43 | 127,0 44 | 140,0 45 | 142,0 46 | 147,0 47 | 148,0 48 | 150,0 49 | 152,0 50 | 154,0 51 | 155,0 52 | 166,0 53 | 167,0 54 | 169,0 55 | 177,0 56 | 179,0 57 | 181,0 58 | 186,0 59 | 188,0 60 | 189,0 61 | 192,0 62 | 200,0 63 | 202,0 64 | 206,0 65 | 207,0 66 | 214,0 67 | 217,0 68 | 223,0 69 | 224,0 70 | 227,0 71 | 228,0 72 | 230,0 73 | 233,0 74 | 234,0 75 | 236,0 76 | 239,0 77 | 250,0 78 | 255,0 79 | 257,0 80 | 259,0 81 | 275,0 82 | 278,0 83 | 282,0 84 | 284,0 85 | 286,0 86 | 288,0 87 | 292,0 88 | 295,0 89 | 300,0 90 | 304,0 91 | 305,0 92 | 306,0 93 | 308,0 94 | 311,0 95 | 317,0 96 | 319,0 97 | 323,0 98 | 324,0 99 | 325,0 100 | 326,0 101 | 333,0 102 | 339,0 103 | 342,0 104 | 343,0 105 | 350,0 106 | 351,0 107 | 357,0 108 | 359,0 109 | 362,0 110 | 366,0 111 | 367,0 112 | 369,0 113 | 373,0 114 | 374,0 115 | 376,0 116 | 377,0 117 | 378,0 118 | 379,0 119 | 382,0 120 | 385,0 121 | 387,0 122 | 388,0 123 | 391,0 124 | 392,0 125 | 395,0 126 | 399,0 127 | 400,0 128 | 403,0 129 | 405,0 130 | 408,0 131 | 411,0 132 | 414,0 133 | 416,0 134 | 417,0 135 | 422,0 136 | 425,0 137 | 428,0 138 | 430,0 139 | 431,0 140 | 433,0 141 | 434,0 142 | 439,0 143 | 441,0 144 | 449,0 145 | 458,0 146 | 460,0 147 | 464,0 148 | 473,0 149 | 488,0 150 | 491,0 151 | 494,0 152 | 497,0 153 | 500,0 154 | 505,0 155 | 507,0 156 | 508,0 157 | 510,0 158 | 511,0 159 | 515,0 160 | 525,0 161 | 529,0 162 | 532,0 163 | 534,0 164 | 537,0 165 | 539,0 166 | 541,0 167 | 545,0 168 | 547,0 169 | 548,0 170 | 549,0 171 | 553,0 172 | 554,0 173 | 555,0 174 | 557,0 175 | 562,0 176 | 566,0 177 | 572,0 178 | 573,0 179 | 582,0 180 | 586,0 181 | 587,0 182 | 590,0 183 | 591,0 184 | 593,0 185 | 595,0 186 | 596,0 187 | 597,0 188 | 601,0 189 | 602,0 190 | 605,0 191 | 610,0 192 | 616,0 193 | 618,0 194 | 620,0 195 | 626,0 196 | 627,0 197 | 629,0 198 | 632,0 199 | 634,0 200 | 639,0 201 | 645,0 202 | 647,0 203 | 648,0 204 | 650,0 205 | 663,0 206 | 666,0 207 | 668,0 208 | 670,0 209 | 673,0 210 | 676,0 211 | 678,0 212 | 692,0 213 | 693,0 214 | 694,0 215 | 695,0 216 | 696,0 217 | 698,0 218 | 701,0 219 | 703,0 220 | 707,0 221 | 708,0 222 | 711,0 223 | 715,0 224 | 718,0 225 | 722,0 226 | 723,0 227 | 733,0 228 | 741,0 229 | 742,0 230 | 743,0 231 | 747,0 232 | 749,0 233 | 750,0 234 | 756,0 235 | 757,0 236 | 760,0 237 | 764,0 238 | 765,0 239 | 766,0 240 | 768,0 241 | 769,0 242 | 771,0 243 | 772,0 244 | 776,0 245 | 778,0 246 | 780,0 247 | 785,0 248 | 789,0 249 | 792,0 250 | 793,0 251 | 811,0 252 | 813,0 253 | 816,0 254 | 821,0 255 | 824,0 256 | 825,0 257 | 827,0 258 | 830,0 259 | 831,0 260 | 839,0 261 | 844,0 262 | 847,0 263 | 850,0 264 | 854,0 265 | 855,0 266 | 858,0 267 | 861,0 268 | 862,0 269 | 865,0 270 | 869,0 271 | 879,0 272 | 880,0 273 | 887,0 274 | 889,0 275 | 897,0 276 | 900,0 277 | 901,0 278 | 904,0 279 | 908,0 280 | 909,0 281 | 910,0 282 | 913,0 283 | 914,0 284 | 917,0 285 | 918,0 286 | 920,0 287 | 922,0 288 | 924,0 289 | 925,0 290 | 927,0 291 | 933,0 292 | 937,0 293 | 943,0 294 | 949,0 295 | 950,0 296 | 954,0 297 | 966,0 298 | 967,0 299 | 969,0 300 | 970,0 301 | 973,0 302 | 975,0 303 | 980,0 304 | 988,0 305 | 989,0 306 | 995,0 307 | 1000,0 308 | 1003,0 309 | 1007,0 310 | 1011,0 311 | 1012,0 312 | 1013,0 313 | 1014,0 314 | 1016,0 315 | 1019,0 316 | 1025,0 317 | 1027,0 318 | 1028,0 319 | 1030,0 320 | 1033,0 321 | 1034,0 322 | 1039,0 323 | 1046,0 324 | 1047,0 325 | 1053,0 326 | 1055,0 327 | 1056,0 328 | 1059,0 329 | 1060,0 330 | 1063,0 331 | 1064,0 332 | 1068,0 333 | 1076,0 334 | 1086,0 335 | 1087,0 336 | 1089,0 337 | 1092,0 338 | 1095,0 339 | 1096,0 340 | 1097,0 341 | 1100,0 342 | 1101,0 343 | 1107,0 344 | 1108,0 345 | 1111,0 346 | 1115,0 347 | 1116,0 348 | 1121,0 349 | 1125,0 350 | 1127,0 351 | 1131,0 352 | 1133,0 353 | 1135,0 354 | 1137,0 355 | 1140,0 356 | 1144,0 357 | 1147,0 358 | 1148,0 359 | 1150,0 360 | 1158,0 361 | 1159,0 362 | 1161,0 363 | 1163,0 364 | 1165,0 365 | 1169,0 366 | 1171,0 367 | 1172,0 368 | 1176,0 369 | 1180,0 370 | 1184,0 371 | 1186,0 372 | 1187,0 373 | 1192,0 374 | 1193,0 375 | 1194,0 376 | 1197,0 377 | 1200,0 378 | 1205,0 379 | 1210,0 380 | 1216,0 381 | 1220,0 382 | 1231,0 383 | 1233,0 384 | 1246,0 385 | 1247,0 386 | 1248,0 387 | 1255,0 388 | 1256,0 389 | 1257,0 390 | 1258,0 391 | 1260,0 392 | 1261,0 393 | 1265,0 394 | 1266,0 395 | 1268,0 396 | 1274,0 397 | 1281,0 398 | 1285,0 399 | 1286,0 400 | 1291,0 401 | 1292,0 402 | 1295,0 403 | 1299,0 404 | 1306,0 405 | 1310,0 406 | 1311,0 407 | 1313,0 408 | 1314,0 409 | 1322,0 410 | 1323,0 411 | 1325,0 412 | 1329,0 413 | 1330,0 414 | 1333,0 415 | 1336,0 416 | 1339,0 417 | 1342,0 418 | 1344,0 419 | 1355,0 420 | 1357,0 421 | 1358,0 422 | 1359,0 423 | 1364,0 424 | 1366,0 425 | 1367,0 426 | 1370,0 427 | 1373,0 428 | 1377,0 429 | 1386,0 430 | 1387,0 431 | 1392,0 432 | 1397,0 433 | 1398,0 434 | 1400,0 435 | 1403,0 436 | 1404,0 437 | 1410,0 438 | 1413,0 439 | 1416,0 440 | 1417,0 441 | 1423,0 442 | 1424,0 443 | 1426,0 444 | 1427,0 445 | 1428,0 446 | 1430,0 447 | 1434,0 448 | 1435,0 449 | 1437,0 450 | 1438,0 451 | 1442,0 452 | 1446,0 453 | 1451,0 454 | 1457,0 455 | 1461,0 456 | 1462,0 457 | 1465,0 458 | 1468,0 459 | 1469,0 460 | 1471,0 461 | 1476,0 462 | 1478,0 463 | 1481,0 464 | 1489,0 465 | 1490,0 466 | 1492,0 467 | 1496,0 468 | 1512,0 469 | 1516,0 470 | 1517,0 471 | 1528,0 472 | 1529,0 473 | 1536,0 474 | 1539,0 475 | 1541,0 476 | 1542,0 477 | 1548,0 478 | 1550,0 479 | 1551,0 480 | 1552,0 481 | 1557,0 482 | 1563,0 483 | 1564,0 484 | 1565,0 485 | 1566,0 486 | 1571,0 487 | 1578,0 488 | 1581,0 489 | 1583,0 490 | 1584,0 491 | 1586,0 492 | 1589,0 493 | 1592,0 494 | 1598,0 495 | 1606,0 496 | 1612,0 497 | 1616,0 498 | 1620,0 499 | 1624,0 500 | 1629,0 501 | 1630,0 502 | 1635,0 503 | 1640,0 504 | 1641,0 505 | 1642,0 506 | 1651,0 507 | 1655,0 508 | 1656,0 509 | 1659,0 510 | 1664,0 511 | 1667,0 512 | 1668,0 513 | 1674,0 514 | 1678,0 515 | 1680,0 516 | 1681,0 517 | 1682,0 518 | 1685,0 519 | 1695,0 520 | 1696,0 521 | 1697,0 522 | 1704,0 523 | 1708,0 524 | 1711,0 525 | 1713,0 526 | 1714,0 527 | 1717,0 528 | 1729,0 529 | 1730,0 530 | 1732,0 531 | 1734,0 532 | 1736,0 533 | 1738,0 534 | 1742,0 535 | 1743,0 536 | 1746,0 537 | 1748,0 538 | 1749,0 539 | 1751,0 540 | 1758,0 541 | 1764,0 542 | 1765,0 543 | 1777,0 544 | 1778,0 545 | 1781,0 546 | 1782,0 547 | 1783,0 548 | 1785,0 549 | 1788,0 550 | 1793,0 551 | 1794,0 552 | 1795,0 553 | 1797,0 554 | 1800,0 555 | 1801,0 556 | 1805,0 557 | 1806,0 558 | 1819,0 559 | 1820,0 560 | 1825,0 561 | 1828,0 562 | 1829,0 563 | 1830,0 564 | 1839,0 565 | 1843,0 566 | 1844,0 567 | 1846,0 568 | 1849,0 569 | 1850,0 570 | 1854,0 571 | 1855,0 572 | 1858,0 573 | 1859,0 574 | 1862,0 575 | 1867,0 576 | 1868,0 577 | 1871,0 578 | 1872,0 579 | 1874,0 580 | 1876,0 581 | 1879,0 582 | 1884,0 583 | 1891,0 584 | 1894,0 585 | 1896,0 586 | 1902,0 587 | 1903,0 588 | 1904,0 589 | 1906,0 590 | 1907,0 591 | 1912,0 592 | 1913,0 593 | 1923,0 594 | 1926,0 595 | 1928,0 596 | 1930,0 597 | 1931,0 598 | 1934,0 599 | 1936,0 600 | 1944,0 601 | 1946,0 602 | 1947,0 603 | 1958,0 604 | 1964,0 605 | 1970,0 606 | 1974,0 607 | 1977,0 608 | 1978,0 609 | 1982,0 610 | 1984,0 611 | 1988,0 612 | 1993,0 613 | 1997,0 614 | 1998,0 615 | 2002,0 616 | 2004,0 617 | 2005,0 618 | 2008,0 619 | 2011,0 620 | 2013,0 621 | 2018,0 622 | 2021,0 623 | 2025,0 624 | 2029,0 625 | 2030,0 626 | 2032,0 627 | 2037,0 628 | 2041,0 629 | 2044,0 630 | 2048,0 631 | 2052,0 632 | 2053,0 633 | 2054,0 634 | 2062,0 635 | 2065,0 636 | 2066,0 637 | 2072,0 638 | 2079,0 639 | 2080,0 640 | 2085,0 641 | 2088,0 642 | 2090,0 643 | 2092,0 644 | 2093,0 645 | 2101,0 646 | 2104,0 647 | 2105,0 648 | 2106,0 649 | 2107,0 650 | 2120,0 651 | 2124,0 652 | 2127,0 653 | 2130,0 654 | 2132,0 655 | 2135,0 656 | 2137,0 657 | 2140,0 658 | 2143,0 659 | 2147,0 660 | 2151,0 661 | 2152,0 662 | 2155,0 663 | 2156,0 664 | 2162,0 665 | 2165,0 666 | 2166,0 667 | 2167,0 668 | 2168,0 669 | 2170,0 670 | 2178,0 671 | 2180,0 672 | 2182,0 673 | 2184,0 674 | 2185,0 675 | 2187,0 676 | 2196,0 677 | 2197,0 678 | 2199,0 679 | 2200,0 680 | 2201,0 681 | 2202,0 682 | 2206,0 683 | 2208,0 684 | 2218,0 685 | 2223,0 686 | 2224,0 687 | 2226,0 688 | 2228,0 689 | 2232,0 690 | 2234,0 691 | 2243,0 692 | 2247,0 693 | 2249,0 694 | 2252,0 695 | 2253,0 696 | 2259,0 697 | 2261,0 698 | 2264,0 699 | 2268,0 700 | 2269,0 701 | 2270,0 702 | 2276,0 703 | 2283,0 704 | 2287,0 705 | 2290,0 706 | 2291,0 707 | 2293,0 708 | 2295,0 709 | 2302,0 710 | 2305,0 711 | 2310,0 712 | 2313,0 713 | 2316,0 714 | 2320,0 715 | 2322,0 716 | 2323,0 717 | 2326,0 718 | 2328,0 719 | 2331,0 720 | 2335,0 721 | 2338,0 722 | 2343,0 723 | 2344,0 724 | 2345,0 725 | 2353,0 726 | 2355,0 727 | 2357,0 728 | 2360,0 729 | 2365,0 730 | 2369,0 731 | 2371,0 732 | 2378,0 733 | 2380,0 734 | 2381,0 735 | 2383,0 736 | 2384,0 737 | 2392,0 738 | 2393,0 739 | 2401,0 740 | 2403,0 741 | 2404,0 742 | 2405,0 743 | 2407,0 744 | 2411,0 745 | 2424,0 746 | 2426,0 747 | 2431,0 748 | 2433,0 749 | 2434,0 750 | 2436,0 751 | 2439,0 752 | 2444,0 753 | 2447,0 754 | 2448,0 755 | 2449,0 756 | 2450,0 757 | 2461,0 758 | 2469,0 759 | 2472,0 760 | 2473,0 761 | 2474,0 762 | 2477,0 763 | 2481,0 764 | 2484,0 765 | 2495,0 766 | 2503,0 767 | 2509,0 768 | 2511,0 769 | 2518,0 770 | 2522,0 771 | 2525,0 772 | 2526,0 773 | 2529,0 774 | 2533,0 775 | 2549,0 776 | 2551,0 777 | 2558,0 778 | 2562,0 779 | 2563,0 780 | 2567,0 781 | 2574,0 782 | 2577,0 783 | 2578,0 784 | 2580,0 785 | 2581,0 786 | 2583,0 787 | 2584,0 788 | 2586,0 789 | 2589,0 790 | 2595,0 791 | 2596,0 792 | 2600,0 793 | 2601,0 794 | 2607,0 795 | 2610,0 796 | 2613,0 797 | 2615,0 798 | 2618,0 799 | 2620,0 800 | 2623,0 801 | 2626,0 802 | 2630,0 803 | 2634,0 804 | 2636,0 805 | 2638,0 806 | 2639,0 807 | 2646,0 808 | 2650,0 809 | 2652,0 810 | 2653,0 811 | 2654,0 812 | 2662,0 813 | 2665,0 814 | 2669,0 815 | 2674,0 816 | 2678,0 817 | 2681,0 818 | 2685,0 819 | 2686,0 820 | 2690,0 821 | 2697,0 822 | 2699,0 823 | 2704,0 824 | 2705,0 825 | 2710,0 826 | 2712,0 827 | 2713,0 828 | 2716,0 829 | 2717,0 830 | 2718,0 831 | 2721,0 832 | 2722,0 833 | 2735,0 834 | 2737,0 835 | 2738,0 836 | 2742,0 837 | 2745,0 838 | 2746,0 839 | 2747,0 840 | 2750,0 841 | 2751,0 842 | 2754,0 843 | 2762,0 844 | 2764,0 845 | 2772,0 846 | 2775,0 847 | 2776,0 848 | 2779,0 849 | 2781,0 850 | 2789,0 851 | 2790,0 852 | 2791,0 853 | 2798,0 854 | 2800,0 855 | 2804,0 856 | 2805,0 857 | 2806,0 858 | 2809,0 859 | 2810,0 860 | 2812,0 861 | 2814,0 862 | 2816,0 863 | 2818,0 864 | 2823,0 865 | 2824,0 866 | 2834,0 867 | 2837,0 868 | 2840,0 869 | 2845,0 870 | 2847,0 871 | 2848,0 872 | 2850,0 873 | 2859,0 874 | 2862,0 875 | 2868,0 876 | 2874,0 877 | 2876,0 878 | 2892,0 879 | 2894,0 880 | 2897,0 881 | 2901,0 882 | 2903,0 883 | 2904,0 884 | 2906,0 885 | 2914,0 886 | 2918,0 887 | 2919,0 888 | 2923,0 889 | 2926,0 890 | 2928,0 891 | 2930,0 892 | 2938,0 893 | 2940,0 894 | 2949,0 895 | 2951,0 896 | 2958,0 897 | 2961,0 898 | 2962,0 899 | 2964,0 900 | 2966,0 901 | 2967,0 902 | 2968,0 903 | 2972,0 904 | 2977,0 905 | 2978,0 906 | 2979,0 907 | 2981,0 908 | 2985,0 909 | 2986,0 910 | 2989,0 911 | 2994,0 912 | 2996,0 913 | 2997,0 914 | 2999,0 915 | 3002,0 916 | 3007,0 917 | 3008,0 918 | 3017,0 919 | 3020,0 920 | 3024,0 921 | 3028,0 922 | 3031,0 923 | 3032,0 924 | 3033,0 925 | 3035,0 926 | 3040,0 927 | 3041,0 928 | 3046,0 929 | 3050,0 930 | 3063,0 931 | 3065,0 932 | 3067,0 933 | 3069,0 934 | 3076,0 935 | 3078,0 936 | 3081,0 937 | 3087,0 938 | 3088,0 939 | 3094,0 940 | 3096,0 941 | 3098,0 942 | 3103,0 943 | 3110,0 944 | 3113,0 945 | 3121,0 946 | 3127,0 947 | 3128,0 948 | 3129,0 949 | 3135,0 950 | 3143,0 951 | 3146,0 952 | 3148,0 953 | 3149,0 954 | 3151,0 955 | 3156,0 956 | 3160,0 957 | 3164,0 958 | 3169,0 959 | 3178,0 960 | 3187,0 961 | 3194,0 962 | 3202,0 963 | 3203,0 964 | 3204,0 965 | 3206,0 966 | 3207,0 967 | 3208,0 968 | 3209,0 969 | 3213,0 970 | 3214,0 971 | 3215,0 972 | 3220,0 973 | 3223,0 974 | 3224,0 975 | 3226,0 976 | 3228,0 977 | 3230,0 978 | 3232,0 979 | 3233,0 980 | 3234,0 981 | 3238,0 982 | 3246,0 983 | 3247,0 984 | 3250,0 985 | 3251,0 986 | 3254,0 987 | 3257,0 988 | 3258,0 989 | 3261,0 990 | 3267,0 991 | 3268,0 992 | 3269,0 993 | 3271,0 994 | 3272,0 995 | 3273,0 996 | 3279,0 997 | 3290,0 998 | 3291,0 999 | 3293,0 1000 | 3294,0 1001 | 3298,0 1002 | 3305,0 1003 | 3306,0 1004 | 3307,0 1005 | 3310,0 1006 | 3313,0 1007 | 3314,0 1008 | 3315,0 1009 | 3316,0 1010 | 3321,0 1011 | 3325,0 1012 | 3326,0 1013 | 3327,0 1014 | 3330,0 1015 | 3331,0 1016 | 3332,0 1017 | 3333,0 1018 | 3343,0 1019 | 3344,0 1020 | 3348,0 1021 | 3349,0 1022 | 3350,0 1023 | 3352,0 1024 | 3353,0 1025 | 3354,0 1026 | 3358,0 1027 | 3360,0 1028 | 3366,0 1029 | 3371,0 1030 | 3374,0 1031 | 3375,0 1032 | 3378,0 1033 | 3382,0 1034 | 3384,0 1035 | 3385,0 1036 | 3386,0 1037 | 3392,0 1038 | 3399,0 1039 | 3407,0 1040 | 3409,0 1041 | 3416,0 1042 | 3420,0 1043 | 3422,0 1044 | 3424,0 1045 | 3426,0 1046 | 3427,0 1047 | 3434,0 1048 | 3438,0 1049 | 3441,0 1050 | 3442,0 1051 | 3443,0 1052 | 3444,0 1053 | 3449,0 1054 | 3453,0 1055 | 3454,0 1056 | 3456,0 1057 | 3457,0 1058 | 3458,0 1059 | 3461,0 1060 | 3467,0 1061 | 3479,0 1062 | 3488,0 1063 | 3491,0 1064 | 3496,0 1065 | 3502,0 1066 | 3507,0 1067 | 3511,0 1068 | 3515,0 1069 | 3516,0 1070 | 3538,0 1071 | 3539,0 1072 | 3541,0 1073 | 3545,0 1074 | 3546,0 1075 | 3547,0 1076 | 3551,0 1077 | 3553,0 1078 | 3556,0 1079 | 3558,0 1080 | 3559,0 1081 | 3561,0 1082 | 3562,0 1083 | 3563,0 1084 | 3564,0 1085 | 3571,0 1086 | 3574,0 1087 | 3576,0 1088 | 3577,0 1089 | 3579,0 1090 | 3580,0 1091 | 3586,0 1092 | 3590,0 1093 | 3599,0 1094 | 3600,0 1095 | 3601,0 1096 | 3605,0 1097 | 3606,0 1098 | 3612,0 1099 | 3614,0 1100 | 3615,0 1101 | 3616,0 1102 | 3620,0 1103 | 3622,0 1104 | 3624,0 1105 | 3630,0 1106 | 3644,0 1107 | 3649,0 1108 | 3651,0 1109 | 3654,0 1110 | 3665,0 1111 | 3668,0 1112 | 3671,0 1113 | 3672,0 1114 | 3673,0 1115 | 3677,0 1116 | 3678,0 1117 | 3687,0 1118 | 3688,0 1119 | 3693,0 1120 | 3698,0 1121 | 3699,0 1122 | 3701,0 1123 | 3703,0 1124 | 3706,0 1125 | 3707,0 1126 | 3709,0 1127 | 3711,0 1128 | 3714,0 1129 | 3716,0 1130 | 3720,0 1131 | 3728,0 1132 | 3731,0 1133 | 3732,0 1134 | 3733,0 1135 | 3734,0 1136 | 3740,0 1137 | 3746,0 1138 | 3749,0 1139 | 3751,0 1140 | 3755,0 1141 | 3757,0 1142 | 3762,0 1143 | 3767,0 1144 | 3769,0 1145 | 3779,0 1146 | 3781,0 1147 | 3782,0 1148 | 3783,0 1149 | 3784,0 1150 | 3790,0 1151 | 3791,0 1152 | 3792,0 1153 | 3794,0 1154 | 3799,0 1155 | 3801,0 1156 | 3804,0 1157 | 3808,0 1158 | 3809,0 1159 | 3811,0 1160 | 3813,0 1161 | 3817,0 1162 | 3818,0 1163 | 3823,0 1164 | 3843,0 1165 | 3844,0 1166 | 3846,0 1167 | 3847,0 1168 | 3852,0 1169 | 3854,0 1170 | 3856,0 1171 | 3863,0 1172 | 3865,0 1173 | 3867,0 1174 | 3871,0 1175 | 3872,0 1176 | 3878,0 1177 | 3880,0 1178 | 3881,0 1179 | 3882,0 1180 | 3883,0 1181 | 3884,0 1182 | 3885,0 1183 | 3886,0 1184 | 3890,0 1185 | 3891,0 1186 | 3898,0 1187 | 3902,0 1188 | 3909,0 1189 | 3910,0 1190 | 3912,0 1191 | 3915,0 1192 | 3918,0 1193 | 3920,0 1194 | 3925,0 1195 | 3928,0 1196 | 3929,0 1197 | 3930,0 1198 | 3931,0 1199 | 3934,0 1200 | 3939,0 1201 | 3941,0 1202 | 3942,0 1203 | 3943,0 1204 | 3946,0 1205 | 3963,0 1206 | 3965,0 1207 | 3966,0 1208 | 3971,0 1209 | 3972,0 1210 | 3974,0 1211 | 3976,0 1212 | 3978,0 1213 | 3981,0 1214 | 3985,0 1215 | 3986,0 1216 | 3987,0 1217 | 3988,0 1218 | 3991,0 1219 | 3999,0 1220 | 4001,0 1221 | 4002,0 1222 | 4004,0 1223 | 4007,0 1224 | 4009,0 1225 | 4013,0 1226 | 4015,0 1227 | 4016,0 1228 | 4023,0 1229 | 4031,0 1230 | 4035,0 1231 | 4036,0 1232 | 4037,0 1233 | 4040,0 1234 | 4048,0 1235 | 4053,0 1236 | 4056,0 1237 | 4059,0 1238 | 4066,0 1239 | 4067,0 1240 | 4069,0 1241 | 4070,0 1242 | 4071,0 1243 | 4073,0 1244 | 4074,0 1245 | 4075,0 1246 | 4082,0 1247 | 4090,0 1248 | 4099,0 1249 | 4102,0 1250 | 4106,0 1251 | 4109,0 1252 | 4110,0 1253 | 4115,0 1254 | 4118,0 1255 | 4120,0 1256 | 4125,0 1257 | 4126,0 1258 | 4130,0 1259 | 4134,0 1260 | 4136,0 1261 | 4137,0 1262 | 4144,0 1263 | 4148,0 1264 | 4151,0 1265 | 4155,0 1266 | 4162,0 1267 | 4165,0 1268 | 4169,0 1269 | 4174,0 1270 | 4179,0 1271 | 4185,0 1272 | 4186,0 1273 | 4187,0 1274 | 4188,0 1275 | 4190,0 1276 | 4192,0 1277 | 4193,0 1278 | 4194,0 1279 | 4195,0 1280 | 4196,0 1281 | 4207,0 1282 | 4208,0 1283 | 4215,0 1284 | 4217,0 1285 | 4222,0 1286 | 4223,0 1287 | 4226,0 1288 | 4228,0 1289 | 4229,0 1290 | 4231,0 1291 | 4234,0 1292 | 4236,0 1293 | 4249,0 1294 | 4254,0 1295 | 4258,0 1296 | 4259,0 1297 | 4263,0 1298 | 4267,0 1299 | 4277,0 1300 | 4278,0 1301 | 4280,0 1302 | 4283,0 1303 | 4285,0 1304 | 4286,0 1305 | 4287,0 1306 | 4290,0 1307 | 4291,0 1308 | 4294,0 1309 | 4302,0 1310 | 4308,0 1311 | 4310,0 1312 | 4311,0 1313 | 4315,0 1314 | 4316,0 1315 | 4319,0 1316 | 4331,0 1317 | 4338,0 1318 | 4339,0 1319 | 4340,0 1320 | 4344,0 1321 | 4346,0 1322 | 4347,0 1323 | 4360,0 1324 | 4364,0 1325 | 4367,0 1326 | 4369,0 1327 | 4370,0 1328 | 4371,0 1329 | 4380,0 1330 | 4386,0 1331 | 4389,0 1332 | 4390,0 1333 | 4394,0 1334 | 4399,0 1335 | 4400,0 1336 | 4404,0 1337 | 4409,0 1338 | 4414,0 1339 | 4417,0 1340 | 4418,0 1341 | 4419,0 1342 | 4420,0 1343 | 4422,0 1344 | 4429,0 1345 | 4431,0 1346 | 4433,0 1347 | 4434,0 1348 | 4439,0 1349 | 4443,0 1350 | 4446,0 1351 | 4447,0 1352 | 4453,0 1353 | 4460,0 1354 | 4461,0 1355 | 4462,0 1356 | 4467,0 1357 | 4469,0 1358 | 4473,0 1359 | 4474,0 1360 | 4475,0 1361 | 4477,0 1362 | 4481,0 1363 | 4483,0 1364 | 4484,0 1365 | 4485,0 1366 | 4495,0 1367 | 4497,0 1368 | 4500,0 1369 | 4501,0 1370 | 4502,0 1371 | 4505,0 1372 | 4506,0 1373 | 4510,0 1374 | 4512,0 1375 | 4513,0 1376 | 4532,0 1377 | 4535,0 1378 | 4536,0 1379 | 4540,0 1380 | 4545,0 1381 | 4552,0 1382 | 4554,0 1383 | 4555,0 1384 | 4558,0 1385 | 4559,0 1386 | 4560,0 1387 | 4566,0 1388 | 4570,0 1389 | 4572,0 1390 | 4574,0 1391 | 4581,0 1392 | 4583,0 1393 | 4586,0 1394 | 4591,0 1395 | 4594,0 1396 | 4603,0 1397 | 4605,0 1398 | 4612,0 1399 | 4613,0 1400 | 4615,0 1401 | 4618,0 1402 | 4621,0 1403 | 4623,0 1404 | 4626,0 1405 | 4629,0 1406 | 4633,0 1407 | 4636,0 1408 | 4638,0 1409 | 4640,0 1410 | 4643,0 1411 | 4645,0 1412 | 4647,0 1413 | 4648,0 1414 | 4651,0 1415 | 4652,0 1416 | 4653,0 1417 | 4654,0 1418 | 4660,0 1419 | 4662,0 1420 | 4663,0 1421 | 4665,0 1422 | 4668,0 1423 | 4676,0 1424 | 4683,0 1425 | 4685,0 1426 | 4686,0 1427 | 4701,0 1428 | 4718,0 1429 | 4721,0 1430 | 4727,0 1431 | 4728,0 1432 | 4733,0 1433 | 4741,0 1434 | 4743,0 1435 | 4746,0 1436 | 4751,0 1437 | 4756,0 1438 | 4761,0 1439 | 4763,0 1440 | 4764,0 1441 | 4767,0 1442 | 4772,0 1443 | 4776,0 1444 | 4780,0 1445 | 4781,0 1446 | 4792,0 1447 | 4796,0 1448 | 4801,0 1449 | 4804,0 1450 | 4805,0 1451 | 4806,0 1452 | 4811,0 1453 | 4815,0 1454 | 4816,0 1455 | 4817,0 1456 | 4818,0 1457 | 4822,0 1458 | 4824,0 1459 | 4827,0 1460 | 4837,0 1461 | 4838,0 1462 | 4839,0 1463 | 4841,0 1464 | 4851,0 1465 | 4855,0 1466 | 4861,0 1467 | 4862,0 1468 | 4863,0 1469 | 4865,0 1470 | 4871,0 1471 | 4873,0 1472 | 4880,0 1473 | 4885,0 1474 | 4886,0 1475 | 4902,0 1476 | 4904,0 1477 | 4907,0 1478 | 4916,0 1479 | 4921,0 1480 | 4925,0 1481 | 4927,0 1482 | 4928,0 1483 | 4930,0 1484 | 4932,0 1485 | 4933,0 1486 | 4937,0 1487 | 4939,0 1488 | 4941,0 1489 | 4942,0 1490 | 4947,0 1491 | 4949,0 1492 | 4950,0 1493 | 4956,0 1494 | 4960,0 1495 | 4963,0 1496 | 4965,0 1497 | 4976,0 1498 | 4977,0 1499 | 4987,0 1500 | 4991,0 1501 | 4994,0 1502 | 4999,0 1503 | 5003,0 1504 | 5006,0 1505 | 5009,0 1506 | 5011,0 1507 | 5012,0 1508 | 5014,0 1509 | 5020,0 1510 | 5021,0 1511 | 5023,0 1512 | 5026,0 1513 | 5030,0 1514 | 5031,0 1515 | 5036,0 1516 | 5042,0 1517 | 5045,0 1518 | 5048,0 1519 | 5051,0 1520 | 5053,0 1521 | 5054,0 1522 | 5057,0 1523 | 5058,0 1524 | 5066,0 1525 | 5070,0 1526 | 5077,0 1527 | 5081,0 1528 | 5084,0 1529 | 5086,0 1530 | 5090,0 1531 | 5091,0 1532 | 5093,0 1533 | 5100,0 1534 | 5108,0 1535 | 5111,0 1536 | 5112,0 1537 | 5118,0 1538 | 5121,0 1539 | 5123,0 1540 | 5129,0 1541 | 5133,0 1542 | 5143,0 1543 | 5147,0 1544 | 5151,0 1545 | 5156,0 1546 | 5158,0 1547 | 5161,0 1548 | 5163,0 1549 | 5167,0 1550 | 5173,0 1551 | 5205,0 1552 | 5214,0 1553 | 5215,0 1554 | 5216,0 1555 | 5217,0 1556 | 5225,0 1557 | 5237,0 1558 | 5239,0 1559 | 5240,0 1560 | 5241,0 1561 | 5246,0 1562 | 5250,0 1563 | 5253,0 1564 | 5258,0 1565 | 5261,0 1566 | 5268,0 1567 | 5275,0 1568 | 5277,0 1569 | 5279,0 1570 | 5288,0 1571 | 5289,0 1572 | 5294,0 1573 | 5303,0 1574 | 5307,0 1575 | 5311,0 1576 | 5312,0 1577 | 5314,0 1578 | 5318,0 1579 | 5327,0 1580 | 5329,0 1581 | 5333,0 1582 | 5334,0 1583 | 5340,0 1584 | 5348,0 1585 | 5358,0 1586 | 5360,0 1587 | 5361,0 1588 | 5363,0 1589 | 5364,0 1590 | 5369,0 1591 | 5370,0 1592 | 5374,0 1593 | 5376,0 1594 | 5388,0 1595 | 5390,0 1596 | 5393,0 1597 | 5394,0 1598 | 5395,0 1599 | 5398,0 1600 | 5399,0 1601 | 5401,0 1602 | 5402,0 1603 | 5405,0 1604 | 5414,0 1605 | 5415,0 1606 | 5419,0 1607 | 5421,0 1608 | 5422,0 1609 | 5424,0 1610 | 5427,0 1611 | 5429,0 1612 | 5431,0 1613 | 5433,0 1614 | 5434,0 1615 | 5435,0 1616 | 5436,0 1617 | 5438,0 1618 | 5440,0 1619 | 5441,0 1620 | 5447,0 1621 | 5451,0 1622 | 5453,0 1623 | 5456,0 1624 | 5457,0 1625 | 5463,0 1626 | 5464,0 1627 | 5470,0 1628 | 5472,0 1629 | 5474,0 1630 | 5478,0 1631 | 5483,0 1632 | 5490,0 1633 | 5500,0 1634 | 5504,0 1635 | 5508,0 1636 | 5511,0 1637 | 5512,0 1638 | 5513,0 1639 | 5516,0 1640 | 5523,0 1641 | 5527,0 1642 | 5530,0 1643 | 5533,0 1644 | 5536,0 1645 | 5537,0 1646 | 5542,0 1647 | 5543,0 1648 | 5546,0 1649 | 5549,0 1650 | 5550,0 1651 | 5551,0 1652 | 5562,0 1653 | 5566,0 1654 | 5568,0 1655 | 5571,0 1656 | 5572,0 1657 | 5574,0 1658 | 5583,0 1659 | 5585,0 1660 | 5591,0 1661 | 5596,0 1662 | 5597,0 1663 | 5601,0 1664 | 5606,0 1665 | 5607,0 1666 | 5610,0 1667 | 5615,0 1668 | 5616,0 1669 | 5623,0 1670 | 5630,0 1671 | 5636,0 1672 | 5637,0 1673 | 5639,0 1674 | 5640,0 1675 | 5643,0 1676 | 5648,0 1677 | 5649,0 1678 | 5660,0 1679 | 5666,0 1680 | 5667,0 1681 | 5678,0 1682 | 5679,0 1683 | 5681,0 1684 | 5682,0 1685 | 5691,0 1686 | 5696,0 1687 | 5697,0 1688 | 5700,0 1689 | 5701,0 1690 | 5702,0 1691 | 5708,0 1692 | 5709,0 1693 | 5718,0 1694 | 5723,0 1695 | 5725,0 1696 | 5728,0 1697 | 5731,0 1698 | 5735,0 1699 | 5737,0 1700 | 5738,0 1701 | 5742,0 1702 | 5747,0 1703 | 5749,0 1704 | 5750,0 1705 | 5755,0 1706 | 5756,0 1707 | 5761,0 1708 | 5762,0 1709 | 5767,0 1710 | 5768,0 1711 | 5770,0 1712 | 5773,0 1713 | 5774,0 1714 | 5779,0 1715 | 5782,0 1716 | 5785,0 1717 | 5786,0 1718 | 5787,0 1719 | 5788,0 1720 | 5796,0 1721 | 5802,0 1722 | 5806,0 1723 | 5809,0 1724 | 5810,0 1725 | 5811,0 1726 | 5813,0 1727 | 5820,0 1728 | 5823,0 1729 | 5830,0 1730 | 5831,0 1731 | 5838,0 1732 | 5839,0 1733 | 5844,0 1734 | 5846,0 1735 | 5851,0 1736 | 5852,0 1737 | 5857,0 1738 | 5859,0 1739 | 5860,0 1740 | 5862,0 1741 | 5865,0 1742 | 5866,0 1743 | 5871,0 1744 | 5872,0 1745 | 5877,0 1746 | 5878,0 1747 | 5879,0 1748 | 5880,0 1749 | 5895,0 1750 | 5897,0 1751 | 5910,0 1752 | 5914,0 1753 | 5915,0 1754 | 5917,0 1755 | 5924,0 1756 | 5926,0 1757 | 5931,0 1758 | 5936,0 1759 | 5940,0 1760 | 5941,0 1761 | 5945,0 1762 | 5946,0 1763 | 5948,0 1764 | 5951,0 1765 | 5967,0 1766 | 5968,0 1767 | 5969,0 1768 | 5970,0 1769 | 5971,0 1770 | 5973,0 1771 | 5976,0 1772 | 5977,0 1773 | 5984,0 1774 | 5986,0 1775 | 5993,0 1776 | 5994,0 1777 | 6005,0 1778 | 6006,0 1779 | 6008,0 1780 | 6010,0 1781 | 6011,0 1782 | 6014,0 1783 | 6016,0 1784 | 6018,0 1785 | 6021,0 1786 | 6025,0 1787 | 6028,0 1788 | 6029,0 1789 | 6035,0 1790 | 6040,0 1791 | 6042,0 1792 | 6044,0 1793 | 6046,0 1794 | 6052,0 1795 | 6054,0 1796 | 6062,0 1797 | 6063,0 1798 | 6067,0 1799 | 6068,0 1800 | 6077,0 1801 | 6079,0 1802 | 6080,0 1803 | 6081,0 1804 | 6082,0 1805 | 6089,0 1806 | 6095,0 1807 | 6101,0 1808 | 6107,0 1809 | 6114,0 1810 | 6117,0 1811 | 6121,0 1812 | 6122,0 1813 | 6124,0 1814 | 6129,0 1815 | 6131,0 1816 | 6136,0 1817 | 6139,0 1818 | 6142,0 1819 | 6143,0 1820 | 6144,0 1821 | 6149,0 1822 | 6155,0 1823 | 6157,0 1824 | 6158,0 1825 | 6161,0 1826 | 6168,0 1827 | 6172,0 1828 | 6176,0 1829 | 6177,0 1830 | 6179,0 1831 | 6180,0 1832 | 6182,0 1833 | 6186,0 1834 | 6189,0 1835 | 6190,0 1836 | 6194,0 1837 | 6204,0 1838 | 6205,0 1839 | 6209,0 1840 | 6210,0 1841 | 6212,0 1842 | 6214,0 1843 | 6221,0 1844 | 6225,0 1845 | 6228,0 1846 | 6229,0 1847 | 6231,0 1848 | 6235,0 1849 | 6236,0 1850 | 6237,0 1851 | 6238,0 1852 | 6239,0 1853 | 6242,0 1854 | 6249,0 1855 | 6250,0 1856 | 6251,0 1857 | 6252,0 1858 | 6260,0 1859 | 6264,0 1860 | 6266,0 1861 | 6270,0 1862 | 6275,0 1863 | 6279,0 1864 | 6280,0 1865 | 6284,0 1866 | 6285,0 1867 | 6286,0 1868 | 6287,0 1869 | 6288,0 1870 | 6289,0 1871 | 6290,0 1872 | 6291,0 1873 | 6295,0 1874 | 6298,0 1875 | 6307,0 1876 | 6308,0 1877 | 6309,0 1878 | 6313,0 1879 | 6316,0 1880 | 6319,0 1881 | 6321,0 1882 | 6324,0 1883 | 6327,0 1884 | 6333,0 1885 | 6351,0 1886 | 6352,0 1887 | 6353,0 1888 | 6357,0 1889 | 6359,0 1890 | 6360,0 1891 | 6364,0 1892 | 6367,0 1893 | 6368,0 1894 | 6377,0 1895 | 6378,0 1896 | 6379,0 1897 | 6381,0 1898 | 6390,0 1899 | 6401,0 1900 | 6408,0 1901 | 6409,0 1902 | 6411,0 1903 | 6419,0 1904 | 6424,0 1905 | 6426,0 1906 | 6428,0 1907 | 6431,0 1908 | 6432,0 1909 | 6433,0 1910 | 6435,0 1911 | 6437,0 1912 | 6439,0 1913 | 6442,0 1914 | 6444,0 1915 | 6447,0 1916 | 6456,0 1917 | 6457,0 1918 | 6460,0 1919 | 6468,0 1920 | 6471,0 1921 | 6475,0 1922 | 6476,0 1923 | 6479,0 1924 | 6483,0 1925 | 6487,0 1926 | 6488,0 1927 | 6489,0 1928 | 6496,0 1929 | 6498,0 1930 | 6502,0 1931 | 6503,0 1932 | 6507,0 1933 | 6508,0 1934 | 6509,0 1935 | 6517,0 1936 | 6521,0 1937 | 6522,0 1938 | 6524,0 1939 | 6526,0 1940 | 6531,0 1941 | 6533,0 1942 | 6538,0 1943 | 6539,0 1944 | 6544,0 1945 | 6557,0 1946 | 6558,0 1947 | 6562,0 1948 | 6563,0 1949 | 6564,0 1950 | 6574,0 1951 | 6578,0 1952 | 6581,0 1953 | 6584,0 1954 | 6587,0 1955 | 6589,0 1956 | 6590,0 1957 | 6592,0 1958 | 6595,0 1959 | 6599,0 1960 | 6600,0 1961 | 6606,0 1962 | 6609,0 1963 | 6612,0 1964 | 6615,0 1965 | 6618,0 1966 | 6620,0 1967 | 6623,0 1968 | 6633,0 1969 | 6639,0 1970 | 6640,0 1971 | 6641,0 1972 | 6645,0 1973 | 6650,0 1974 | 6651,0 1975 | 6652,0 1976 | 6657,0 1977 | 6659,0 1978 | 6666,0 1979 | 6671,0 1980 | 6673,0 1981 | 6674,0 1982 | 6677,0 1983 | 6680,0 1984 | 6684,0 1985 | 6685,0 1986 | 6691,0 1987 | 6692,0 1988 | 6696,0 1989 | 6698,0 1990 | 6704,0 1991 | 6705,0 1992 | 6710,0 1993 | 6713,0 1994 | 6715,0 1995 | 6717,0 1996 | 6718,0 1997 | 6720,0 1998 | 6728,0 1999 | 6732,0 2000 | 6733,0 2001 | 6739,0 2002 | 6740,0 2003 | 6741,0 2004 | 6743,0 2005 | 6747,0 2006 | 6750,0 2007 | 6752,0 2008 | 6753,0 2009 | 6755,0 2010 | 6761,0 2011 | 6763,0 2012 | 6768,0 2013 | 6770,0 2014 | 6771,0 2015 | 6777,0 2016 | 6778,0 2017 | 6780,0 2018 | 6782,0 2019 | 6786,0 2020 | 6791,0 2021 | 6797,0 2022 | 6798,0 2023 | 6803,0 2024 | 6805,0 2025 | 6812,0 2026 | 6816,0 2027 | 6818,0 2028 | 6822,0 2029 | 6825,0 2030 | 6826,0 2031 | 6827,0 2032 | 6829,0 2033 | 6831,0 2034 | 6836,0 2035 | 6838,0 2036 | 6840,0 2037 | 6842,0 2038 | 6846,0 2039 | 6851,0 2040 | 6853,0 2041 | 6856,0 2042 | 6859,0 2043 | 6865,0 2044 | 6866,0 2045 | 6868,0 2046 | 6869,0 2047 | 6871,0 2048 | 6873,0 2049 | 6886,0 2050 | 6887,0 2051 | 6888,0 2052 | 6889,0 2053 | 6891,0 2054 | 6894,0 2055 | 6895,0 2056 | 6899,0 2057 | 6901,0 2058 | 6902,0 2059 | 6904,0 2060 | 6906,0 2061 | 6922,0 2062 | 6923,0 2063 | 6924,0 2064 | 6927,0 2065 | 6934,0 2066 | 6938,0 2067 | 6941,0 2068 | 6942,0 2069 | 6944,0 2070 | 6947,0 2071 | 6952,0 2072 | 6957,0 2073 | 6958,0 2074 | 6964,0 2075 | 6968,0 2076 | 6969,0 2077 | 6976,0 2078 | 6982,0 2079 | 6986,0 2080 | 6987,0 2081 | 6989,0 2082 | 6991,0 2083 | 6993,0 2084 | 6995,0 2085 | 6997,0 2086 | 7000,0 2087 | 7003,0 2088 | 7004,0 2089 | 7007,0 2090 | 7011,0 2091 | 7014,0 2092 | 7016,0 2093 | 7017,0 2094 | 7020,0 2095 | 7022,0 2096 | 7028,0 2097 | 7033,0 2098 | 7034,0 2099 | 7035,0 2100 | 7038,0 2101 | 7040,0 2102 | 7041,0 2103 | 7042,0 2104 | 7045,0 2105 | 7049,0 2106 | 7055,0 2107 | 7057,0 2108 | 7062,0 2109 | 7064,0 2110 | 7066,0 2111 | 7067,0 2112 | 7072,0 2113 | 7079,0 2114 | 7082,0 2115 | 7083,0 2116 | 7084,0 2117 | 7085,0 2118 | 7087,0 2119 | 7090,0 2120 | 7094,0 2121 | 7096,0 2122 | 7099,0 2123 | 7100,0 2124 | 7101,0 2125 | 7102,0 2126 | 7103,0 2127 | 7107,0 2128 | 7110,0 2129 | 7113,0 2130 | 7117,0 2131 | 7119,0 2132 | 7123,0 2133 | 7127,0 2134 | 7133,0 2135 | 7139,0 2136 | 7143,0 2137 | 7145,0 2138 | 7151,0 2139 | 7152,0 2140 | 7153,0 2141 | 7156,0 2142 | 7162,0 2143 | 7170,0 2144 | 7172,0 2145 | 7177,0 2146 | 7181,0 2147 | 7182,0 2148 | 7189,0 2149 | 7190,0 2150 | 7200,0 2151 | 7207,0 2152 | 7209,0 2153 | 7212,0 2154 | 7216,0 2155 | 7217,0 2156 | 7219,0 2157 | 7220,0 2158 | 7222,0 2159 | 7225,0 2160 | 7233,0 2161 | 7237,0 2162 | 7238,0 2163 | 7239,0 2164 | 7240,0 2165 | 7243,0 2166 | 7245,0 2167 | 7246,0 2168 | 7249,0 2169 | 7257,0 2170 | 7258,0 2171 | 7259,0 2172 | 7262,0 2173 | 7263,0 2174 | 7269,0 2175 | 7271,0 2176 | 7273,0 2177 | 7276,0 2178 | 7279,0 2179 | 7282,0 2180 | 7284,0 2181 | 7293,0 2182 | 7298,0 2183 | 7303,0 2184 | 7304,0 2185 | 7305,0 2186 | 7308,0 2187 | 7313,0 2188 | 7314,0 2189 | 7321,0 2190 | 7322,0 2191 | 7327,0 2192 | 7333,0 2193 | 7336,0 2194 | 7339,0 2195 | 7341,0 2196 | 7346,0 2197 | 7347,0 2198 | 7349,0 2199 | 7351,0 2200 | 7353,0 2201 | 7363,0 2202 | 7364,0 2203 | 7368,0 2204 | 7370,0 2205 | 7375,0 2206 | 7376,0 2207 | 7379,0 2208 | 7382,0 2209 | 7384,0 2210 | 7385,0 2211 | 7387,0 2212 | 7388,0 2213 | 7389,0 2214 | 7394,0 2215 | 7396,0 2216 | 7398,0 2217 | 7399,0 2218 | 7401,0 2219 | 7404,0 2220 | 7406,0 2221 | 7409,0 2222 | 7411,0 2223 | 7417,0 2224 | 7420,0 2225 | 7422,0 2226 | 7423,0 2227 | 7427,0 2228 | 7429,0 2229 | 7432,0 2230 | 7435,0 2231 | 7436,0 2232 | 7440,0 2233 | 7441,0 2234 | 7445,0 2235 | 7448,0 2236 | 7449,0 2237 | 7450,0 2238 | 7454,0 2239 | 7455,0 2240 | 7460,0 2241 | 7462,0 2242 | 7464,0 2243 | 7466,0 2244 | 7468,0 2245 | 7469,0 2246 | 7471,0 2247 | 7472,0 2248 | 7483,0 2249 | 7484,0 2250 | 7485,0 2251 | 7486,0 2252 | 7487,0 2253 | 7489,0 2254 | 7492,0 2255 | 7495,0 2256 | 7499,0 2257 | 7500,0 2258 | 7506,0 2259 | 7508,0 2260 | 7509,0 2261 | 7511,0 2262 | 7516,0 2263 | 7524,0 2264 | 7538,0 2265 | 7539,0 2266 | 7541,0 2267 | 7546,0 2268 | 7549,0 2269 | 7562,0 2270 | 7564,0 2271 | 7567,0 2272 | 7572,0 2273 | 7574,0 2274 | 7575,0 2275 | 7586,0 2276 | 7592,0 2277 | 7596,0 2278 | 7597,0 2279 | 7599,0 2280 | 7606,0 2281 | 7615,0 2282 | 7618,0 2283 | 7620,0 2284 | 7624,0 2285 | 7625,0 2286 | 7629,0 2287 | 7632,0 2288 | 7636,0 2289 | 7637,0 2290 | 7646,0 2291 | 7655,0 2292 | 7658,0 2293 | 7660,0 2294 | 7664,0 2295 | 7665,0 2296 | 7666,0 2297 | 7667,0 2298 | 7673,0 2299 | 7676,0 2300 | 7682,0 2301 | 7684,0 2302 | 7690,0 2303 | 7697,0 2304 | 7700,0 2305 | 7704,0 2306 | 7705,0 2307 | 7706,0 2308 | 7708,0 2309 | 7709,0 2310 | 7710,0 2311 | 7713,0 2312 | 7716,0 2313 | 7726,0 2314 | 7729,0 2315 | 7730,0 2316 | 7732,0 2317 | 7734,0 2318 | 7740,0 2319 | 7741,0 2320 | 7745,0 2321 | 7757,0 2322 | 7762,0 2323 | 7770,0 2324 | 7776,0 2325 | 7777,0 2326 | 7778,0 2327 | 7779,0 2328 | 7782,0 2329 | 7786,0 2330 | 7791,0 2331 | 7792,0 2332 | 7794,0 2333 | 7795,0 2334 | 7796,0 2335 | 7798,0 2336 | 7805,0 2337 | 7806,0 2338 | 7808,0 2339 | 7811,0 2340 | 7814,0 2341 | 7819,0 2342 | 7820,0 2343 | 7825,0 2344 | 7829,0 2345 | 7834,0 2346 | 7836,0 2347 | 7838,0 2348 | 7841,0 2349 | 7845,0 2350 | 7846,0 2351 | 7853,0 2352 | 7856,0 2353 | 7858,0 2354 | 7859,0 2355 | 7866,0 2356 | 7875,0 2357 | 7879,0 2358 | 7884,0 2359 | 7886,0 2360 | 7890,0 2361 | 7892,0 2362 | 7896,0 2363 | 7899,0 2364 | 7900,0 2365 | 7901,0 2366 | 7904,0 2367 | 7911,0 2368 | 7917,0 2369 | 7919,0 2370 | 7920,0 2371 | 7921,0 2372 | 7922,0 2373 | 7925,0 2374 | 7927,0 2375 | 7928,0 2376 | 7931,0 2377 | 7942,0 2378 | 7946,0 2379 | 7947,0 2380 | 7948,0 2381 | 7951,0 2382 | 7956,0 2383 | 7961,0 2384 | 7964,0 2385 | 7966,0 2386 | 7967,0 2387 | 7974,0 2388 | 7975,0 2389 | 7979,0 2390 | 7985,0 2391 | 7986,0 2392 | 7993,0 2393 | 7995,0 2394 | 7997,0 2395 | 7998,0 2396 | 8004,0 2397 | 8007,0 2398 | 8011,0 2399 | 8014,0 2400 | 8022,0 2401 | 8027,0 2402 | 8033,0 2403 | 8041,0 2404 | 8042,0 2405 | 8046,0 2406 | 8048,0 2407 | 8050,0 2408 | 8051,0 2409 | 8052,0 2410 | 8053,0 2411 | 8054,0 2412 | 8059,0 2413 | 8063,0 2414 | 8072,0 2415 | 8075,0 2416 | 8076,0 2417 | 8077,0 2418 | 8078,0 2419 | 8080,0 2420 | 8082,0 2421 | 8086,0 2422 | 8090,0 2423 | 8092,0 2424 | 8093,0 2425 | 8099,0 2426 | 8104,0 2427 | 8107,0 2428 | 8108,0 2429 | 8114,0 2430 | 8115,0 2431 | 8117,0 2432 | 8123,0 2433 | 8124,0 2434 | 8127,0 2435 | 8132,0 2436 | 8134,0 2437 | 8139,0 2438 | 8145,0 2439 | 8148,0 2440 | 8151,0 2441 | 8152,0 2442 | 8153,0 2443 | 8157,0 2444 | 8160,0 2445 | 8166,0 2446 | 8167,0 2447 | 8173,0 2448 | 8174,0 2449 | 8178,0 2450 | 8179,0 2451 | 8185,0 2452 | 8186,0 2453 | 8192,0 2454 | 8193,0 2455 | 8194,0 2456 | 8197,0 2457 | 8198,0 2458 | 8199,0 2459 | 8200,0 2460 | 8206,0 2461 | 8207,0 2462 | 8220,0 2463 | 8222,0 2464 | 8227,0 2465 | 8228,0 2466 | 8229,0 2467 | 8230,0 2468 | 8233,0 2469 | 8248,0 2470 | 8249,0 2471 | 8255,0 2472 | 8260,0 2473 | 8263,0 2474 | 8265,0 2475 | 8268,0 2476 | 8269,0 2477 | 8272,0 2478 | 8273,0 2479 | 8275,0 2480 | 8277,0 2481 | 8281,0 2482 | 8282,0 2483 | 8290,0 2484 | 8293,0 2485 | 8299,0 2486 | 8302,0 2487 | 8303,0 2488 | 8305,0 2489 | 8306,0 2490 | 8307,0 2491 | 8308,0 2492 | 8313,0 2493 | 8316,0 2494 | 8319,0 2495 | 8322,0 2496 | 8323,0 2497 | 8325,0 2498 | 8326,0 2499 | 8327,0 2500 | 8328,0 2501 | 8331,0 2502 | 8333,0 2503 | 8336,0 2504 | 8338,0 2505 | 8340,0 2506 | 8342,0 2507 | 8343,0 2508 | 8353,0 2509 | 8354,0 2510 | 8357,0 2511 | 8358,0 2512 | 8359,0 2513 | 8373,0 2514 | 8376,0 2515 | 8379,0 2516 | 8380,0 2517 | 8381,0 2518 | 8384,0 2519 | 8395,0 2520 | 8398,0 2521 | 8403,0 2522 | 8407,0 2523 | 8413,0 2524 | 8417,0 2525 | 8420,0 2526 | 8421,0 2527 | 8424,0 2528 | 8426,0 2529 | 8427,0 2530 | 8438,0 2531 | 8439,0 2532 | 8442,0 2533 | 8449,0 2534 | 8456,0 2535 | 8460,0 2536 | 8462,0 2537 | 8465,0 2538 | 8466,0 2539 | 8467,0 2540 | 8469,0 2541 | 8470,0 2542 | 8474,0 2543 | 8479,0 2544 | 8481,0 2545 | 8482,0 2546 | 8485,0 2547 | 8488,0 2548 | 8492,0 2549 | 8493,0 2550 | 8495,0 2551 | 8499,0 2552 | 8501,0 2553 | 8519,0 2554 | 8521,0 2555 | 8525,0 2556 | 8527,0 2557 | 8529,0 2558 | 8532,0 2559 | 8534,0 2560 | 8535,0 2561 | 8537,0 2562 | 8544,0 2563 | 8548,0 2564 | 8549,0 2565 | 8552,0 2566 | 8554,0 2567 | 8563,0 2568 | 8564,0 2569 | 8565,0 2570 | 8566,0 2571 | 8568,0 2572 | 8569,0 2573 | 8573,0 2574 | 8583,0 2575 | 8588,0 2576 | 8590,0 2577 | 8592,0 2578 | 8593,0 2579 | 8594,0 2580 | 8597,0 2581 | 8600,0 2582 | 8601,0 2583 | 8602,0 2584 | 8603,0 2585 | 8604,0 2586 | 8605,0 2587 | 8611,0 2588 | 8614,0 2589 | 8616,0 2590 | 8617,0 2591 | 8619,0 2592 | 8626,0 2593 | 8629,0 2594 | 8630,0 2595 | 8632,0 2596 | 8634,0 2597 | 8641,0 2598 | 8645,0 2599 | 8649,0 2600 | 8652,0 2601 | 8666,0 2602 | 8671,0 2603 | 8672,0 2604 | 8675,0 2605 | 8678,0 2606 | 8679,0 2607 | 8682,0 2608 | 8687,0 2609 | 8701,0 2610 | 8703,0 2611 | 8707,0 2612 | 8713,0 2613 | 8716,0 2614 | 8719,0 2615 | 8725,0 2616 | 8730,0 2617 | 8731,0 2618 | 8748,0 2619 | 8749,0 2620 | 8756,0 2621 | 8764,0 2622 | 8765,0 2623 | 8769,0 2624 | 8771,0 2625 | 8772,0 2626 | 8773,0 2627 | 8779,0 2628 | 8792,0 2629 | 8794,0 2630 | 8796,0 2631 | 8798,0 2632 | 8803,0 2633 | 8807,0 2634 | 8809,0 2635 | 8811,0 2636 | 8813,0 2637 | 8814,0 2638 | 8818,0 2639 | 8819,0 2640 | 8820,0 2641 | 8821,0 2642 | 8822,0 2643 | 8824,0 2644 | 8826,0 2645 | 8827,0 2646 | 8828,0 2647 | 8833,0 2648 | 8834,0 2649 | 8845,0 2650 | 8847,0 2651 | 8849,0 2652 | 8861,0 2653 | 8867,0 2654 | 8868,0 2655 | 8870,0 2656 | 8873,0 2657 | 8874,0 2658 | 8876,0 2659 | 8877,0 2660 | 8879,0 2661 | 8882,0 2662 | 8884,0 2663 | 8889,0 2664 | 8891,0 2665 | 8894,0 2666 | 8895,0 2667 | 8897,0 2668 | 8898,0 2669 | 8901,0 2670 | 8904,0 2671 | 8909,0 2672 | 8910,0 2673 | 8911,0 2674 | 8915,0 2675 | 8917,0 2676 | 8918,0 2677 | 8919,0 2678 | 8922,0 2679 | 8925,0 2680 | 8928,0 2681 | 8929,0 2682 | 8930,0 2683 | 8932,0 2684 | 8937,0 2685 | 8940,0 2686 | 8943,0 2687 | 8950,0 2688 | 8951,0 2689 | 8954,0 2690 | 8958,0 2691 | 8960,0 2692 | 8964,0 2693 | 8975,0 2694 | 8977,0 2695 | 8981,0 2696 | 8982,0 2697 | 8984,0 2698 | 8988,0 2699 | 8990,0 2700 | 8991,0 2701 | 8995,0 2702 | 8997,0 2703 | 9003,0 2704 | 9004,0 2705 | 9010,0 2706 | 9011,0 2707 | 9013,0 2708 | 9014,0 2709 | 9015,0 2710 | 9017,0 2711 | 9019,0 2712 | 9021,0 2713 | 9024,0 2714 | 9032,0 2715 | 9035,0 2716 | 9036,0 2717 | 9037,0 2718 | 9043,0 2719 | 9046,0 2720 | 9048,0 2721 | 9049,0 2722 | 9050,0 2723 | 9056,0 2724 | 9063,0 2725 | 9065,0 2726 | 9066,0 2727 | 9068,0 2728 | 9069,0 2729 | 9070,0 2730 | 9073,0 2731 | 9076,0 2732 | 9091,0 2733 | 9092,0 2734 | 9104,0 2735 | 9105,0 2736 | 9108,0 2737 | 9111,0 2738 | 9115,0 2739 | 9117,0 2740 | 9122,0 2741 | 9125,0 2742 | 9127,0 2743 | 9129,0 2744 | 9133,0 2745 | 9136,0 2746 | 9138,0 2747 | 9140,0 2748 | 9147,0 2749 | 9150,0 2750 | 9152,0 2751 | 9153,0 2752 | 9155,0 2753 | 9158,0 2754 | 9160,0 2755 | 9163,0 2756 | 9165,0 2757 | 9167,0 2758 | 9168,0 2759 | 9170,0 2760 | 9176,0 2761 | 9178,0 2762 | 9184,0 2763 | 9186,0 2764 | 9188,0 2765 | 9189,0 2766 | 9190,0 2767 | 9196,0 2768 | 9198,0 2769 | 9199,0 2770 | 9200,0 2771 | 9201,0 2772 | 9202,0 2773 | 9204,0 2774 | 9205,0 2775 | 9213,0 2776 | 9214,0 2777 | 9224,0 2778 | 9227,0 2779 | 9228,0 2780 | 9229,0 2781 | 9234,0 2782 | 9236,0 2783 | 9241,0 2784 | 9243,0 2785 | 9245,0 2786 | 9256,0 2787 | 9258,0 2788 | 9261,0 2789 | 9274,0 2790 | 9279,0 2791 | 9282,0 2792 | 9284,0 2793 | 9285,0 2794 | 9291,0 2795 | 9295,0 2796 | 9299,0 2797 | 9302,0 2798 | 9304,0 2799 | 9305,0 2800 | 9306,0 2801 | 9310,0 2802 | 9312,0 2803 | 9316,0 2804 | 9318,0 2805 | 9323,0 2806 | 9326,0 2807 | 9327,0 2808 | 9328,0 2809 | 9331,0 2810 | 9335,0 2811 | 9336,0 2812 | 9340,0 2813 | 9349,0 2814 | 9352,0 2815 | 9353,0 2816 | 9354,0 2817 | 9356,0 2818 | 9357,0 2819 | 9358,0 2820 | 9359,0 2821 | 9364,0 2822 | 9366,0 2823 | 9369,0 2824 | 9370,0 2825 | 9379,0 2826 | 9381,0 2827 | 9383,0 2828 | 9389,0 2829 | 9390,0 2830 | 9392,0 2831 | 9394,0 2832 | 9398,0 2833 | 9399,0 2834 | 9400,0 2835 | 9407,0 2836 | 9409,0 2837 | 9412,0 2838 | 9413,0 2839 | 9415,0 2840 | 9419,0 2841 | 9423,0 2842 | 9424,0 2843 | 9426,0 2844 | 9427,0 2845 | 9428,0 2846 | 9429,0 2847 | 9433,0 2848 | 9437,0 2849 | 9440,0 2850 | 9442,0 2851 | 9443,0 2852 | 9444,0 2853 | 9447,0 2854 | 9459,0 2855 | 9461,0 2856 | 9462,0 2857 | 9464,0 2858 | 9473,0 2859 | 9475,0 2860 | 9476,0 2861 | 9477,0 2862 | 9478,0 2863 | 9479,0 2864 | 9483,0 2865 | 9487,0 2866 | 9494,0 2867 | 9497,0 2868 | 9498,0 2869 | 9506,0 2870 | 9512,0 2871 | 9514,0 2872 | 9515,0 2873 | 9516,0 2874 | 9517,0 2875 | 9518,0 2876 | 9521,0 2877 | 9523,0 2878 | 9527,0 2879 | 9528,0 2880 | 9530,0 2881 | 9532,0 2882 | 9534,0 2883 | 9535,0 2884 | 9536,0 2885 | 9543,0 2886 | 9544,0 2887 | 9545,0 2888 | 9546,0 2889 | 9549,0 2890 | 9558,0 2891 | 9560,0 2892 | 9561,0 2893 | 9570,0 2894 | 9573,0 2895 | 9578,0 2896 | 9584,0 2897 | 9587,0 2898 | 9588,0 2899 | 9599,0 2900 | 9601,0 2901 | 9604,0 2902 | 9614,0 2903 | 9615,0 2904 | 9621,0 2905 | 9622,0 2906 | 9623,0 2907 | 9624,0 2908 | 9626,0 2909 | 9628,0 2910 | 9630,0 2911 | 9631,0 2912 | 9633,0 2913 | 9635,0 2914 | 9637,0 2915 | 9641,0 2916 | 9647,0 2917 | 9648,0 2918 | 9649,0 2919 | 9658,0 2920 | 9662,0 2921 | 9668,0 2922 | 9671,0 2923 | 9676,0 2924 | 9677,0 2925 | 9679,0 2926 | 9682,0 2927 | 9685,0 2928 | 9689,0 2929 | 9692,0 2930 | 9693,0 2931 | 9694,0 2932 | 9696,0 2933 | 9700,0 2934 | 9711,0 2935 | 9713,0 2936 | 9720,0 2937 | 9721,0 2938 | 9725,0 2939 | 9726,0 2940 | 9727,0 2941 | 9735,0 2942 | 9740,0 2943 | 9742,0 2944 | 9743,0 2945 | 9747,0 2946 | 9748,0 2947 | 9751,0 2948 | 9758,0 2949 | 9767,0 2950 | 9768,0 2951 | 9773,0 2952 | 9777,0 2953 | 9781,0 2954 | 9784,0 2955 | 9786,0 2956 | 9789,0 2957 | 9792,0 2958 | 9793,0 2959 | 9798,0 2960 | 9799,0 2961 | 9802,0 2962 | 9803,0 2963 | 9804,0 2964 | 9805,0 2965 | 9807,0 2966 | 9809,0 2967 | 9811,0 2968 | 9814,0 2969 | 9817,0 2970 | 9821,0 2971 | 9824,0 2972 | 9825,0 2973 | 9827,0 2974 | 9839,0 2975 | 9840,0 2976 | 9843,0 2977 | 9844,0 2978 | 9845,0 2979 | 9847,0 2980 | 9848,0 2981 | 9851,0 2982 | 9852,0 2983 | 9855,0 2984 | 9856,0 2985 | 9863,0 2986 | 9867,0 2987 | 9871,0 2988 | 9876,0 2989 | 9879,0 2990 | 9882,0 2991 | 9891,0 2992 | 9892,0 2993 | 9893,0 2994 | 9895,0 2995 | 9899,0 2996 | 9900,0 2997 | 9902,0 2998 | 9903,0 2999 | 9904,0 3000 | 9908,0 3001 | 9913,0 3002 | 9914,0 3003 | 9917,0 3004 | 9922,0 3005 | 9924,0 3006 | 9926,0 3007 | 9927,0 3008 | 9928,0 3009 | 9929,0 3010 | 9936,0 3011 | 9939,0 3012 | 9947,0 3013 | 9951,0 3014 | 9954,0 3015 | 9956,0 3016 | 9957,0 3017 | 9959,0 3018 | 9962,0 3019 | 9964,0 3020 | 9966,0 3021 | 9968,0 3022 | 9969,0 3023 | 9970,0 3024 | 9975,0 3025 | 9977,0 3026 | 9981,0 3027 | 9993,0 3028 | 9996,0 3029 | 9997,0 3030 | 9999,0 3031 | 10002,0 3032 | 10007,0 3033 | 10015,0 3034 | 10019,0 3035 | 10022,0 3036 | 10024,0 3037 | 10026,0 3038 | 10033,0 3039 | 10043,0 3040 | 10046,0 3041 | 10051,0 3042 | 10053,0 3043 | 10062,0 3044 | 10063,0 3045 | 10065,0 3046 | 10068,0 3047 | 10078,0 3048 | 10086,0 3049 | 10094,0 3050 | 10095,0 3051 | 10096,0 3052 | 10097,0 3053 | 10103,0 3054 | 10104,0 3055 | 10108,0 3056 | 10122,0 3057 | 10123,0 3058 | 10128,0 3059 | 10131,0 3060 | 10133,0 3061 | 10134,0 3062 | 10135,0 3063 | 10145,0 3064 | 10148,0 3065 | 10154,0 3066 | 10155,0 3067 | 10158,0 3068 | 10160,0 3069 | 10161,0 3070 | 10162,0 3071 | 10165,0 3072 | 10166,0 3073 | 10167,0 3074 | 10170,0 3075 | 10178,0 3076 | 10180,0 3077 | 10181,0 3078 | 10185,0 3079 | 10188,0 3080 | 10190,0 3081 | 10196,0 3082 | 10200,0 3083 | 10205,0 3084 | 10211,0 3085 | 10216,0 3086 | 10219,0 3087 | 10221,0 3088 | 10225,0 3089 | 10227,0 3090 | 10228,0 3091 | 10230,0 3092 | 10232,0 3093 | 10233,0 3094 | 10235,0 3095 | 10238,0 3096 | 10240,0 3097 | 10242,0 3098 | 10248,0 3099 | 10254,0 3100 | 10257,0 3101 | 10261,0 3102 | 10262,0 3103 | 10266,0 3104 | 10267,0 3105 | 10271,0 3106 | 10277,0 3107 | 10279,0 3108 | 10281,0 3109 | 10282,0 3110 | 10285,0 3111 | 10292,0 3112 | 10298,0 3113 | 10300,0 3114 | 10309,0 3115 | 10311,0 3116 | 10312,0 3117 | 10319,0 3118 | 10324,0 3119 | 10326,0 3120 | 10328,0 3121 | 10343,0 3122 | 10346,0 3123 | 10347,0 3124 | 10353,0 3125 | 10354,0 3126 | 10356,0 3127 | 10357,0 3128 | 10362,0 3129 | 10363,0 3130 | 10370,0 3131 | 10373,0 3132 | 10386,0 3133 | 10388,0 3134 | 10389,0 3135 | 10391,0 3136 | 10397,0 3137 | 10400,0 3138 | 10403,0 3139 | 10404,0 3140 | 10408,0 3141 | 10417,0 3142 | 10425,0 3143 | 10435,0 3144 | 10437,0 3145 | 10438,0 3146 | 10440,0 3147 | 10442,0 3148 | 10447,0 3149 | 10452,0 3150 | 10453,0 3151 | 10454,0 3152 | 10459,0 3153 | 10460,0 3154 | 10463,0 3155 | 10465,0 3156 | 10469,0 3157 | 10474,0 3158 | 10475,0 3159 | 10476,0 3160 | 10477,0 3161 | 10480,0 3162 | 10491,0 3163 | 10493,0 3164 | 10494,0 3165 | 10495,0 3166 | 10497,0 3167 | 10501,0 3168 | 10504,0 3169 | 10507,0 3170 | 10509,0 3171 | 10510,0 3172 | 10512,0 3173 | 10514,0 3174 | 10526,0 3175 | 10528,0 3176 | 10530,0 3177 | 10531,0 3178 | 10532,0 3179 | 10538,0 3180 | 10539,0 3181 | 10542,0 3182 | 10547,0 3183 | 10549,0 3184 | 10556,0 3185 | 10569,0 3186 | 10572,0 3187 | 10577,0 3188 | 10579,0 3189 | 10586,0 3190 | 10594,0 3191 | 10595,0 3192 | 10597,0 3193 | 10602,0 3194 | 10604,0 3195 | 10614,0 3196 | 10617,0 3197 | 10618,0 3198 | 10619,0 3199 | 10624,0 3200 | 10633,0 3201 | 10634,0 3202 | 10635,0 3203 | 10638,0 3204 | 10639,0 3205 | 10642,0 3206 | 10643,0 3207 | 10645,0 3208 | 10646,0 3209 | 10649,0 3210 | 10652,0 3211 | 10653,0 3212 | 10654,0 3213 | 10661,0 3214 | 10664,0 3215 | 10668,0 3216 | 10670,0 3217 | 10674,0 3218 | 10683,0 3219 | 10694,0 3220 | 10697,0 3221 | 10699,0 3222 | 10701,0 3223 | 10703,0 3224 | 10713,0 3225 | 10714,0 3226 | 10716,0 3227 | 10717,0 3228 | 10719,0 3229 | 10725,0 3230 | 10728,0 3231 | 10734,0 3232 | 10738,0 3233 | 10740,0 3234 | 10742,0 3235 | 10756,0 3236 | 10757,0 3237 | 10758,0 3238 | 10761,0 3239 | 10762,0 3240 | 10773,0 3241 | 10778,0 3242 | 10781,0 3243 | 10791,0 3244 | 10792,0 3245 | 10796,0 3246 | 10797,0 3247 | 10801,0 3248 | 10804,0 3249 | 10806,0 3250 | 10807,0 3251 | 10816,0 3252 | 10820,0 3253 | 10828,0 3254 | 10836,0 3255 | 10838,0 3256 | 10845,0 3257 | 10856,0 3258 | 10857,0 3259 | 10858,0 3260 | 10861,0 3261 | 10865,0 3262 | 10868,0 3263 | 10874,0 3264 | 10875,0 3265 | --------------------------------------------------------------------------------