逻辑回归基础知识可参考:http://blog.csdn.net/fjssharpsword/article/details/54580552
python内部算法已经实现了,最重要是理解y=f(x)的最小化损失函数并通过梯度下降法求解参数。
这里通过Python机器学习库scikit-learn实现,代码如下:
# -*- coding: utf-8 -*-
import numpy as np
import urllib
from sklearn import preprocessing
from sklearn.feature_selection import RFE
from sklearn.linear_model import LogisticRegression
from sklearn import metrics
from sklearn.ensemble import ExtraTreesClassifier
import time
def main():
#数据加载
# load the CSV file as a numpy matrix
dataset = np.loadtxt('D:\sample.csv', delimiter=",")
# separate the data from the target attributes
X = dataset[:,0:4]
y = dataset[:,4]
#数据标准化
# normalize the data attributes
normalized_X = preprocessing.normalize(X)
# standardize the data attributes
standardized_X = preprocessing.scale(X)
#特征选取
#model = Logi