Package: ray-skorch
ray-skorchDistributed skorch on Ray Trainpip install ray-skorchskorch-based wrapper forRay Train. Experimental!:warning:RayTrainNeuralNetand the rest of this package are experimental and not production ready. In particular, validation and error handling may be spotty. If you encounter any problems or have any suggestions please open an issue on GitHub.We are looking for feedback! Please let us know about your experience using ray-skorch and about any suggestions and problems you may have by opening an issue. We are also interested in feedback on the concept of distributed training with scikit-learn(like) interfaces itself.DevelopmentRunpip install -e .to install necessary packagesUpon push, run./format.shto make sure lint changes are applied appropriately.The current working examples can be found inexamples.Known issues & missing featuresOnly numpy arrays, pandas dataframes and Ray Data Datasets are supported as inputs.Compatibility with scikit-learn hyperparameter tuners is not tested.Basic exampleThe only breaking API difference compared toskorchis the addition of a newnum_workersargument, contolling how many Ray workers to use for training. Please refer to docstrings for more information on other changes.With numpy/pandasimportnumpyasnpfromsklearn.datasetsimportmake_classificationfromtorchimportnnfromray_skorchimportRayTrainNeuralNetX,y=make_classification(1000,20,n_informative=10,random_state=0)X=X.astype(np.float32)y=y.astype(np.int64)classMyModule(nn.Module):def__init__(self,num_units=10,nonlin=nn.ReLU()):super(MyModule,self).__init__()self.dense0=nn.Linear(20,num_units)self.nonlin=nonlinself.dropout=nn.Dropout(0.5)self.dense1=nn.Linear(num_units,num_units)self.output=nn.Linear(num_units,2)defforward(self,X,**kwargs):X=self.nonlin(self.dense0(X))X=self.dropout(X)X=self.nonlin(self.dense1(X))X=self.output(X)returnXnet=RayTrainNeuralNet(MyModule,num_workers=2,# the only new mandatory argumentcriterion=nn.CrossEntropyLoss,max_epochs=10,lr=0.1,# required for classification loss funcsiterator_train__unsqueeze_label_tensor=False,iterator_valid__unsqueeze_label_tensor=False,)net.fit(X,y)# predict_proba returns a ray.data.Datasety_proba=net.predict_proba(X).to_pandas()print(y_proba)With Ray Dataimportnumpyasnpimportpandasaspdfromsklearn.datasetsimportmake_classificationfromtorchimportnnfromray.dataimportfrom_pandasfromray_skorchimportRayTrainNeuralNetX,y=make_classification(1000,20,n_informative=10,random_state=0)X=pd.DataFrame(X.astype(np.float32))y=pd.Series(y.astype(np.int64))X.columns=[str(colname)forcolnameinX.columns]X_pred=X.copy()X["target"]=yX=from_pandas(X)# ensure no target column is in data for predictionX_pred=from_pandas(X_pred)classMyModule(nn.Module):def__init__(self,num_units=10,nonlin=nn.ReLU()):super(MyModule,self).__init__()self.dense0=nn.Linear(20,num_units)self.nonlin=nonlinself.dropout=nn.Dropout(0.5)self.dense1=nn.Linear(num_units,num_units)self.output=nn.Linear(num_units,2)defforward(self,X,**kwargs):X=self.nonlin(self.dense0(X))X=self.dropout(X)X=self.nonlin(self.dense1(X))X=self.output(X)returnXnet=RayTrainNeuralNet(MyModule,num_workers=2,# the only new mandatory argumentcriterion=nn.CrossEntropyLoss,max_epochs=10,lr=0.1,# required for classification loss funcsiterator_train__unsqueeze_label_tensor=False,iterator_valid__unsqueeze_label_tensor=False,)net.fit(X,"target")# predict_proba returns a ray.data.Datasety_proba=net.predict_proba(X_pred).to_pandas()print(y_proba)