© All Rights Reserved

320 views

© All Rights Reserved

- Machine Learning Absolute Beginners Introduction 2nd
- Python Matplotlib Cheat Sheet
- Pandas Python for Data Science
- Python Seaborn Cheat Sheet
- Deep Learning Applications Using Python
- Data Analysis From Scratch With - Peters Morgan
- Numpy Cheat Sheet
- Python Data Analysis
- Python 3 Cheat Sheet
- Deep Learning With PyTorch (Packt)-2018 262p
- Pandas Cheat Sheet
- NumPy, SciPy, Pandas, Quandl Cheat Sheet
- Pandas Cookbook [eBook]
- Python 3.2 Reference Card
- Python Reference Card
- Matplotlib Cheat Sheet
- Real Python Part 1
- Python Cheat Sheet
- scipy_and_numpy.pdf
- Python 3 Cheat Sheet

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

- Machine Learning Absolute Beginners Introduction 2ndUploaded byud
- Python Matplotlib Cheat SheetUploaded bysreedhar
- Pandas Python for Data ScienceUploaded bychowdamhemalatha
- Python Seaborn Cheat SheetUploaded byFrâncio Rodrigues
- Deep Learning Applications Using PythonUploaded byBratva Ankit Mishra
- Data Analysis From Scratch With - Peters MorganUploaded byWallisson Carvalho
- Numpy Cheat SheetUploaded byIan Flores
- Python Data AnalysisUploaded byAmbalika Smiti
- Python 3 Cheat SheetUploaded byLaurent Pointal
- Deep Learning With PyTorch (Packt)-2018 262pUploaded byalex torres
- Pandas Cheat SheetUploaded byRoberto
- NumPy, SciPy, Pandas, Quandl Cheat SheetUploaded byseanrwcrawford
- Pandas Cookbook [eBook]Uploaded byMarcos Filipe Godoy
- Python 3.2 Reference CardUploaded byLaurent Pointal
- Python Reference CardUploaded bymarczucker
- Matplotlib Cheat SheetUploaded byTuan Ton
- Real Python Part 1Uploaded bystata
- Python Cheat SheetUploaded byebookkarthi
- scipy_and_numpy.pdfUploaded byAndrés Chavarría
- Python 3 Cheat SheetUploaded byFredrik Johansson
- Beginners Python Cheat Sheet Pcc AllUploaded byjohn smith
- Jupyter Notebook Cheat SheetUploaded byAnurag Agarwal
- Numpy_Python_Cheat_Sheet.pdfUploaded byAshish Sharma
- Python NotesUploaded byJosé Luis
- Python for Data ScienceUploaded bySujeet Omar
- python quick reference cardUploaded bySérgio Luiz Araújo Silva
- Statistics For Machine LearningUploaded byDiamond Ravi
- Python Machine LearningUploaded byArjun
- Git Cheat SheetUploaded bykzelda
- Natural Lanugage Processing with TensorFlow_ Teach language to machines using Python's deep learning library.pdfUploaded byLucas Alves

- Python_Bokeh_Cheat_Sheet.pdfUploaded byrakesharumalla
- Rl CheatsheetUploaded byrakesharumalla
- Apache HadoopUploaded byrakesharumalla
- UltimateGuidetoDataScienceInterviews-2Uploaded byAnonymous wt1Miztt3F
- NumPy, SciPy, Pandas, Quandl Cheat SheetUploaded byseanrwcrawford
- Cheatsheet for R programmingUploaded byAbhi Gupta
- 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

- ZAHARIA InTech-Sediment Transport and River Channel Dynamics in Romania Variability and Control FactorsUploaded byRe Manefiu
- Compressor wet gasUploaded byyogacruise
- Bickel and Levina 2004Uploaded bydfaini12
- Model Tuning RadioUploaded bysantanapas
- Time Series AnalysisUploaded byMiningBooks
- TMA 02 for ScribUploaded byAnonymous U5t9NYzhLW
- 2014-mpc-452.pdfUploaded byjunaid112
- Ch 3 AssignmentUploaded byArpit Patel
- Correlation in Resrarch..Uploaded byMohammad Jewel Rana
- Hamizah Bt JasmiUploaded byAzizah Ariffin
- Case Study ArkonUploaded byKother
- Performance Assessment of Topologically Diverse Power Systems Subjected to Hurricane EventUploaded byRenata Maldonado Gheno
- STATA Basics Regression and Panal DataUploaded byFarhad
- MFP of airUploaded byjameskay
- tmp46BCUploaded byFrontiers
- Step by Step Procedure to Do Shortcut Sizing for Air Cooled Heat Exchanger and Estimate Finned Area and Power RequiredUploaded bykarthick
- NucleationUploaded byRicha Tripathi
- Arch Experimental 4Uploaded byDanijela Roksandić
- EX10.pdfUploaded bySalman Farooq
- Thermodynamics_of_humid_air.pdfUploaded byĐoàn Trang
- Geographic Weighted Regression_WhitePaperUploaded byricontreMPH
- Dimension ReductionUploaded byMARCUS.VARANIS8748
- Impact of Drought on Crop YieldUploaded byAnonymous XSm48p
- Pert Master Weather ModelingUploaded byKhaled Abdelbaki
- RANDOM VIBRATION OF STRUCTURES_YANG scan by ghazali 89.pdfUploaded byMoj Jamaran
- l7_anova4Uploaded byPrasad Raikar
- Chapter 10-Data_Analysis_and_Probability.pdfUploaded byivcscribd
- Autocorrelation Time SeriesUploaded byL'enin Aleph
- FIGHTING FANTASY the Seven SerpentsUploaded byjasc0_hotmail_it
- d 2122 – 98 ;Rdixmjitotg_ - CopiaUploaded byHumberto Gutierrez

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.