Comments (8)
I was able to get the OneVsRestClassifier
working with the following (not terribly elegant) patching:
from fastFM import als
class FMClassifier(als.FMClassification):
def fit(self, X, y, *args):
y = y.copy()
y[y == 0] = -1
return super(FMClassifier, self).fit(X, y, *args)
def predict_proba(self, X):
probs = super(FMClassifier, self).predict_proba(X)
return np.tile(probs, 2).reshape(2, probs.shape[0]).T
from sklearn.multiclass import OneVsRestClassifier
clf = OneVsRestClassifier(FMClassifier(n_iter=500, random_state=42), n_jobs=-1)
Basically, scikit produces [0, 1] labels which must be converted to [-1, 1] labels. Then it extracts the probabilities from what it assumes is a (n_instances, 2) array. Broadcasting the values would be better than my tiling solution, but I didn't know the syntax off the top of my head. There may be other changes needed to make the API fully compatible; I haven't tested this with a pipeline.
from fastfm.
I want to use fm to solve a multi-class classification problem too,Can you give some advise? @farimahfanaei @ibayer @macks22
from fastfm.
Actually there is a predict_proba
function for the als and sdg solver but it's not showing up in the docs (there is an open issue now). In general, I would recommend to use the mcmc
solver with the fit_predict_proba
function.
from fastfm.
thank you so much,I was thinking to try implementing a customized predic_proba
and 'fit' functions for sgd which can solve the problem but you said that there is an issue!
Although I preferred to use sgd method but I also tried it withmcmc
solver as following:
y_proba =OneVsRestClassifier(fm).fit_predict_proba(X_train, y_train, X_test)
but I face the following error:
AttributeError: 'OneVsRestClassifier' object has no attribute 'fit_predict_proba'
from fastfm.
You are talking about the OneVsRestClassifierI
class from sklearn? I thought you want to implement it yourself. Please provide a Short, Self Contained, Correct Example to help us understand the issue.
from fastfm.
yes, I am facing a multi-class classification problem and I was thinking to use OneVsRestClassifier
from sklearn for tuning sgd-FMclassification to solve my multi-class classification problem using FastFM method .
fm = sgd.FMClassification(n_iter=1000, init_stdev=0.1, rank=2, random_state=123,l2_reg_w=0, l2_reg_V=0, l2_reg=0, step_size=0.1)
OneVsRestClassifier(fm).fit(X_train,y_train)
with the above code I face the following error related to sklearn.base
:
RuntimeError: Cannot clone object FMClassification(init_stdev=0.1, l2_reg=None, l2_reg_V=0, l2_reg_w=0,
n_iter=1000, random_state=123, rank=2, step_size=0.1), as the constructor does not seem to set parameter l2_reg_V
I thought maybe it is because of the fact that sgd (or als) solver has not a proper decision_function for OneVsRestClassifier
!?
That's why I asked this question and I was wondering if implementing customized **fit _and _predict_proba by myself can be a plausible solution for this problem?
from fastfm.
The Cannot clone object FMClassification error has been reported before #44 .
That's why I asked this question and I was wondering if implementing customized fit *and *predict_proba > by myself can be a plausible solution for this problem?
I think it's better to fix this clone issue first, maybe that fixes your problem too. I'll look into it but it might take a while. Your example doesn't run. You could just adapt the code from http://scikit-learn.org/stable/auto_examples/plot_multilabel.html to create a self contained example.
from fastfm.
@ibayer I tried to solve that clone problem we faced and the problem was in __init__()
function in sgd.py , I just try to feed the parameter values manually I am afraid if it is a efficient way to do so !
But my question is still if FMClassifier is able to solve a problem with huge number of classes like 1000-100000 classes using OneVsRestClassifier
? because I still have the following error:
sklearn.utils.validation.NotFittedError: This OneVsRestClassifier instance is not fitted yet. Call 'fit' with appropriate arguments before using this method.
I had make a change in _validate_class_labels(y)
in base.py file and I set the assert len(set(y))
equal to my maximum number of classes! so I was afraid if this method can really work with multi-class classification using OneVsRestClassifier
?
from fastfm.
Related Issues (20)
- pip install . is not working on Winodws HOT 1
- Illegal instruction (core dumped) in ALS HOT 5
- Can fastfm use mini batch? HOT 1
- Check pairs range failed when fitting BPR
- OverflowError: n_iter too high in bpr.FMRecommender HOT 1
- Need partial_fit HOT 1
- Can fastfm use multicore to speed up training? HOT 1
- Fit complaining about both dense/sparse HOT 2
- Recompile for python 3.7 HOT 7
- Input of fit() and return value of predict_proba() method
- Failure to install on Python3.8 HOT 8
- Fix simple typo: reommend -> recommend
- Import Error
- Compiling using OpenBLAS from anaconda
- Source file type in PyPi
- No coordinate descent solver available HOT 1
- Compilation error on macOS 11.2 ARM HOT 3
- Any plan to support py3.7+? HOT 1
- will it work for third order categorical features interaction ?
- will it work on windows OS?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastfm.