31dcb31
joyvan 6 years ago
2 changed file(s) with 16 addition(s) and 60 deletion(s). Raw diff Collapse all Expand all
304304 "source": [
305305 "line = \"1 2 3 4 5\"\n",
306306 "numbers = line.split()\n",
307 "print (numbers)"
307 "print (numbers)\n",
308 "type(numbers)"
308309 ]
309310 },
310311 {
800801 },
801802 {
802803 "cell_type": "code",
803 "execution_count": 1,
804 "metadata": {},
805 "outputs": [
806 {
807 "data": {
808 "text/plain": [
809 "1"
810 ]
811 },
812 "execution_count": 1,
813 "metadata": {},
814 "output_type": "execute_result"
815 }
816 ],
804 "execution_count": null,
805 "metadata": {},
806 "outputs": [],
817807 "source": [
818808 "a = [10, 11, 12, 13, 11]\n",
819809 "a.index(11)"
828818 },
829819 {
830820 "cell_type": "code",
831 "execution_count": 2,
832 "metadata": {},
833 "outputs": [
834 {
835 "data": {
836 "text/plain": [
837 "2"
838 ]
839 },
840 "execution_count": 2,
841 "metadata": {},
842 "output_type": "execute_result"
843 }
844 ],
821 "execution_count": null,
822 "metadata": {},
823 "outputs": [],
845824 "source": [
846825 "a = [10, 11, 12, 13, 11]\n",
847826 "a.count(11)"
859859 "cell_type": "markdown",
860860 "metadata": {},
861861 "source": [
862 "运算|函数|\n",
863 "--- | --- \n",
862 "运算符|函数|\n",
863 ":---: | :---: \n",
864864 "`==` | `equal`\n",
865865 "`!=` | `not_equal`\n",
866866 "`>` | `greater`\n",
867867 "`>=` | `greater_equal`\n",
868868 "`<` | `less`\n",
869869 "`<=` | `less_equal`\n",
870 "`^` | `bitwise_xor`\n",
871 "`~` | `invert`\n",
872 "`>>` | `right_shift`\n",
873 "`<<` | `left_shift`\n",
874870 "\n",
875871 "数组元素的比对,我们可以直接使用运算符进行比较,比如判断数组中元素是否大于某个数:"
876872 ]
936932 "cell_type": "markdown",
937933 "metadata": {},
938934 "source": [
939 "比如判断数组某个区间的元素是否存在大于 `20`:"
935 "比如判断数组某个区间的元素是否存在大于 `20`的元素:"
940936 ]
941937 },
942938 {
959955 "cell_type": "markdown",
960956 "metadata": {},
961957 "source": [
962 "读写各种格式的文件,如下表所示:\n",
963 "\n",
964 "文件格式|使用的包|函数\n",
965 "----|----|----\n",
966 "txt | numpy | loadtxt, genfromtxt, fromfile, savetxt, tofile\n",
967 "csv | csv | reader, writer\n",
968 "Matlab | scipy.io | loadmat, savemat\n",
969 "hdf | pytables, h5py| \n",
970 "NetCDF | netCDF4, scipy.io.netcdf | netCDF4.Dataset, scipy.io.netcdf.netcdf_file\n",
971 "**文件格式**|**使用的包**|**备注**\n",
972 "wav | scipy.io.wavfile | 音频文件\n",
973 "jpeg,png,...| PIL, scipy.misc.pilutil | 图像文件\n",
974 "fits | pyfits | 天文图像\n"
975 ]
976 },
977 {
978 "cell_type": "markdown",
979 "metadata": {},
980 "source": [
981958 "`savetxt` 可以将数组写入文件,默认使用科学计数法的形式保存:"
982959 ]
983960 },
984961 {
985962 "cell_type": "code",
986 "execution_count": null,
963 "execution_count": 2,
987964 "metadata": {},
988965 "outputs": [],
989966 "source": [
15331510 "<img src=\"http://imgbed.momodel.cn/scikitlearn.png\" width=300 />\n",
15341511 "\n",
15351512 "+ **Python** 语言的机器学习工具\n",
1536 "+ `Scikit-learn` 包括许多知名的机器学习算法的实现\n",
1537 "+ `Scikit-learn` 文档完善,容易上手,丰富的 `API`"
1513 "+ `Scikit-learn` 包括大量常用的机器学习算法\n",
1514 "+ `Scikit-learn` 文档完善,容易上手"
15381515 ]
15391516 },
15401517 {
18021779 "\n",
18031780 "划分比例:\n",
18041781 "+ 训练集:70% 80% 75%\n",
1805 "+ 测试集:30% 20% 30%\n",
1782 "+ 测试集:30% 20% 25%\n",
18061783 "\n",
18071784 "<br>\n",
1808 "`sklearn.model_selection.train_test_split(arrays, *options)`\n",
1785 "`sklearn.model_selection.train_test_split(x, y, test_size, random_state )`\n",
18091786 " + `x`:数据集的特征值\n",
18101787 " + `y`: 数据集的标签值\n",
18111788 " + `test_size`: 如果是浮点数,表示测试集样本占比;如果是整数,表示测试集样本的数量。\n",