首页 > 编程语言 > 详细

Logistic回归实现分析不同的因素对研究生录取的影响来预测一个人是否会被录取(Python实现)

时间:2020-09-27 17:04:40      阅读:134      评论:0      收藏:0      [点我收藏+]
 1 import pandas as pd
 2 from sklearn.model_selection import train_test_split
 3 from sklearn.linear_model import LogisticRegression 
 4 from sklearn.metrics import accuracy_score 
 5 df = pd.read_csv("./LogisticRegression.csv")
 6 df.head()
 7 df_x = df.iloc[:,1:]
 8 df_y = df.iloc[:,0]
 9 df_x_train,df_x_test,df_y_train,df_y_test = train_test_split(df_x,df_y,train_size = 0.8 ,random_state = 2)
10 logistic = LogisticRegression(max_iter = 1000,solver = "newton-cg" ).fit(df_x_train,df_y_train)
11 df_y_predict = logistic.predict(df_x_test)
12 accuracy_score(df_y_test,df_y_predict)

技术分享图片  
准确率为:0.7125  

 

Logistic回归实现分析不同的因素对研究生录取的影响来预测一个人是否会被录取(Python实现)

原文:https://www.cnblogs.com/jory-boke/p/13740278.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!