python算法
Maro_13th
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Shannon 信息熵:python_code
信息熵代码来源于《机器学习》 from math import logimport numpy as npdef calcShannonEnt(dataset): numEntries =len(dataset) labelCounts = {} for favocter in dataset: setkeys = favocter[-1]原创 2017-11-01 09:34:20 · 742 阅读 · 0 评论 -
冒泡排序:python
# -*- coding: utf_8 -*-print(__doc__)dic = {}with open('G:/py_proj/test/flask.txt') as f: for char in f.read().replace(' ',''): if char in dic: dic[char] += 1 els原创 2017-11-01 09:46:21 · 399 阅读 · 0 评论 -
permutations
## data permutations# Python function to print permutations of a given listdef permutation(lst): # If lst is empty then there are no permutations if len(lst) == 0: return [] # If t翻译 2017-11-11 10:01:56 · 304 阅读 · 0 评论 -
python_socket_tcp
# -*- coding:utf-8 -*-import socketHOST='127.0.0.2' #服务端的IP地址PORT=50007 #服务端的端口号s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)try: s.connect((HOST,PORT))except Exception as e: print...原创 2018-03-30 21:41:00 · 247 阅读 · 0 评论 -
集成学习算法
本文来源于网络# coding=utf8from sklearn.model_selection import cross_val_scorecross_val_score()from sklearn import datasetsfrom sklearn.ensemble import RandomForestClassifier, ExtraTreesClassifier, Gra...翻译 2018-04-25 14:26:10 · 366 阅读 · 0 评论 -
逻辑回归-采用的是梯度上升
# 读取数据和分割数据from math import expimport numpy as npdef loadData(): dataMat=[];labelMat =[] fr = open('testSet.txt') for line in fr.readlines(): lineArr = line.strip().split() ...原创 2018-04-21 15:18:58 · 626 阅读 · 0 评论 -
python 模型的保存
来源于知乎模型上线一般通过java处理 此时最好用pmml,github上有sklearntopmml的模块可以免费使用,强烈推荐。 这和R语言有点类似完整的一个例子# conding = utf-8from sklearn import svmfrom sklearn.externals import joblibimport osX = [[0,1],[0,2]...原创 2018-04-25 14:59:14 · 5491 阅读 · 0 评论 -
机器学习-特征选择sbs
序列向后特征选择from itertools import combinationsimport numpy as npfrom sklearn.metrics import accuracy_scorefrom sklearn.model_selection import train_test_splitclass SBS(): def __init__(self, e...原创 2018-08-09 10:01:37 · 1805 阅读 · 0 评论
分享