Package: blitzml
Automate machine learning pipelines rapidlyInstall BlitzMLClassificationRegressionTime-SeriesClusteringInstall BlitzMLpipinstallblitzmlClassificationfromblitzml.tabularimportClassificationimportpandasaspd# prepare your dataframestrain_df=pd.read_csv("auxiliary/datasets/banknote/train.csv")test_df=pd.read_csv("auxiliary/datasets/banknote/test.csv")# create the pipelineauto=Classification(train_df,test_df,algorithm='RF',n_estimators=50)# perform the entire processauto.run()# We can get their values using:pred_df=auto.pred_dfmetrics_dict=auto.metrics_dictprint(pred_df.head())print(metrics_dict)Available ClassifiersRandom Forest 'RF'LinearDiscriminantAnalysis 'LDA'Support Vector Classifier 'SVC'KNeighborsClassifier 'KNN'GaussianNB 'GNB'LogisticRegression 'LR'AdaBoostClassifier 'AB'GradientBoostingClassifier 'GB'DecisionTreeClassifier 'DT'MLPClassifier 'MLP'Parametersclassifieroptions: {'RF','LDA','SVC','KNN','GNB','LR','AB','GB','DT','MLP', 'auto', 'custom'}, default = 'RF'auto: selects the best scoring classifier based on f1-scorecustom: enables providing a custom classifier through *file_path* and *class_name* parametersfile_pathwhen using 'custom' classifier, pass the path of the file containing the custom class, default = 'none'class_namewhen using 'custom' classifier, pass the class name through this parameter, default = 'none'feature_selectionoptions: {'correlation', 'importance', 'none'}, default = 'none'correlation: use feature columns with the highest correlation with the targetimportance: use feature columns that are important for the model to predict the targetnone: use all feature columnsvalidation_percentagevalue determining the validation split percentage (value from 0 to 1), default = 0.1average_typewhen performing multiclass classification, provide the average type for the resulting metrics, default = 'macro'cross_validation_k_foldsnumber of k-folds for cross validation, if 1 then no cv will be performed, default = 1**kwargsoptional parameters for the chosen classifier. you can find available parameters in thesklearn docsAttributestrain_dfthe preprocessed train dataset (after runningClassification.preprocess())test_dfthe preprocessed test dataset (after runningClassification.preprocess())modelthe trained model (after runningClassification.train_the_model())pred_dfthe prediction dataframe (test_df + predicted target) (after runningClassification.gen_pred_df(Classification.test_df))metrics_dictthe validation metrics (after runningClassification.gen_metrics_dict()){"accuracy": acc,"f1": f1,"precision": pre,"recall": recall,"hamming_loss": h_loss,"cross_validation_score":cv_score,returns None if cross_validation_k_folds==1}Methodsrun()a shortcut that runs the entire process:preprocessingmodel trainingpredictionmodel evaluationaccuracy_history()accuracy scores when varying the sampling size of the train_df (after runningClassification.train_the_model()).returns:{'x':train_df_sample_sizes,'y1':train_scores_mean,'y2':test_scores_mean,'title':title}plot()plotting line chart visualizes accuracy historyRegressionfromblitzml.tabularimportRegressionimportpandasaspd# prepare your dataframestrain_df=pd.read_csv("auxiliary/datasets/house prices/train.csv")test_df=pd.read_csv("auxiliary/datasets/house prices/test.csv")# create the pipelineauto=Regression(train_df,test_df,algorithm='RF')# perform the entire processauto.run()# We can get their values using:pred_df=auto.pred_dfmetrics_dict=auto.metrics_dictprint(pred_df.head())print(metrics_dict)Available RegressorsRandom Forest 'RF'Support Vector Regressor 'SVR'KNeighborsRegressor 'KNN'Lasso Regressor 'LSS'LinearRegression 'LR'Ridge Regressor 'RDG'GaussianProcessRegressor 'GPR'GradientBoostingRegressor 'GB'DecisionTreeRegressor 'DT'MLPRegressor 'MLP'Parametersregressoroptions: {'RF','SVR','KNN','LSS','LR','RDG','GPR','GB','DT','MLP', 'auto', 'custom'}, default = 'RF'auto: selects the best scoring regressor based on r2 scorecustom: enables providing a custom regressor through *file_path* and *class_name* parametersfile_pathwhen using 'custom' regressor, pass the path of the file containing the custom class, default = 'none'class_namewhen using 'custom' regressor, pass the class name through this parameter, default = 'none'feature_selectionoptions: {'correlation', 'importance', 'none'}, default = 'none'correlation: use feature columns with the highest correlation with the targetimportance: use feature columns that are important for the model to predict the targetnone: use all feature columnsvalidation_percentagevalue determining the validation split percentage (value from 0 to 1), default = 0.1cross_validation_k_foldsnumber of k-folds for cross validation, if 1 then no cv will be performed, default = 1**kwargsoptional parameters for the chosen regressor. you can find available parameters in thesklearn docsAttributestrain_dfthe preprocessed train dataset (after runningRegression.preprocess())test_dfthe preprocessed test dataset (after runningRegression.preprocess())modelthe trained model (after runningRegression.train_the_model())pred_dfthe prediction dataframe (test_df + predicted target) (after runningRegression.gen_pred_df(Regression.test_df))metrics_dictthe validation metrics (after runningRegression.gen_metrics_dict()){"r2_score": r2,"mean_squared_error": mse,"root_mean_squared_error": rmse,"mean_absolute_error" : mae,"cross_validation_score":cv_score,returns None if cross_validation_k_folds==1}Methodsrun()a shortcut that runs the entire process:preprocessingmodel trainingpredictionmodel evaluationplot()plotting line chart visualizes RMSE historyRMSE_history()RMSE scores when varying the sampling size of the train_df (after runningRegression.train_the_model()).returns:{'x':train_df_sample_sizes,'y1':train_scores_mean,'y2':test_scores_mean,'title':title}Time-seriestime series is a particular problem of Regression, but time series have some additional functions:stationary test (IsStationary()).convert to stationary.reverse predicted.and the dataset must have a DateTime column, even if the DataType of this column is Object.fromblitzml.tabularimportTimeSeriesimportpandasaspd# prepare your dataframestrain_df=pd.read_csv("train_dataset.csv")test_df=pd.read_csv("test_dataset.csv")# create the pipelineauto=TimeSeries(train_df,test_df,algorithm='RF')# Perform the entire process:auto.run()# We can get their values using:pred_df=auto.pred_dfmetrics_dict=auto.metrics_dictprint(pred_df.head())print(metrics_dict)Clusteringfromblitzml.unsupervisedimportClusteringimportpandasaspd# prepare your dataframetrain_df=pd.read_csv("auxiliary/datasets/customer personality/train.csv")# create the pipelineauto=Clustering(train_df,clustering_algorithm='KM')# first perform data preprocessingauto.preprocess()# second train the modelauto.train_the_model()# After training the model we can generate:auto.gen_pred_df()auto.gen_metrics_dict()# We can get their values using:print(auto.pred_df.head())print(auto.metrics_dict)Available Clustering AlgorithmsK-Means 'KM'Affinity Propagation 'AP'Agglomerative Clustering 'AC'Mean Shift 'MS'Spectral Clustering 'SC'Birch 'Birch'Bisecting K-Means 'BKM'OPTICS 'OPTICS'DBSCAN 'DBSCAN'Parametersclustering_algorithmoptions: {"KM", "AP", "AC", "MS", "SC", "Birch", "BKM", "OPTICS", "DBSCAN", 'auto', 'custom'}, default = 'KM'auto: selects the best scoring clustering algorithm based on silhouette scorecustom: enables providing a custom clustering algorithm through *file_path* and *class_name* parametersfile_pathwhen using 'custom' clustering_algorithm, pass the path of the file containing the custom class, default = 'none'class_namewhen using 'custom' clustering_algorithm, pass the class name through this parameter, default = 'none'feature_selectionoptions: {'importance', 'none'}, default = 'none'importance: use feature columns that are important for the model to predict the targetnone: use all feature columns**kwargsoptional parameters for the chosen clustering_algorithm. you can find available parameters in thesklearn docsAttributestrain_dfthe preprocessed train dataset (after runningClustering.preprocess())modelthe trained model (after runningClustering.train_the_model())pred_dfthe prediction dataframe (test_df + predicted target) (after runningClustering.gen_pred_df())metrics_dictthe validation metrics (after runningClustering.gen_metrics_dict())
{
    "silhouette_score": sil_score,
    "calinski_harabasz_score": cal_har_score,
    "davies_bouldin_score": dav_boul_score,
    "n_clusters" : n
}Methodspreprocess()perform preprocessing on train_dftrain_the_model()train the chosen clustering algorithm on the train_dfclustering_visualization()2-d visualization of the data points with its corresponding labels  (after doing dimensionality reduction using Principal Componenet Analysis).returns:{
    'principal_component_1':pc1,
    'principal_component_2':pc2,
    'cluster_labels':labels,
    'title':title
}gen_pred_df()generates the prediction dataframe and assigns it to thepred_dfattributegen_metrics_dict()generates the clustering metrics and assigns it to themetrics_dictrun()a shortcut that runs the following methods:
preprocess()
train_the_model()
gen_pred_df()
gen_metrics_dict()DevelopmentClone the reporunpip install virtualenvrunpython -m virtualenv venvrun. ./venv/bin/activateon UNIX based systems or. ./venv/Scripts/activate.ps1if on windowsrunpip install -r requirements.txtrunpre-commit install