In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to understand and master Python logical regression". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to understand and master Python logical regression".
Def sigmoid (x): define the sigmoid function
Return 1 / (1+np.exp (- x))
Parameter setting and iteration for logical regression
Def weights: # initialization parameter mline n = x_train.shapetheta = np.random.rand (n) # Parameter cnt = "iterations max_iter = 5000" start iteration while cnt < max_iter:cnt + = 1diff = np.full (nMagol 0) for i in range (m): diff = (y [I]-sigmoid (theta.T @ x [I]) * x [I] theta = theta + alpha * diffif (abs (diff) 0.5:return 1else:return 0)
Call function
X_train = np.array ([1Power2.697 minus 6.254], [1mine1.872 pr 2.014], [1je 2.312 pr 0.812], [lde 1.932 pr 3.920], [1Me 1.321 mei 5.583], [1 mei 2.215 mei 1.560], [1mel 1.659pr 2.932], [1mel 0.85 pr 7.362], [1mel 1.685pr 4.763], [1mel 1.786je 2.523]) y_train = np.array ([1remiere 1.685 meme 4.763]) y_train = np.array 1]) alpha = 0.001 # Learning rate thershold = 0.01# specify a threshold Used to check twice error print (weights) thank you for reading, above is the content of "how to understand and master Python logical regression". After the study of this article, I believe you have a deeper understanding of how to understand and master Python logical regression, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.