Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
101 views
Machine Learning Algorithms (Python & R) PDF
Uploaded by
John Faria
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Machine Learning Algorithms (Python & R).pdf For Later
Download
Save
Save Machine Learning Algorithms (Python & R).pdf For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
101 views
Machine Learning Algorithms (Python & R) PDF
Uploaded by
John Faria
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Machine Learning Algorithms (Python & R).pdf For Later
Carousel Previous
Carousel Next
Save
Save Machine Learning Algorithms (Python & R).pdf For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 11
Search
Fullscreen
CHEATSHEET Machine Learning @ Algorithms @ ( Python and R Codes) Types Supervised Learning Unsupervised Learning Reinforcement Learning -Decision Tree -Random Forest -Apriori algorithm - k-means Markov Decision Process ~KNN Logistic Regression - Hierarchical Clustering ~ Q LearningEle = 2 A ra ry ‘4 > Cy [4 Python Code taport Library taport other necessary Libraries Like pandas, run fron sklearn Inport Linear_nodel Load Train and Test datasets Tdentity feature and response variable(s) and values must be numeric and numpy arrays x traininput_variables_values training datasets y-train-target variables values training datasets x test=Lnput variables values test datasets create Linear regression object Linear = Linear_wodel. LinearRegression() Train the model using the training sets and check score Linear-Fit(x train, y_tratn) Linear-score(x_train, y_train) equation coefficient and Intercept print(*Coefficlent: \a", Linear.coef_) print(*Iatercept: \n', Linear. Intercept_) Predict output predicted= Linear.predict(x test) ‘load Train and Test datasets stdentify feature and response varlable(s) and values must be muvee and nunpy arrays a tealn <- input _vartables_values_training datasets yiteain < tanget_vartables_values_tratning datasets test c input variables values test datasets cbind(x_train,y. train) ‘train the model using the training sets and check score Linear <= Im(y_tratn ~ ., stumnary(Qinear) predict output pradicted= predict(inear,x test) data = 0)Python Code ‘iport Library ‘Assured you have, X (predictor) and ¥ (target) ‘for training data set and x test(orecietor) oF test_sotaset (4 rotel FLt(K, ) wotel.score(k, 9) ‘tention coetfictent ané Intercept print(*coctticiant: \n', model.coof_) print(Entercept: \n", nedel intercept) sPredict Output pradictede model.predict(x test) rr i= s cae ro 2 uy oy ‘rm sklearn.Linear_wodel inport Logistictegression © cbind(x trsin,y_train) ‘rain the model using the training sets and check logistic <- gln(y-train = ., data = x,fanily='binoniat) surmary (logistic) predictedn prodict( logistic x test)act} = = 2 ete Python Code ‘more Library import other necessary Libraries Like pandas, nunpy. from sklearn Snport tree ‘ssuned you have, X (predictor) and ¥ (tareet) for training data set and x test (predictor) of Acoeate tree object wodel = tree.Decistontresclassifter(criterione'gint') ‘fon clasesfication, here you can change the algorithm a5 gint or entropy (information gain) by ‘fault St 45 aint rodel = tree.Qectstontredhagrestor() for rain the model using the training Sets and check model. fitix, y) wodel.score(k, 1) predicted nodel.predict(x test) brary(rpart) X& ebind(x train, train) erow tree 41 & rpare(y_train ~ ., data = xnethode"class") summary Fit) trredict output redict( Fie x test)s 2 = 5 A = 5 EF s = 5 A Ey Ei 3B = EA Python Code ‘ingore Library from skleaen snport sym ‘Asse you have, X (predictor) and Y (target) for ‘training data set and x test(predictor) of test dataset screste Su classification object rogel ~ syn.sve() fthere are various options associates vith St, this 15 sinple for classification, ‘train the nodel using the training sets and check rodel.Fit(k ¥) rodel.score(s, ¥) Predict output predieted- nogel.onedict(x test) ‘apart Library Lbrary(e1971) x < cbind(x train,y train) ‘aitting model Fit cosum(y_train ~ ., data =x) suamary Fit) ‘Arecict Output predicteds predict(Fit,x testPETC ty Python Code sapere Library ‘nssunes you have, X (predictor) and ¥ (target) for ‘training data set and x test(predictor) of test dataset jn object node = Gaussiam() ‘here 45 otter distribution for multinomial classes Like Bernoulls Naive Bayes ‘ain the model using the training sets and check scoeate SiN classifi rodel f18(K, y) predictede nodel.predict(x test) ampore Library brary e1e71) x © cbind(x train,y train) srieting nose it Cnatvesayes(y train ~ ., data =x) summary (#42) sPredict Output predicted= pradict(fit,x test)Python Code fron slearn.neiehbors snport KtelghborsClassifier ibrary(knn) XG ehind(x_tratn,y tain) FE Chan(y train ~ ., date = sunnary( fit) weredice output predictede prediet(fit,x test) ‘issuned you have, X (predictor) and ¥ (target) For raining data set and x tost(predicto) of test_cataset ereate Kueighbors cassi¢ier object model el groorsCiassifier(anedghtarse6) roael F880, 9) ‘sPredict tut predicted nadel.pradict(x test) A 3 k= c= 3 2 4 5 Fy Fs = 7 2 =Python Code suport Laseary ‘rom sklearncluster taport means assumed you have, X (attributes) for training cata ‘and x test(attriutes) of test_cataset create meigneors classifler object node eons = means(n_cius ‘Train te model using the training sets and check score ode £20(0) predictede noel. greater x test) nbrary(cluster) Fat < bneans(t, 3)EUs Python Code tngart Lieacy kssuned you have, X (predictor) and ¥ (target) for ‘trsining data set and x test (predictor) of test nodel= Randotorestclassifier() ‘rein the node using the tring sets and check score motel #5806, 9) recictede model. predict (x test) typort Uibeary Library (randonForest) x <= ebind(x train,y_tratn) Fitting model #18 < randonForest(spectes ~ ., xpntree=50) sunmary #20) eredict ovtput predietede predict (#it,x test)2 Es i 2 = Python Code Create PCA object peox deconpositionPCAa component) defoutt value of K =aln(n sarge, m Fetures) for Factor analysis foe decopasition Factenaaiysis() ‘Reduced the osnension of training dataset using PCL ‘train seduced = pea Fit_transforn(train) est_reduced » pea.transfor(test) sport brary brary(stats) pee & princonp(train, cor = TRUE) train reduced < predict(pca, train) test reduced < predict(pca,test)EI ks 2 Py r s Fy Ee Python Code taport Library ‘ron sklear.ensenble Snport GradientoostingClassifier ftssuned you have, X (predictor) and ¥ (target) for training data set ard x test(predictor) of test_dataset create Gradient Boosting Classifier object GradientBoostingClassifier(n_estinators-100, \ Learning ratert.0, max depthea, random stat train the noel using the training sets and check score mocel #100, 9) roredict Ovtout ede -precice(x test) amport Library brary caret) 2 cbind(x troinyy_train) sriccing model ixcontrol © tratnControl( wethed = “repeatedcv", + nunber = 4, repeats = 4) #5 tratngy = 5 date predietede predict(Fit,x_test, type pause) prob") L,2]
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6135)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (628)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brené Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (935)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8215)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2923)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4973)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Tóibín
3.5/5 (2061)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1988)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2641)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1994)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2544)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
Capítulo 26: Scanned by Camscanner
PDF
No ratings yet
Capítulo 26: Scanned by Camscanner
9 pages
Capítulo 23: Scanned by Camscanner
PDF
No ratings yet
Capítulo 23: Scanned by Camscanner
6 pages
Capítulo 24: Scanned by Camscanner
PDF
No ratings yet
Capítulo 24: Scanned by Camscanner
5 pages
Capítulo 28: Scanned by Camscanner
PDF
No ratings yet
Capítulo 28: Scanned by Camscanner
2 pages
Capítulo 22: Scanned by Camscanner
PDF
No ratings yet
Capítulo 22: Scanned by Camscanner
3 pages
Capítulo 29: Scanned by Camscanner
PDF
No ratings yet
Capítulo 29: Scanned by Camscanner
1 page
Capítulo 21: Scanned by Camscanner
PDF
No ratings yet
Capítulo 21: Scanned by Camscanner
5 pages
Novo Documento 2019-06-17 16.54.40
PDF
No ratings yet
Novo Documento 2019-06-17 16.54.40
5 pages
Novo Documento 2018-03-07 - 1
PDF
No ratings yet
Novo Documento 2018-03-07 - 1
1 page
Novo Documento 2019-06-17 16.54.40 - 1
PDF
No ratings yet
Novo Documento 2019-06-17 16.54.40 - 1
1 page
Orders Order - Items Products Users
PDF
No ratings yet
Orders Order - Items Products Users
2 pages
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carre
3.5/5 (109)