Package: modelcreator
modelcreator - AutoML packageThis package contains aMachinewhich is meant to do thelearningfor you. It can automaticly create a fitting predictive model for given data.Sample outputTesting:  Gradient Boosting Classifier
[########################################] | 100% Completed |  3.9s
Score: 0.9667

Testing:  Ada Boost Classifier
[########################################] | 100% Completed |  1.3s
Score: 0.9600

Testing:  Random Forest Classifier
[########################################] | 100% Completed |  5.0s
Score: 0.9600

Testing:  Balanced Random Forest Classifier
[########################################] | 100% Completed |  3.5s
Score: 0.9600

Testing:  SVC
[########################################] | 100% Completed |  1.2s
Score: 0.9667

Chosen model:  Gradient Boosting Classifier 0.9667

Params:
        min_samples_split: 2
        n_estimators: 100

Results saved to  output.csvTable of ContentsInstallationUsageCSV inputPandas inputSaving modelParametersMachinelearnlearnFromDfpredictpredictFromDfsaveMachineDevelopmentInstallationTo use the package run:pipinstallmodelcreatorUsageThe input may be either a path to acsvfile or apandas DataFrameobject.CSV path inputThe library assumes that the last column of the training dataset contains the expected results. The dataset (both training and predictive) must be provided as acsvfile.If the results column contains text theMachinewill do its best to learn toclassifythe data correctly. In case of a number inside,regressionwill be performed.If the file contains headers you shall addheader_in_csv=Trueparameter to the method.Example 1IrisfrommodelcreatorimportMachine# Create automl machine instancemachine=Machine()# Train machine learning modelmachine.learn('example-data/iris.csv')# Predict the outcomesmachine.predict('example-data/iris-pred.csv','output.csv')This example is also available in theexample.pyfile. Consider trying it on your own.Pandas inputBut what to do if a result column is not the last in the given csv? It may be inconvenient to rewrite the whole csv just to swap the columns. Because of this problem Machine haslearnFromDfandpredictFromDfmethods. TheDfin method names stands forDataFramefrompandasmodule. This way you can handle reading the file by yourself.Example 2TitanicfrommodelcreatorimportMachineimportpandasaspd# Create DataFrame object from filetrain=pd.read_csv("train.csv")# Get features columns from DataFrameX_train=train.drop(['Survived'],axis=1)# And labels (results) columny_train=train["Survived"].astype(str)# Create the instance of Machinemachine=Machine()# Train machine learning modelmachine.learnFromDf(X_train,y_train,computation_level='advanced')# Show parameters of the modelmachine.showParams()# Load test set from fileX_test=pd.read_csv("test.csv")# Predict the labelsresults=machine.predictFromDf(X_test)# Save results to a new fileresults.to_csv("results.csv")Simple? That's right! Just note that we usedastype(str)in order to treat data asclasses, notnumbersbecause theTitanic datasetused in the example above has values0and1in"Survived"column to indicate whether a person made it through the disaster.Saving the modelIf you want your model to avoid re-learning on the whole dataset just to make a simple prediction you can save the state ofMachineto a file.# Save Machine with a trained model to "machine.pkl"machine.saveMachine('machine.pkl')# Create a new machine based on a schema filemachine2=Machine('machine.pkl')ParametersTheMachinecan be customized according to the use case. Check the parameters table:MachineParamTypeDefaultDescriptionschemaNoneorstrNoneA Machine may be created based on a saved, pre-trained machine instance. You may specify the path to the saved instance in this param to recreate it.learnParamTypeDefaultDescriptiondataset_filestrPath to a csv file which contains training dataset.header_in_csvboolFalseWhether the csv file containsheadersin the first row.metricsNone,strorCallable'accuracy'or'neg_root_mean_squared_error'Metrics used for scoring estimators. Many popular scoring functions (such asf1,roc_auc,neg_mean_gamma_deviance). Seeherehow to make custom scoring functions.verboseboolTrueWhether to print learning logs.cvint3a Number of cross-validation subsets. Higher values may increase computation time.computation_levelstr'medium'Can be either'basic','medium'or'advanced'. With higher computation level more models and parameters are being tested.learnFromDfParamTypeDefaultDescriptionXpandas.DataFrameDataFrame containing the feature columns.ypandas.SeriesLabel columns of the training data.metricsNone,strorCallable'accuracy'or'neg_root_mean_squared_error'Metrics used for scoring estimators. Many popular scoring functions (such asf1,roc_auc,neg_mean_gamma_deviance). Seeherehow to make custom scoring functions.verboseboolTrueWhether to print learning logs.cvint3A number of cross-validation subsets. Higher values may increase computation time.computation_levelstr'medium'Can be either'basic','medium'or'advanced'. With higher computation level more models and parameters are being tested.predictParamTypeDefaultDescriptionfeatures_filestrPath to the featurescsvof the data to generate predictions on.header_in_csvboolFalseWhether the csv file containsheadersin the first row.output_filestr'output.csv'Path to the outputcsvfile. In this file, the predictions will be saved.verbosestrTrueWhether to print logs.predictFromDfParamTypeDefaultDescriptionX_predictionspandas.DataFrameFeatures columns to generate predictions on.output_filestrNonePredict method returnspandas.Seriesof the results. Additionally, it can also save the results to acsvfile. It can be specified here. If the path is other thanNoneit will be interpreted as a path to the output file.verbosestrTrueWhether to print logs.saveMachineParamTypeDefaultDescriptionoutput_file_namestr'machine.pkl'Path to where shall the Machine instance be saved.DevelopmentHave a feature idea or just want to help? Take a look at theissues tab!