FairlyUncertain Documentation
Table of Contents
- How to Add a New Dataset
- How to Write a New Experiment
- How to Add a New Model/Algorithm
- How to Add a New Metric/Evaluation
How to Add a New Dataset
To add a new dataset, follow these steps.
-
Import Necessary Libraries
Ensure you have the required libraries imported:
import pickle import os import numpy as np import pandas as pd import requests
-
Create Dataset Loader Function
Implement a function to load your new dataset. Here is an example:
def get_new_dataset():
# Add logic to download, preprocess and return your dataset
pass
- Update Data Loaders Dictionary
Add the new dataset loader function to the dictionary of data loaders:
dataloaders = {
'New Dataset': get_new_dataset,
# other datasets...
}
- Ensure Dataset Caching
Make sure your dataset is cached for quick access:
def cache_dataset(name):
# Logic to cache the dataset
pass
def read_dataset(name):
# Logic to read the cached dataset
pass
```
5. **Load Dataset Instance**
Ensure that the dataset can be loaded correctly:
```python
def load_instance(name, train_split=.8):
# Logic to load dataset instance
pass
How to Write a New Experiment
To write a new experiment, follow these steps:
- Import Necessary Libraries
Ensure all required libraries are imported:
from tqdm import tqdm
import numpy as np
...
import fairlyuncertain as fu
- Define Algorithms to Test
List the algorithms you want to test:
algorithm_names = ['Algorithm1', 'Algorithm2']
algorithms = {name: fu.algorithms[name] for name in algorithm_names}
- Run Experiments
Loop through datasets and algorithms to run your experiments:
results = {}
for dataset in tqdm(yp.datasets):
instance = fu.load_instance(dataset)
results[dataset] = {'instance': instance}
for algo_name in algorithms:
results[dataset][algo_name] = algorithms[algo_name](instance)
- Evaluate and Plot Results
Evaluate the results using the appropriate metrics and plot the outcomes:
for metric_name in fu.metrics:
fu.plot_results(results, algorithms, fu.datasets, metric_name=metric_name)
How to Add a New Model/Algorithm
To add a new model or algorithm, follow these steps:
- Add your Model Class if Necessary
If your new algorithm requires a new model class, make those changes:
class Model:
def __init__(self, **kwargs):
# Initialization logic
pass
def fit(self, X, y):
# Fit logic
pass
def predict(self, X):
# Prediction logic
pass
```
2. **Import Necessary Libraries**
Ensure necessary libraries and modules are imported:
```python
import numpy as np
...
import fairlyuncertain as fu
- Define the New Algorithm
Implement the logic for your new algorithm:
def new_algorithm(instance, Model):
# Algorithm implementation
pass
- Add Algorithm to Dictionary
Update the algorithms dictionary to include your new algorithm:
algorithms = {
'New Algorithm': new_algorithm,
# other algorithms...
}
How to Add a New Metric/Evaluation
To add a new metric or evaluation, follow these steps:
- Import Necessary Libraries
Import required libraries for your metric:
import numpy as np
...
- Define the New Metric
Implement the logic for the new metric:
def new_metric(pred, y, group):
# Metric calculation logic
pass
- Add Metric to Dictionary
Update the metrics dictionary to include your new metric:
metrics = {
'New Metric': new_metric,
# other metrics...
}
- Use New Metric in Evaluation
Ensure the new metric is used in the evaluation process:
def evaluate_metrics(results, metrics):
for metric_name in metrics:
for dataset in results:
results[dataset][metric_name] = metrics[metric_name](
results[dataset]['pred'],
results[dataset]['y'],
results[dataset]['group']
)
Metadata
Release files for fairlyuncertain 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fairlyuncertain-0.0.4.tar.gz | 22.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fairlyuncertain-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 49.6 kB
Release files / fairlyuncertain-0.0.4.tar.gz
| Download URL | fairlyuncertain-0.0.4.tar.gz |
|---|---|
| Size | 22.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d664426e9fb3d2c45000009f71d414c5a03fd245e8a447215e20da1576ecaee4
|
|
BLAKE2b-256 checksum How to use checksums |
081aba7483d0a1c7cea665de613717f617e4817985089c7b25076cd21a15e45f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Release files / fairlyuncertain-0.0.4-py3-none-any.whl
| Download URL | fairlyuncertain-0.0.4-py3-none-any.whl |
|---|---|
| Size | 27.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f2c557a653905c258c08ef3a3ee58826be7d7ae789432ed123a70b2a4fff5755
|
|
BLAKE2b-256 checksum How to use checksums |
1b16ba244d49cbe0ecb22b87a3b98d823d5eeace73a61126bd0a469f07cf9b14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|