René's URL Explorer Experiment


Title: Proof of concept for allowing non-sklearn estimators by adelevie · Pull Request #160 · modAL-python/modAL · GitHub

Open Graph Title: Proof of concept for allowing non-sklearn estimators by adelevie · Pull Request #160 · modAL-python/modAL

X Title: Proof of concept for allowing non-sklearn estimators by adelevie · Pull Request #160 · modAL-python/modAL

Description: Not sure if there is any desire for this feature, but in this PR I have sketched out a way to use virtually any estimator type with the ActiveLearner and BayesianOptimizer classes. Motivation Allow us to use other training and inference facilities, such as HuggingFace models that are trained using the Trainer class, use AWS SageMaker Estimators, etc. With this added flexibility, the training and inference does not need to even run on the same hardware as the modAL code. This brings the suite of sampling methods here to many new applications, particularly resource-intensive deep learning models that typically don't fit that great under the sklearn interface. Implementation Rather than call the classic sklearn estimator functions such as fit, predict, predict_proba, and score, this PR adds a layer of callables that can be overridden: fit_func, predict_func, predict_proba_func, and score_func. def __init__(self, estimator: BaseEstimator, query_strategy: Callable = uncertainty_sampling, X_training: Optional[modALinput] = None, y_training: Optional[modALinput] = None, bootstrap_init: bool = False, on_transformed: bool = False, force_all_finite: bool = True, fit_func: FitFunction = SKLearnFitFunction(), predict_func: PredictFunction = SKLearnPredictFunction(), predict_proba_func: PredictProbaFunction = SKLearnPredictProbaFunction(), score_func: ScoreFunction = SKLearnScoreFunction(), **fit_kwargs ) -> None: I added SKLearn implementations of each by default (included their corresponding Protocol classes as well). Here's how fit works: class FitFunction(Protocol): def __call__(self, estimator: GenericEstimator, X, y, **kwargs) -> GenericEstimator: raise NotImplementedError # ... class SKLearnFitFunction(FitFunction): def __call__(self, estimator: BaseEstimator, X, y, **kwargs) -> BaseEstimator: return estimator.fit(X=X, y=y, **kwargs) I'll also note that the changes in this PR don't break any of the existing tests. Usage When using SageMaker, we might implement fit and predict_proba in this manner: class CustomEstimator: hf_predictor: Union[HuggingFacePredictor, Predictor] hf_estimator: HuggingFace def __init__(self, hf_predictor: HuggingFacePredictor, hf_estimator: HuggingFace): self.hf_predictor = hf_predictor self.hf_estimator = hf_estimator class CustomFitFunction(FitFunction): def __call__(self, estimator: CustomEstimator, X, y, **kwargs) -> CustomEstimator: # notice we don't use `y` -- the label is baked into the HuggingFace Dataset return estimator.hf_estimator.fit(X=X, **kwargs) class CustomPredictProbaFunction(PredictProbaFunction): @staticmethod def hf_prediction_to_proba(predictions: Union[List[Dict], object], positive_class_label: str = 'LABEL_1', negative_class_label: str = 'LABEL_0') -> np.array: label_key: str = 'label' score_key: str = 'score' p = [] for prediction in predictions: if positive_class_label == prediction[label_key]: score = prediction[score_key] p.append([score, 1.0 - score]) if negative_class_label == prediction[label_key]: score = prediction[score_key] p.append([1.0 - score, score]) return np.array(p) def __call__(self, estimator: CustomEstimator, X, **kwargs) -> np.array: return self.hf_prediction_to_proba( predictions=estimator.hf_predictor.predict(dict(inputs=X)) ) estimator = CustomEstimator(hf_predictor=hf_predictor, hf_estimator=hf_estimator) learner = ActiveLearner( estimator=estimator, fit_func=CustomFitFunction(), predict_proba_func=CustomPredictProbaFunction(), X_training=train_dataset # standard HuggingFace Dataset instead of your typical types for `X` in `sklearn` ) If you've made it this far, I'd ask that you forgive the clunkiness. This was a rough sketch of an idea I wanted to get written down before I forgot it. Anyways, would love some feedback, and if you think this PR is worth finishing, let me know. I can say for me, this would unlock a lot of really useful applications.

Open Graph Description: Not sure if there is any desire for this feature, but in this PR I have sketched out a way to use virtually any estimator type with the ActiveLearner and BayesianOptimizer classes. Motivation Allow...

X Description: Not sure if there is any desire for this feature, but in this PR I have sketched out a way to use virtually any estimator type with the ActiveLearner and BayesianOptimizer classes. Motivation Allow...

Opengraph URL: https://github.com/modAL-python/modAL/pull/160

X: @github

direct link

Domain: patch-diff.githubusercontent.com

route-pattern/:user_id/:repository/pull/:id/checks(.:format)
route-controllerpull_requests
route-actionchecks
fetch-noncev2:6063accd-5c1c-d2af-75de-f25f997db08c
current-catalog-service-hash87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a
request-idC4BA:3DB526:9B7765:D0C101:698F819F
html-safe-nonceac11e59454a7bae9031699aad60c18e278004ef1d4e17a62e3eaceaca08f1756
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNEJBOjNEQjUyNjo5Qjc3NjU6RDBDMTAxOjY5OEY4MTlGIiwidmlzaXRvcl9pZCI6IjIwMjA5ODE5NzIyNTIxOTcyNzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac13aba782b41178f8cca67a395e6f6eb49aae427f363452d539269d76570714ad
hovercard-subject-tagpull_request:1023298701
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/checks
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/modAL-python/modAL/pull/160/checks
twitter:imagehttps://avatars.githubusercontent.com/u/86790?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/86790?s=400&v=4
og:image:altNot sure if there is any desire for this feature, but in this PR I have sketched out a way to use virtually any estimator type with the ActiveLearner and BayesianOptimizer classes. Motivation Allow...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4763146d672e989a41c6c0bd715790c0c59341d9f855508c8a3196e1e480b8f7
turbo-cache-controlno-preview
go-importgithub.com/modAL-python/modAL git https://github.com/modAL-python/modAL.git
octolytics-dimension-user_id42179679
octolytics-dimension-user_loginmodAL-python
octolytics-dimension-repository_id110697473
octolytics-dimension-repository_nwomodAL-python/modAL
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id110697473
octolytics-dimension-repository_network_root_nwomodAL-python/modAL
turbo-body-classeslogged-out env-production page-responsive full-width full-width-p-0
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8b442a4e0d8e68ffb351da689499018fde153e49
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/modAL-python/modAL/pull/160/checks#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FmodAL-python%2FmodAL%2Fpull%2F160%2Fchecks
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FmodAL-python%2FmodAL%2Fpull%2F160%2Fchecks
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fchecks&source=header-repo&source_repo=modAL-python%2FmodAL
Reloadhttps://patch-diff.githubusercontent.com/modAL-python/modAL/pull/160/checks
Reloadhttps://patch-diff.githubusercontent.com/modAL-python/modAL/pull/160/checks
Reloadhttps://patch-diff.githubusercontent.com/modAL-python/modAL/pull/160/checks
modAL-python https://patch-diff.githubusercontent.com/modAL-python
modALhttps://patch-diff.githubusercontent.com/modAL-python/modAL
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2FmodAL-python%2FmodAL
Fork 327 https://patch-diff.githubusercontent.com/login?return_to=%2FmodAL-python%2FmodAL
Star 2.3k https://patch-diff.githubusercontent.com/login?return_to=%2FmodAL-python%2FmodAL
Code https://patch-diff.githubusercontent.com/modAL-python/modAL
Issues 93 https://patch-diff.githubusercontent.com/modAL-python/modAL/issues
Pull requests 12 https://patch-diff.githubusercontent.com/modAL-python/modAL/pulls
Actions https://patch-diff.githubusercontent.com/modAL-python/modAL/actions
Projects 0 https://patch-diff.githubusercontent.com/modAL-python/modAL/projects
Wiki https://patch-diff.githubusercontent.com/modAL-python/modAL/wiki
Security 0 https://patch-diff.githubusercontent.com/modAL-python/modAL/security
Insights https://patch-diff.githubusercontent.com/modAL-python/modAL/pulse
Code https://patch-diff.githubusercontent.com/modAL-python/modAL
Issues https://patch-diff.githubusercontent.com/modAL-python/modAL/issues
Pull requests https://patch-diff.githubusercontent.com/modAL-python/modAL/pulls
Actions https://patch-diff.githubusercontent.com/modAL-python/modAL/actions
Projects https://patch-diff.githubusercontent.com/modAL-python/modAL/projects
Wiki https://patch-diff.githubusercontent.com/modAL-python/modAL/wiki
Security https://patch-diff.githubusercontent.com/modAL-python/modAL/security
Insights https://patch-diff.githubusercontent.com/modAL-python/modAL/pulse
Sign up for GitHub https://patch-diff.githubusercontent.com/signup?return_to=%2FmodAL-python%2FmodAL%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://patch-diff.githubusercontent.com/login?return_to=%2FmodAL-python%2FmodAL%2Fissues%2Fnew%2Fchoose
adeleviehttps://patch-diff.githubusercontent.com/adelevie
modAL-python:masterhttps://patch-diff.githubusercontent.com/modAL-python/modAL/tree/master
adelevie:flexible-learner-interfacehttps://patch-diff.githubusercontent.com/adelevie/modAL/tree/flexible-learner-interface
Conversation 2 https://patch-diff.githubusercontent.com/modAL-python/modAL/pull/160
Commits 1 https://patch-diff.githubusercontent.com/modAL-python/modAL/pull/160/commits
Checks 0 https://patch-diff.githubusercontent.com/modAL-python/modAL/pull/160/checks
Files changed https://patch-diff.githubusercontent.com/modAL-python/modAL/pull/160/files
Please reload this pagehttps://patch-diff.githubusercontent.com/modAL-python/modAL/pull/160/checks
Please reload this pagehttps://patch-diff.githubusercontent.com/modAL-python/modAL/pull/160/checks
Proof of concept for allowing non-sklearn estimators https://patch-diff.githubusercontent.com/modAL-python/modAL/pull/160/checks#top
Please reload this pagehttps://patch-diff.githubusercontent.com/modAL-python/modAL/pull/160/checks
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.