https://github.com/jihoonerd/restricted-discriminant-analysis
RDA implementation compatible with Scikit-learn API
https://github.com/jihoonerd/restricted-discriminant-analysis
discriminant-analysis rda scikit-learn
Last synced: about 2 months ago
JSON representation
RDA implementation compatible with Scikit-learn API
- Host: GitHub
- URL: https://github.com/jihoonerd/restricted-discriminant-analysis
- Owner: jihoonerd
- Created: 2021-10-28T01:31:18.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-04T00:53:14.000Z (over 4 years ago)
- Last Synced: 2025-03-05T05:43:49.877Z (over 1 year ago)
- Topics: discriminant-analysis, rda, scikit-learn
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# restricted-discriminant-analysis
RDA implementation compatible with Scikit-learn API
## How to use
Model class is inherited from `BaseEstimator` of `scikit-learn`, so you can use the `RDA` model just like the other `scikit-learn`'s esimators:
`RDA` uses macro-f1 score as a score function.
### Model Only
```python
rda_model = RDA()
rda_model.fit(X_train, y_train)
preds = rda_model.predict(X_test)
```
### With Pipeline
```python
# Gridsearch CV
parameters = {'rda__alpha': np.linspace(0, 1.0, 11), 'rda__beta':np.linspace(0, 1.0, 11), 'rda__variance': [0.1, 0.5, 1.0]}
pipeline = Pipeline(
steps = [('scaler', StandardScaler()), ('rda', RDA())]
)
skf = StratifiedKFold(n_splits=3, shuffle=True, random_state=1)
rda_g_search = GridSearchCV(pipeline, parameters, cv=skf, n_jobs=-1, verbose=1)
rda_g_search.fit(X.to_numpy(), y.to_numpy())
```