Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coefficient attribute not found on TimeSeriesSVC object after fitting. #447

Open
delacylab opened this issue Apr 10, 2023 · 0 comments
Open
Labels

Comments

@delacylab
Copy link

delacylab commented Apr 10, 2023

Describe the bug
coef_ attribute not found when using tslearn.svm.TimeSeriesSVC. I am guessing this qualifies as a bug instead of a feature request since the documentation says this should be available when using a linear kernel.

To Reproduce
clf = tslearn.svm.TimeSeriesSVC(C=1.0, kernel="linear")
clf.fit(X,y)
clf.coef_

AttributeError: 'TimeSeriesSVC' object has no attribute 'coef_'

Expected behavior
An array of coefficients.

Environment (please complete the following information):

  • OS: Ubuntu 20.04
  • tslearn version 0.5.3.2 installed from conda

Additional context
I added the following lines to the tslearn source code svm.py at line 261 and got what I think are expected results (an array of numClasses * sz * d). I had one class. This is the shape I would expect for a coef listing for time series 3D arrays since I will have a feature coefficient for each feature/time period. The below code also throws the appropriate error if a non-linear kernel is used. Can you confirm that if I have e.g. 3 time periods and 50 dimensions, that the resulting length 150 array would be represented as: 0-49 features in time period 1, 50-99 features in time period 2, 100-149 features in time period 3. I want to be sure that I am interpreting the results correctly and that the data isn't arranged in some different way.

@Property
def coef_(self):
check_is_fitted(self, 'X_fit')
return self.svm_estimator
.coef_

@delacylab delacylab added the bug label Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant