Package: autopredict
autopredictAutopredict is a simple yet powerful library which can be used by Data Scientists to create multiple prediction (regression,classification) data models.Pass in the data to autopredict and sit back as it does all the work for you. It is very powerfull in creating intial baseline models and also has ready made tweaked parameters for multiple models to generate highly accurate predictions.Automate Model SelectionHyperparameter tuningFeature selection/rankingFeature CompressionStacked Ensemble ModelsThis software has been designed with much Joy,
by Sanchit Latawa & is protected by The Apache Licensev2.0.New Features!Added new classification ModelsAllow grid tuning parameters to be passed in as argumentTechSample Usage>>fromautopredict.classificationimportautoClassify
>>model=autoClassify(encoder='label',scaler='minmax',useGridtuning=False)>>model.train(X,y)>>print(model.getModelScores())OutputmodelNamescoreroc_auc_scoref1_score
LogisticRegression0.9274640.6395700.000000
DecisionTreeClassifier0.9374220.7889670.285612
GaussianNB0.9353520.7606700.203207
RandomForestClassifier0.9372970.7915520.248444
GradientBoostingClassifier0.9374720.7924350.257557Sample Run for Iris DatasetBelow shows sample code flow for using autopredict , you can get this sample file
from -> */autopredict/tests/sample_iris_classification.py# Loading Librariesimportpandasaspd
fromautopredict.classificationimportautoClassify
fromautopredict.featuresimportrankFeatures,reduce_memory# Setting display optionspd.set_option('display.max_columns',50000)pd.set_option('display.width',500000)# Load the data into a dataframedf=pd.read_csv('./tests/iris.csv')# St target and feature valuesX=df.drop('Species',axis=1)y=df['Species']# step 1  Feature Importance/Evaluation# rankFeatures is a function in autopredict which you can# use for feature evaluation it will give you the ranking of your features# based on importance , with the most important feature starting from 1print(rankFeatures(X,y))## Sample Output - showing features along with their realtive rank  #########     Column-name  Importance-Rank# 0   Petal.Width              1.0# 1  Petal.Length              1.5# 2  Sepal.Length              3.0# 3   Sepal.Width              3.0## Once you have the list of importance of the features## you can either drop or add some new features which## would be used in the prediction modeling## step 2 Train the model/evaluate################ sample usage 2.1 ######################### the below fit statement trains the modelmodel=autoClassify(scaler='standard',useGridtuning=False,gridDict=None).fit(X,y)## get model scoresprint(model.getModelScores())################ sample usage 2.2 ########################## the below fit statement would ask autopredict to perform## hyper parameter tuning using Gridsearchmodel=autoClassify(scaler='standard',useGridtuning=True,gridDict=None).fit(X,y)####### sample useage 2.3 ####################### the below fit uses grid tuning to fit models but over-rides### auto-predict's base grid search parameters and models# Define the grid that you want to rungrid={'LogisticRegression':{'penalty':['l2'],'C':[0.001,0.1,1,10]},'DecisionTreeClassifier':{'max_depth':[4,5,6,7,8,9,10]},'RandomForestClassifier':{'n_estimators':[100,500,1000],'max_depth':[4,5]},'GradientBoostingClassifier':{'learning_rate':[0.01,0.1,0.2,0.3],'n_estimaors':[1000]}}# train the model , passing useGridtuning as True which tells# the function to use Grid Tuning and pass the grid to be used# in case you pass gridDict as NUll default options set in autopredict# would be usedmodel=autoClassify(scaler='standard',useGridtuning=True,gridDict=grid).fit(X,y)# Step 3 get the score boardprint(model.getModelScores())print(model._predict_df)# step 4 if you want to get a model object back to predict ouput# below gets the best model object based onb accuracy score# you can over-ride the default scoring mechanism by using# score paramter in the the getBestModel Functionmodel_obj=model.getBestModel()# Step 4.1 In case you want to select any other model# the model Name is derived from the output# you get when you print print(model.getModelScores())model_obj=model.getModelObject('DecisionTreeClassifier')# Step 5 To predict using the model object use the below statementy_predict=model_obj.predict(validTestData)# Other Misc features# 1 If you want to compress memory usage of your datframe use the# reduce_memory utilty this will compress your feature set and display# the compress percentagedf=reduce_memory(df)# 2 Using stacked Ensemble models is only supported for# binary classification for now below is sample usage# where lgb and catboost are being used as base models# and then the output is consume by LR model to give final ouputfromlightgbmimportLGBMClassifier
fromsklearn.linear_modelimportLogisticRegression
fromsklearn.model_selectionimportStratifiedKFold
fromsklearn.model_selectionimportcross_val_score
fromautopredict.stackingimportstackClassify
fromcatboostimportCatBoostClassifier# LightGBM paramslgb_params={}lgb_params['learning_rate']=0.02
lgb_params['n_estimators']=650lgb_params['max_bin']=10lgb_params['subsample']=0.8
lgb_params['subsample_freq']=10lgb_params['colsample_bytree']=0.8
lgb_params['min_child_samples']=500lgb_params['seed']=99lgmodel=LGBMClassifier(**lgb_params)cat_params={}cat_params['iterations']=900cat_params['depth']=8cat_params['rsm']=0.95
cat_params['learning_rate']=0.03
cat_params['l2_leaf_reg']=3.5
cat_params['border_count']=8catmodel=CatBoostClassifier(**cat_params)logmodel=LogisticRegression()tmp=stackClassify(splits=2,stackerModel=logmodel,models=[lgmodel,catmodel],score='roc_auc',seed=100)y_pred_prob=tmp.fit_predict(X=train,y=target_train,test=test)# y_pred_prob has the predict probability for True classDevelopmentWant to contribute?
Please reach out to me atslatawa@yahoo.inand we can go over the Queue items planned for
the next releaseTodosWrite MORE TestsBuild catboost,LGB,XGB as a seperate featureLicenseApache v2.0Free Software, Hell Yeah!