© All Rights Reserved

320 views

© All Rights Reserved

- Deep Learning Applications Using Python
- Python Matplotlib Cheat Sheet
- Pandas Python for Data Science
- Python Seaborn Cheat Sheet
- Applied Deep Learning.pdf
- Machine Learning Algorithms Applications
- Python Data Analysis
- Pandas Cheat Sheet
- Data Analysis From Scratch With - Peters Morgan
- Python 3 Cheat Sheet
- NumPy, SciPy, Pandas, Quandl Cheat Sheet
- Matplotlib Cheat Sheet
- Pandas Cookbook [eBook]
- Python Reference Card
- Numpy Cheat Sheet
- scipy_and_numpy.pdf
- Real Python Part 1
- Python Cheat Sheet
- Python 3 Cheat Sheet
- Beginners Python Cheat Sheet Pcc All

You are on page 1of 1

Scikit-Learn

Learn Python for data science Interactively at www.DataCamp.com Linear Regression Accuracy Score

>>> from sklearn.linear_model import LinearRegression >>> knn.score(X_test, y_test) Estimator score method

>>> lr = LinearRegression(normalize=True) >>> from sklearn.metrics import accuracy_score Metric scoring functions

>>> accuracy_score(y_test, y_pred)

Support Vector Machines (SVM)

Scikit-learn >>> from sklearn.svm import SVC Classification Report

>>> svc = SVC(kernel='linear') >>> from sklearn.metrics import classification_report Precision, recall, f1-score

Scikit-learn is an open source Python library that Naive Bayes >>> print(classification_report(y_test, y_pred)) and support

implements a range of machine learning, >>> from sklearn.naive_bayes import GaussianNB Confusion Matrix

>>> gnb = GaussianNB() >>> from sklearn.metrics import confusion_matrix

preprocessing, cross-validation and visualization >>> print(confusion_matrix(y_test, y_pred))

algorithms using a unified interface. KNN

>>> from sklearn import neighbors Regression Metrics

A Basic Example >>> knn = neighbors.KNeighborsClassifier(n_neighbors=5)

>>> from sklearn import neighbors, datasets, preprocessing

Mean Absolute Error

>>> from sklearn.cross_validation import train_test_split Unsupervised Learning Estimators >>> from sklearn.metrics import mean_absolute_error

>>> from sklearn.metrics import accuracy_score >>> y_true = [3, -0.5, 2]

>>> iris = datasets.load_iris() Principal Component Analysis (PCA) >>> mean_absolute_error(y_true, y_pred)

>>> X, y = iris.data[:, :2], iris.target >>> from sklearn.decomposition import PCA Mean Squared Error

>>> X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=33) >>> pca = PCA(n_components=0.95) >>> from sklearn.metrics import mean_squared_error

>>> scaler = preprocessing.StandardScaler().fit(X_train) >>> mean_squared_error(y_test, y_pred)

>>> X_train = scaler.transform(X_train)

K Means

>>> X_test = scaler.transform(X_test) >>> from sklearn.cluster import KMeans R Score

>>> knn = neighbors.KNeighborsClassifier(n_neighbors=5) >>> k_means = KMeans(n_clusters=3, random_state=0) >>> from sklearn.metrics import r2_score

>>> r2_score(y_true, y_pred)

>>> knn.fit(X_train, y_train)

>>> y_pred = knn.predict(X_test)

>>> accuracy_score(y_test, y_pred) Model Fitting Clustering Metrics

Adjusted Rand Index

Supervised learning >>> from sklearn.metrics import adjusted_rand_score

Loading The Data Also see NumPy & Pandas >>> lr.fit(X, y) Fit the model to the data

>>> adjusted_rand_score(y_true, y_pred)

>>> knn.fit(X_train, y_train)

Your data needs to be numeric and stored as NumPy arrays or SciPy sparse >>> svc.fit(X_train, y_train) Homogeneity

>>> from sklearn.metrics import homogeneity_score

matrices. Other types that are convertible to numeric arrays, such as Pandas Unsupervised Learning >>> homogeneity_score(y_true, y_pred)

DataFrame, are also acceptable. >>> k_means.fit(X_train) Fit the model to the data

>>> pca_model = pca.fit_transform(X_train) Fit to data, then transform it V-measure

>>> import numpy as np >>> from sklearn.metrics import v_measure_score

>>> X = np.random.random((10,5)) >>> metrics.v_measure_score(y_true, y_pred)

>>> y = np.array(['M','M','F','F','M','F','M','M','F','F','F'])

>>> X[X < 0.7] = 0 Prediction Cross-Validation

>>> from sklearn.cross_validation import cross_val_score

Supervised Estimators >>> print(cross_val_score(knn, X_train, y_train, cv=4))

Training And Test Data >>> y_pred = svc.predict(np.random.random((2,5))) Predict labels

>>> y_pred = lr.predict(X_test)

>>> print(cross_val_score(lr, X, y, cv=2))

Predict labels

>>> from sklearn.cross_validation import train_test_split >>> y_pred = knn.predict_proba(X_test) Estimate probability of a label

>>> X_train, X_test, y_train, y_test = train_test_split(X,

y, Unsupervised Estimators Tune Your Model

random_state=0) >>> y_pred = k_means.predict(X_test) Predict labels in clustering algos Grid Search

>>> from sklearn.grid_search import GridSearchCV

>>> params = {"n_neighbors": np.arange(1,3),

Preprocessing The Data "metric": ["euclidean", "cityblock"]}

>>> grid = GridSearchCV(estimator=knn,

Standardization Encoding Categorical Features param_grid=params)

>>> grid.fit(X_train, y_train)

>>> from sklearn.preprocessing import StandardScaler >>> from sklearn.preprocessing import LabelEncoder >>> print(grid.best_score_)

>>> scaler = StandardScaler().fit(X_train) >>> print(grid.best_estimator_.n_neighbors)

>>> enc = LabelEncoder()

>>> standardized_X = scaler.transform(X_train) >>> y = enc.fit_transform(y)

>>> standardized_X_test = scaler.transform(X_test) Randomized Parameter Optimization

Normalization Imputing Missing Values >>> from sklearn.grid_search import RandomizedSearchCV

>>> params = {"n_neighbors": range(1,5),

>>> from sklearn.preprocessing import Normalizer "weights": ["uniform", "distance"]}

>>> from sklearn.preprocessing import Imputer >>> rsearch = RandomizedSearchCV(estimator=knn,

>>> scaler = Normalizer().fit(X_train) >>> imp = Imputer(missing_values=0, strategy='mean', axis=0) param_distributions=params,

>>> normalized_X = scaler.transform(X_train) >>> imp.fit_transform(X_train) cv=4,

>>> normalized_X_test = scaler.transform(X_test) n_iter=8,

random_state=5)

Binarization Generating Polynomial Features >>> rsearch.fit(X_train, y_train)

>>> print(rsearch.best_score_)

>>> from sklearn.preprocessing import Binarizer >>> from sklearn.preprocessing import PolynomialFeatures

>>> binarizer = Binarizer(threshold=0.0).fit(X) >>> poly = PolynomialFeatures(5)

>>> binary_X = binarizer.transform(X) >>> poly.fit_transform(X) DataCamp

Learn Python for Data Science Interactively

- Deep Learning Applications Using PythonUploaded byBratva Ankit Mishra
- Python Matplotlib Cheat SheetUploaded bysreedhar
- Pandas Python for Data ScienceUploaded bychowdamhemalatha
- Python Seaborn Cheat SheetUploaded byFrâncio Rodrigues
- Applied Deep Learning.pdfUploaded byAmbrose Onueseke
- Machine Learning Algorithms ApplicationsUploaded byasadfx
- Python Data AnalysisUploaded byAmbalika Smiti
- Pandas Cheat SheetUploaded byRoberto
- Data Analysis From Scratch With - Peters MorganUploaded byWallisson Carvalho
- Python 3 Cheat SheetUploaded byLaurent Pointal
- NumPy, SciPy, Pandas, Quandl Cheat SheetUploaded byseanrwcrawford
- Matplotlib Cheat SheetUploaded byTuan Ton
- Pandas Cookbook [eBook]Uploaded byMarcos Filipe Godoy
- Python Reference CardUploaded bymarczucker
- Numpy Cheat SheetUploaded byIan Flores
- scipy_and_numpy.pdfUploaded byAndrés Chavarría
- Real Python Part 1Uploaded bystata
- Python Cheat SheetUploaded byebookkarthi
- Python 3 Cheat SheetUploaded byFredrik Johansson
- Beginners Python Cheat Sheet Pcc AllUploaded byjohn smith
- Python 3.2 Reference CardUploaded byLaurent Pointal
- Git Cheat SheetUploaded bykzelda
- Numpy_Python_Cheat_Sheet.pdfUploaded byAshish Sharma
- Statistics For Machine LearningUploaded byDiamond Ravi
- Python for Data ScienceUploaded bySujeet Omar
- Jupyter Notebook Cheat SheetUploaded byAnurag Agarwal
- Machine Learning AlgorithmsUploaded byAditya Aggarwal
- Natural Lanugage Processing with TensorFlow_ Teach language to machines using Python's deep learning library.pdfUploaded byLucas Alves
- Python Machine LearningUploaded byArjun
- Machine Learning Projects PythonUploaded byVesnog

- Python_Bokeh_Cheat_Sheet.pdfUploaded byrakesharumalla
- Rl CheatsheetUploaded byrakesharumalla
- Apache HadoopUploaded byrakesharumalla
- UltimateGuidetoDataScienceInterviews-2Uploaded byAnonymous wt1Miztt3F
- Cheatsheet for R programmingUploaded byAbhi Gupta
- NumPy, SciPy, Pandas, Quandl Cheat SheetUploaded byseanrwcrawford
- Data Science Careers Guide Springboard FinalUploaded byarun.sambargi6220
- 90221_80827v00_machine_learning_section4_ebook_v03.pdfUploaded byviejopiscolero
- R cheatsheet Data WranglingUploaded byarekbee
- Streaming AnalyticsUploaded byrakesharumalla
- Machine Learning Section3 eBook v05Uploaded byhuze_nedian
- dvwkbm_lab2_cli1Uploaded byrakesharumalla
- IotUploaded byrakesharumalla
- Introduction to Cloud Infrastructure TechnologiesUploaded byendermuabdib
- R-Cheat SheetUploaded byPrasad Marathe
- Matlab Cheat SheetUploaded bylpauling
- mementopython3-english.pdfUploaded byraj06740
- Data Table Cheat SheetUploaded byAnthony Lee Zhang
- AV Big Data Engineers PathUploaded byrakesharumalla
- vishnustotramUploaded bytmadduluri
- Scikit_Learn_Cheat_Sheet_Python.pdfUploaded byrakesharumalla

- Information Requirement AnalysisUploaded by5lady
- The Chinese Li and the Japanese Rei Concepts-Thanking RitualsUploaded bypostig
- 9c0f989ef1479eeafcda6fca01ad3821c9c8Uploaded byGom-o Eugenio Jr
- Grammar and Clc Keeping It in ContextUploaded byhigginscribd
- Psychiatric NursingUploaded byFreeNursingNotes
- 6 Decision Support System & ConceptsUploaded byHamza Masood
- ed 243 lesson 2 my monster mama loves me soUploaded byapi-245588668
- (Bloomsbury Companions) Violeta Sotirova (ed.) - The Bloomsbury Companion to Stylistics-Bloomsbury Academic (2015).pdfUploaded byMaiminh Le
- perceptions and relationships in picking cottonUploaded byapi-315820518
- The Essence of ShrmUploaded bypapripetals07
- 424 491 Unit 2 Ads Text.docxUploaded byMeow Memyself
- Ticket 3Uploaded byOULGOUT Abdelouahed
- The Dyslexic Reader 2001 Issue 23Uploaded byDavis Dyslexia Association International
- Organisational Savvy Multi Rater Assessment - Confidential Feedback ReportUploaded bychien
- Active LearningUploaded bySanti Delova
- QUALITATIVE RESEARCH.docxUploaded byshrygpta
- schools as textUploaded byapi-310182910
- PID ControllerUploaded byabdussamih
- Paper 1Uploaded byRohit Sahu
- Investigate the VerbsUploaded byNathaliaSantillandelRosillo
- naeema jin 201620Uploaded byapi-346126154
- Paul Virilio: The effect of speed on communications and the architectures of controlUploaded byAnthony J Askew
- Teacher Personality Test ReportUploaded byDerek Banas
- Annual Plan de 2do Grado PaolaUploaded byClavijo Cinthya
- Multigenre ResearchUploaded byTerrierTr
- CE 440 - M. BUDHUUploaded byIndra Priadi
- Jenson Shoes- Jane KravitzUploaded byBrian Kennedy
- presentacinpastsimple-110331122216-phpapp01.pdfUploaded byNataly Macas
- Manuscript Evaluation FormUploaded byjembrongfunky
- Grammar ExercisesUploaded byJoseph Kennedy