from sklearn base import baseestimatortransformermixin class mytransformer(baseestimatortransformermixin)def __init__(selffirst_parameter= second_parameter= )all parameters must be specified in the __init__ function self first_parameter self second_parameter def fit(selfxy=none)fit should only take and as parameters even if your model is unsupervisedyou need to accept argumentmodel fitting code goes here print("fitting the model right here"fit returns self return self def transform(selfx)transform takes as parameter only apply some transformation to x_transformed return x_transformed implementing classifier or regressor works similarlyonly instead of transformer mixin you need to inherit from classifiermixin or regressormixin alsoinstead of implementing transformyou would implement predict as you can see from the example given hereimplementing your own estimator requires very little codeand most scikit-learn users build up collection of custom models over time where to go from here this book provides an introduction to machine learning and will make you an effective practitioner howeverif you want to further your machine learning skillshere are some suggestions of books and more specialized resources to investigate to dive deeper theory in this bookwe tried to provide an intuition of how the most common machine learning algorithms workwithout requiring strong foundation in mathematics or computer science howevermany of the models we discussed use principles from probability theorylinear algebraand optimization while it is not necessary to understand all the details of how these algorithms are implementedwe think that where to go from here