當前位置: 首頁>>代碼示例>>Python>>正文


Python LogisticRegression.classify方法代碼示例

本文整理匯總了Python中Bio.LogisticRegression.classify方法的典型用法代碼示例。如果您正苦於以下問題:Python LogisticRegression.classify方法的具體用法?Python LogisticRegression.classify怎麽用?Python LogisticRegression.classify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Bio.LogisticRegression的用法示例。


在下文中一共展示了LogisticRegression.classify方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: str

# 需要導入模塊: from Bio import LogisticRegression [as 別名]
# 或者: from Bio.LogisticRegression import classify [as 別名]
from Bio import LogisticRegression
import numpy as np


all_data = np.loadtxt("../datasets/iris/iris.data", delimiter=",",
                      dtype="float, float, float, float, S11")

xs = []
ys = []

for i in all_data:
    if 'virgi' not in str(i[-1]):
        xs.append([i[0], i[1], i[2], i[3]])
        if 'setosa' in str(i[-1]):
            ys.append(0)
        else:
            ys.append(1)

test_xs = xs.pop()
test_ys = ys.pop()


def show_progress(iteration, loglikelihood):
    print("Iteration:", iteration, "Log-likelihood function:", loglikelihood)

model = LogisticRegression.train(xs, ys, update_fn=show_progress)
print("This should be Iris-versic (1): {}".format(LogisticRegression.classify(model, test_xs)))
開發者ID:carlosp420,項目名稱:algorithms-exercises,代碼行數:29,代碼來源:using_biopython.py

示例2: get

# 需要導入模塊: from Bio import LogisticRegression [as 別名]
# 或者: from Bio.LogisticRegression import classify [as 別名]
	def get(self):
		offset   = int(self.get_argument('o',default='1'))
		rowcount = int(self.get_argument('r',default='10'))
		offset=(offset-1)*rowcount
		no = self.get_argument('no', default='')
		model_id = self.get_argument('model_id', default='')
		model_type = self.get_argument('model_type', default='')
		package=self.get_argument('model_name', default='')
		cur=self.db.getCursor()
		rowdata={}
		#查詢
		if no=='1':
			if model_type =='1':
				cur.execute(" select b.name,a.create_id,a.name,a.note,a.beta from public.logistis a "
				            " left join public.account b on a.create_id = b.id "
						"where a.id='%s'  "% (model_id) )
				rows = cur.fetchall()
				print(rows)
				rowdata['struct']="id,create_id,name,note,beta "
				rowdata['rows']= rows
			else:
				cur.execute(" select b.name,a.create_id,a.name,a.note,c.name,a.file_name from public.pymodel a "
					    " left join public.account b on a.create_id = b.id "
				            " left join public.model c on a.type = c.type "
					    " where a.id='%s' and a.type='%s' "% (model_id,model_type) )
				rows = cur.fetchall()
				rowdata['struct']="id,create_id,name,note,type,filename "
				rowdata['rows']= rows				
			self.response(rowdata)
		elif no=='2':
			if model_type=='1':
				beta = self.get_argument('beta', default='')
				model_data=self.get_argument('model', default='')
				a=[]
				q=0
				print(model_data)
				a=(list(eval(model_data)))	
				model=LogisticRegression.LogisticRegression()
				model.beta=(list(eval(beta)))
				rowdata={}
				rowdata['op']=LogisticRegression.calculate(model,a)
				rowdata['rows']=LogisticRegression.classify(model,a)
			elif model_type=='2':
				pack='data_mining.'+package
				import importlib
				bb=importlib.import_module(pack)
				ma=kNN.kNN()
				model=bb.model.knn(ma)
				model_data=self.get_argument('model', default='')
				a=[]
				a=(list(eval(model_data)))	
				rowdata={}
				rowdata['op']=kNN.calculate(model,a)
				rowdata['rows']=kNN.classify(model,a)			
			elif model_type=='3':
				pack='data_mining.'+package
				import importlib
				bb=importlib.import_module(pack)
				ma=NaiveBayes.NaiveBayes()
				model=bb.model.bayes(ma)
				model_data=self.get_argument('model', default='')
				a=[]
				a=(list(eval(model_data)))	
				rowdata={}
				rowdata['op']=NaiveBayes.calculate(model,a)
				rowdata['rows']=NaiveBayes.classify(model,a)				
		
			self.response(rowdata)
開發者ID:LiangHe266,項目名稱:Biotornadohl,代碼行數:70,代碼來源:list.py


注:本文中的Bio.LogisticRegression.classify方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。