I am trying to subclass from sklearn.svm.LinearSVC
and noticed the *
argument in the signature. I'm not sure if this *
refers to **kwargs or *args or something else. I am trying subclass the init function as follows. In this scenario I'm have added a single additional argument new_string_in_subclass
the init function.
from sklearn.svm import LinearSVC
class LinearSVCSub(LinearSVC):
def __init__(self, penalty='l2', loss='squared_hinge', *, dual=True, tol=0.0001, C=1.0, multi_class='ovr',
fit_intercept=True, intercept_scaling=1, class_weight=None, verbose=0, random_state=None,
max_iter=1000, sampler: new_string_in_subclass=None):
super(LinearSVCSub, self).__init__(penalty=penalty, loss=loss, *, dual=dual, tol=tol,
C=C, multi_class=multi_class, fit_intercept=fit_intercept,
intercept_scaling=intercept_scaling, class_weight=class_weight,
verbose=verbose, random_state=random_state, max_iter=max_iter)
self.new_string_in_subclass = new_string_in_subclass
If I want to maintain the functionality of the LinearSVC
class's other methods, do I need to pass the * argument to the super class's __init__
function? If so how do I do this? Right now I get a SyntaxError
as below:
super(LinearSVCSub, self).init(penalty=penalty, loss=loss, *, dual=dual, tol=tol, ^ SyntaxError: invalid syntax