Discover coursera machine learning python, include the articles, news, trends, analysis and practical advice about coursera machine learning python on alibabacloud.com
System: OS X 10.11.6
The MAC system has its own Python2.7, using the Easy_install command with its own system to install the modules online. If you need to use the PYTHON3 environment, python3.5 is invoked at the terminal input Python3 after installing the Python3.5.1, view Python version
Python
2, install NumPyNumPy is a Python package. It represents "Numer
): # Extend the Input feature vector as a feature matrix linenum = featurematrix.shape[0] featurematrixin = Np.tile ( Featurevectorin, (linenum,1)) # Calculate the Euclidean distance between the matrix Diffmatrix = featurematrixin -Featurematrix Sqdiffmatrix = Diffmatrix * * 2 Distancevaluearray = Sqdiffmatrix.sum (Axis=1) Distancevaluearray = Distancevaluearray * * 0.5 return DistancevaluearrayUsed in the numpy of the more distinctive things. The practice is to first
classes in the data. - -Many, many more ... the the a total of 150 data samples the evenly distributed over 3 subspecies the 4 petals per sample, calyx shape Description - " " the the " " the 2 dividing the training set and the test set94 " " theX_train, X_test, y_train, y_test =train_test_split (Iris.data, the Iris.target, thetest_size=0.25,98Random_state=33) About - " "101 3 K Nearest Neighbor Classifier learning model and prediction102 " "10
understand computer knowledge, psychology and philosophy. Artificial intelligence consists of a very wide range of sciences, consisting of a variety of fields, such as machine learning, computer vision, and so on, in general, one of the main goals of AI research is to make machines capable of doing complex work that normally requires human intelligence. But different times, different people's understanding
(Ss_y.inverse_transform (y_test), Ss_y.inverse_transform (lr_y_predict)) $ Print("the mean square error of the linear is:", Lr_mse) -Lr_mae =Mean_absolute_error (Ss_y.inverse_transform (y_test), Ss_y.inverse_transform (lr_y_predict)) - Print("the average absolute error of the linear is:", Lr_mae) - A #evaluation of the SGD model +Sgdr_score =Sgdr.score (x_test, y_test) the Print("the default evaluation value for SGD is:", Sgdr_score) -sgdr_r_squared =R2_score (y_test, sgdr_y_predict) $ Print("
regression tree is:", Dtr.score (X_test, y_test)) - Print("the r_squared values for the flat regression tree are:", R2_score (Y_test, dtr_y_predict)) - Print("the mean square error of the regression tree is:", Mean_squared_error (Ss_y.inverse_transform (y_test), - Ss_y.inverse_transform (dtr_y_predict))) A Print("the average absolute error of the regression tree is:", Mean_absolute_error (Ss_y.inverse_transform (y_test), + Ss_y.inverse_transform (dtr_y_predict))) the - " " $ the default evalua
.score (X_train_poly2, Y_train))#0.9816421639597427Two-time linear regression model fitted curves:The fitting degree is better than 1 linear fitting.The following 4 linear regression models are performed:1 #four-time linear regression model fitting2Poly4 = Polynomialfeatures (degree=4)#4-time polynomial feature generator3X_train_poly4 =poly4.fit_transform (X_train)4 #Building Model Predictions5Regressor_poly4 =linearregression ()6 Regressor_poly4.fit (X_train_poly4, Y_train)7 #draw a graph of 2
-za-z]"," ", Sent.lower (). Strip ()). Split () in sentences.append (temp) - to returnsentences + - #The sentences in the long news are stripped out for training . thesentences = [] * forIinchx: $Sentence_list =news_to_sentences (i)Panax NotoginsengSentences + =sentence_list - the + #Configure the dimension of the word vector ANum_features = 300 the #the frequency of the words that are to be considered +Min_word_count = 20 - #number of CPU cores used in parallel computing $Num_workers =
#岭回归主要是弥补在数据中出现异常值时, improve the stability of linear model, that is, robustness robustImport Pandas as PDImport NumPy as NPImport Matplotlib.pyplot as PltFrom Sklearn import Linear_modelImport Sklearn.metrics as SM#直接拿最小二乘法数据Ridgerg=linear_model. Ridge (alpha=0.5,fit_intercept=true,max_iter=10000) #alpha nearer to 0, the more the ridge regression approached the linear regression.Ridgerg.fit (X_train,y_train) #训练模型Y_train_pred=ridgerg.predict (X_train) #模型y值Y_test_pred=ridgerg.predict (x_test) #模
Python Kmeans clustering is relatively simple, first requires the import NumPy, from the Sklearn.cluster import Kmeans module:Import NumPy as NP from Import KmeansThen read the TXT file, get the corresponding data and convert it to numpy array:X == open ('rktj4.txt') for in f: = Re.compile ('\s+') x.append ([Float (Regex.Split (v) [3]), float ( Regex.Split (v) [6= Np.array (X)Set the number of classes and cluster:N_clusters = 5= Kmeans (n_clust
Maximumlikelihood (p=w): H,t=defineparam () f1=factorial (h+t)/(factorial (H) *factorial (T)) f2= (p**h) * ((1.0-p) **t) return F1*F2 def factorial (x): return reduce (lambda x,y:x*y,range (1,x+1)) achieve the effect, corresponding to the above example, when h=49,t=31, is the probability of P=2/3 probabilitiesCode Address: Please click on my/********************************* This article from the blog "Bo Li Garvin"* Reprint Please indicate the sourc
It is mentioned in this series that using Python to start machine learning (3: Data fitting and generalized linear regression) mentions the regression algorithm for numerical prediction. The logical regression algorithm is essentially regression, but it introduces a logical function to help classify it. The practice found that the logical regression in the field
learning in Hadoop that you can learn by yourself. If you are a novice in machine learning and big data learning, stick to learning Weka and learn a library wholeheartedly.
Scikit Learn: This is a machine
Preface: "The foundation determines the height, not the height of the foundation!" The book mainly from the coding program, data structure, mathematical theory, data processing and visualization of several aspects of the theory of machine learning, and then extended to the probability theory, numerical analysis, matrix analysis and other knowledge to guide us into the world of
and the contrast divergence algorithm, and is also an active catalyst for deep learning. There are videos and materials .L Oxford Deep LearningNando de Freitas has a full set of videos in the deep learning course offered in Oxford.L Wulide, Professor, Fudan University. Youku Video: "Deep learning course", speaking of a very master style.
Other reference
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.