Logo
Pattern

Discover published sets by community

Explore tens of thousands of sets crafted by our community.

Machine Learning Algorithms in Python

28

Flashcards

0/28

Still learning
StarStarStarStar

Linear Regression

StarStarStarStar

A method to predict dependent variable (Y) based on the values of independent variables (X). It assumes a linear relationship between X and Y. ```python from sklearn.linear_model import LinearRegression model = LinearRegression() model.fit(X_train, y_train) ```

StarStarStarStar

Logistic Regression

StarStarStarStar

A predictive analysis algorithm used for binary classification problems. It models the probability that an instance belongs to a particular class. ```python from sklearn.linear_model import LogisticRegression model = LogisticRegression() model.fit(X_train, y_train) ```

StarStarStarStar

Elastic Net

StarStarStarStar

A regularized regression method that linearly combines the L1 and L2 penalties of the lasso and ridge methods. ```python from sklearn.linear_model import ElasticNet model = ElasticNet(alpha=1.0, l1_ratio=0.5) model.fit(X_train, y_train) ```

StarStarStarStar

Hierarchical Clustering

StarStarStarStar

A method of cluster analysis which seeks to build a hierarchy of clusters. The two main types of hierarchical clustering are Agglomerative and Divisive. ```python from sklearn.cluster import AgglomerativeClustering model = AgglomerativeClustering() model.fit(X_train) ```

StarStarStarStar

t-Distributed Stochastic Neighbor Embedding (t-SNE)

StarStarStarStar

A non-linear dimensionality reduction technique suitable for embedding high-dimensional data for visualization in a low-dimensional space of two or three dimensions. ```python from sklearn.manifold import TSNE X_embedded = TSNE(n_components=2).fit_transform(X_train) ```

StarStarStarStar

Isolation Forest

StarStarStarStar

An algorithm for anomaly detection that works on the principle of isolating anomalies, as opposed to normal points, by randomly selecting a feature and then randomly selecting a split value between the maximum and minimum values of the selected feature. ```python from sklearn.ensemble import IsolationForest model = IsolationForest() model.fit(X_train) ```

StarStarStarStar

Gradient Boosting Machines (GBM)

StarStarStarStar

A machine learning technique for regression and classification that builds predictive models from an ensemble of weak prediction models, typically decision trees. ```python from sklearn.ensemble import GradientBoostingClassifier model = GradientBoostingClassifier() model.fit(X_train, y_train) ```

StarStarStarStar

Recurrent Neural Networks (RNN)

StarStarStarStar

A class of artificial neural networks where connections between nodes form a directed graph along a temporal sequence. This allows it to exhibit temporal dynamic behavior for a time sequence. ```python from keras.models import Sequential from keras.layers import SimpleRNN, Dense model = Sequential([ SimpleRNN(50, activation='relu', input_shape=(sequence_length, features)), Dense(1) ]) model.compile(optimizer='adam', loss='mean_squared_error') model.fit(X_train, y_train, epochs=5) ```

StarStarStarStar

Long Short-Term Memory Networks (LSTM)

StarStarStarStar

An advanced RNN architecture that can learn long-term dependencies. They are particularly useful for classifying, processing and making predictions based on time series data. ```python from keras.models import Sequential from keras.layers import LSTM, Dense model = Sequential([ LSTM(50, activation='relu', input_shape=(sequence_length, features)), Dense(1) ]) model.compile(optimizer='adam', loss='mean_squared_error') model.fit(X_train, y_train, epochs=5) ```

StarStarStarStar

Principal Component Analysis (PCA)

StarStarStarStar

A statistical procedure that uses orthogonal transformation to convert a set of observations of possibly correlated variables into a set of values of linearly uncorrelated variables called principal components. ```python from sklearn.decomposition import PCA model = PCA(n_components=2) model.fit(X_train) ```

StarStarStarStar

Association Rule Learning: Apriori

StarStarStarStar

A popular algorithm for mining frequent itemsets and relevant association rules. Often used in market basket analysis, it works by identifying the frequent individual items in the database and extending them to larger item sets as long as those item sets appear sufficiently often in the database. ```python from mlxtend.frequent_patterns import apriori frequent_itemsets = apriori(df, min_support=0.07, use_colnames=True) ```

StarStarStarStar

CatBoost

StarStarStarStar

An algorithm that uses gradient boosting on decision trees. It is designed to work with categorical features and supports numerical features as well for regression, classification, and other ML tasks. ```python from catboost import CatBoostClassifier model = CatBoostClassifier() model.fit(X_train, y_train) ```

StarStarStarStar

k-Means Clustering

StarStarStarStar

A popular unsupervised learning algorithm for cluster analysis in data mining. k-Means clustering aims to partition n observations into k clusters in which each observation belongs to the cluster with the nearest mean. ```python from sklearn.cluster import KMeans model = KMeans(n_clusters=3) model.fit(X_train) ```

StarStarStarStar

DBSCAN Clustering

StarStarStarStar

Density-Based Spatial Clustering of Applications with Noise is a data clustering algorithm that finds cores of high density and expands clusters from them, good for data with clusters of similar density. ```python from sklearn.cluster import DBSCAN model = DBSCAN(eps=0.5, min_samples=5) model.fit(X_train) ```

StarStarStarStar

Random Forest

StarStarStarStar

An ensemble learning method that operates by constructing a multitude of decision trees during training time and outputting the class that is the mode of the classes (classification) or average prediction (regression). ```python from sklearn.ensemble import RandomForestClassifier model = RandomForestClassifier() model.fit(X_train, y_train) ```

StarStarStarStar

Decision Trees

StarStarStarStar

A non-parametric supervised learning method for classification and regression tasks. They model decisions and their possible consequences as a tree-like structure. ```python from sklearn.tree import DecisionTreeClassifier model = DecisionTreeClassifier() model.fit(X_train, y_train) ```

StarStarStarStar

K-Nearest Neighbors (KNN)

StarStarStarStar

A non-parametric method used for classification and regression. A query instance is assigned the data class which has the most representatives within the nearest neighbors of the instance. ```python from sklearn.neighbors import KNeighborsClassifier model = KNeighborsClassifier(n_neighbors=5) model.fit(X_train, y_train) ```

StarStarStarStar

Neural Networks

StarStarStarStar

Computational models inspired by the human brain that are capable of learning a variety of complex patterns and tasks. They consist of interconnected groups of nodes, akin to vast networks of neurons in the brain. ```python from sklearn.neural_network import MLPClassifier model = MLPClassifier() model.fit(X_train, y_train) ```

StarStarStarStar

Extreme Gradient Boosting (XGBoost)

StarStarStarStar

An implementation of gradient boosted decision trees designed for speed and performance that is dominant competitive machine learning. ```python from xgboost import XGBClassifier model = XGBClassifier() model.fit(X_train, y_train) ```

StarStarStarStar

Support Vector Machines (SVM)

StarStarStarStar

Supervised learning models used for classification and regression analysis. They find the hyperplane that best separates the classes of data. ```python from sklearn.svm import SVC model = SVC() model.fit(X_train, y_train) ```

StarStarStarStar

Ridge Regression

StarStarStarStar

A technique for analyzing multiple regression data that suffer from multicollinearity. By adding a degree of bias to the regression estimates, ridge regression reduces the standard errors. ```python from sklearn.linear_model import Ridge model = Ridge(alpha=1.0) model.fit(X_train, y_train) ```

StarStarStarStar

Time Series Forecasting: ARIMA

StarStarStarStar

ARIMA stands for Auto-Regressive Integrated Moving Average. It is a class of models that explains a given time series based on its own past values, i.e., its own lags and the lagged forecast errors. ```python import statsmodels.api as sm model = sm.tsa.arima.ARIMA(endog=y_train, order=(1,1,1)) model_fit = model.fit() ```

StarStarStarStar

Convolutional Neural Networks (CNN)

StarStarStarStar

A class of deep neural networks, commonly applied to analyzing visual imagery. They take advantage of the hierarchical pattern in data and assemble more complex patterns using smaller and simpler patterns. ```python from keras.models import Sequential from keras.layers import Dense, Conv2D, Flatten model = Sequential([ Conv2D(filters=64, kernel_size=3, activation='relu', input_shape=(28,28,1)), Flatten(), Dense(10, activation='softmax') ]) model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy']) model.fit(X_train, y_train, epochs=5) ```

StarStarStarStar

LightGBM

StarStarStarStar

A gradient boosting framework that uses tree-based learning algorithms and is designed for distributed and efficient training, particularly on large datasets. ```python from lightgbm import LGBMClassifier model = LGBMClassifier() model.fit(X_train, y_train) ```

StarStarStarStar

Autoencoders

StarStarStarStar

An unsupervised neural network model that is trained to attempt to copy its input to its output. It has an internal hidden layer that describes a code used to represent the input. It's commonly used for dimensionality reduction. ```python from keras.layers import Input, Dense from keras.models import Model input_img = Input(shape=(input_size,)) encoded = Dense(encoding_dim, activation='relu')(input_img) decoded = Dense(input_size, activation='sigmoid')(encoded) autoencoder = Model(input_img, decoded) ```

StarStarStarStar

Naive Bayes Classifiers

StarStarStarStar

A family of simple probabilistic classifiers based on applying Bayes' theorem with strong independence assumptions between the features. ```python from sklearn.naive_bayes import GaussianNB model = GaussianNB() model.fit(X_train, y_train) ```

StarStarStarStar

AdaBoost

StarStarStarStar

A boosting algorithm that can be used in conjunction with many other types of learning algorithms to improve performance. The output of the other learning algorithms is combined into a weighted sum that represents the final output of the boosted classifier. ```python from sklearn.ensemble import AdaBoostClassifier model = AdaBoostClassifier() model.fit(X_train, y_train) ```

StarStarStarStar

Lasso Regression

StarStarStarStar

A regression analysis method that performs both variable selection and regularization to enhance the prediction accuracy and interpretability of the statistical model it produces. ```python from sklearn.linear_model import Lasso model = Lasso(alpha=0.1) model.fit(X_train, y_train) ```

Know
0
Still learning
Click to flip
Know
0
Logo

© Hypatia.Tech. 2024 All rights reserved.