Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ data = TailData(name='CAIDA_KONECT').data
estimator = HillEstimator()
estimator.fit(data)

# Get the estimated parameters
result = estimator.get_parameters()
# Get the estimated results
result = estimator.get_result()

# Get the power law exponent
gamma = result.gamma
gamma = result.gamma_

# Print full results
print(result)
Expand All @@ -59,11 +59,11 @@ degree = list(dict(G.degree()).values()) # Degree sequence
estimator = HillEstimator()
estimator.fit(degree)

# Get the estimated parameters
result = estimator.get_parameters()
# Get the estimated results
result = estimator.get_result()

# Get the power law exponent
gamma = result.gamma
gamma = result.gamma_

# Print full results
print(result)
Expand All @@ -87,10 +87,10 @@ The package provides several estimators for tail estimation. For details on para
- Smoothed version of the Hill estimator (no bootstrap)

## Results
The full result can be obtained by `estimator.get_parameters()`, which returns a dictionary. This includes:
- `gamma`: Power law exponent (γ = 1 + 1/ξ)
- `xi_star`: Tail index (ξ)
- `k_star`: Optimal order statistic
The full result can be obtained by `estimator.get_result()`, which is a TailEstimatorResult object. This includes attributes such as:
- `gamma_`: Power law exponent (γ = 1 + 1/ξ)
- `xi_star_`: Tail index (ξ)
- `k_star_`: Optimal order statistic
- Bootstrap results (when applicable):
- First and second bootstrap AMSE values
- Optimal bandwidths or minimum AMSE fractions
Expand Down
4 changes: 2 additions & 2 deletions docs/estimators/hill.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Examples
hill = HillEstimator()
hill.fit(data)

# Get estimated parameters
params = hill.get_parameters()
# Get estimated values
res = hill.get_result()
4 changes: 2 additions & 2 deletions docs/estimators/kernel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ Examples
)
kernel.fit(data)

# Get estimated parameters
params = kernel.get_parameters()
# Get estimated values
res = kernel.get_result()
4 changes: 2 additions & 2 deletions docs/estimators/moments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ Examples
moments = MomentsEstimator()
moments.fit(data)

# Get estimated parameters
params = moments.get_parameters()
# Get estimated values
res = moments.get_result()
4 changes: 2 additions & 2 deletions docs/estimators/pickands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Examples
pickands = PickandsEstimator()
pickands.fit(data)

# Get estimated parameters
params = pickands.get_parameters()
# Get estimated values
res = pickands.get_result()
4 changes: 2 additions & 2 deletions docs/estimators/smooth_hill.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ Examples
smooth_hill = SmoothHillEstimator()
smooth_hill.fit(data)

# Get estimated parameters
params = smooth_hill.get_parameters()
# Get estimated values
res = smooth_hill.get_result()

8 changes: 4 additions & 4 deletions docs/result.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ Examples
hill = HillEstimator()
hill.fit(data)
# Get estimated parameters
result = hill.get_parameters() # This returns TailEstimatorResult class.
# Get estimated values
result = hill.get_result() # This returns TailEstimatorResult class.
print(result)
# Access individual parameters
gamma = result.gamma # Power-law exponent estimate
xi = result.xi # Tail index estimate
gamma = result.gamma_ # Power-law exponent estimate
xi = result.xi_ # Tail index estimate
20 changes: 10 additions & 10 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Using Built-in Datasets
estimator = HillEstimator()
estimator.fit(data)
# Get the estimated parameters
result = estimator.get_parameters()
gamma = result.gamma
# Get estimated values
result = estimator.get_result()
gamma = result.gamma_
# Print full results
print(result)
Expand All @@ -55,9 +55,9 @@ Using degree sequence from networkx graphs
estimator = HillEstimator()
estimator.fit(degree)
# Get the estimated parameters
result = estimator.get_parameters()
gamma = result.gamma
# Get estimated values
result = estimator.get_result()
gamma = result.gamma_
# Print full results
print(result)
Expand All @@ -84,11 +84,11 @@ The package provides several estimators for tail estimation. For details on each
Results
-------

The full result can be obtained by ``result = estimator.get_parameters()``. You can either print the result, or access individual attributes (e.g., `result.gamma`). The output will include:
The full result can be obtained by ``result = estimator.get_result()``. You can either print the result, or access individual attributes (e.g., `result.gamma_`). The output will include values such as:

- ``gamma``: Power law exponent (γ = 1 + 1/ξ)
- ``xi_star``: Tail index (ξ)
- ``k_star``: Optimal order statistic
- ``gamma_``: Power law exponent (γ = 1 + 1/ξ)
- ``xi_star_``: Tail index (ξ)
- ``k_star_``: Optimal order statistic
- Bootstrap results (when applicable):
- First and second bootstrap AMSE values
- Optimal bandwidths or minimum AMSE fractions
Expand Down
132 changes: 99 additions & 33 deletions examples/example.ipynb

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
estimator.fit(data)
print(estimator)

# Get the estimated parameters
result = estimator.get_parameters()
# Get the parameters of the estimator
params = estimator.get_params()

# Get estimated values
result = estimator.get_result()

# Get the power law exponent
gamma = result.gamma
gamma = result.gamma_

# Print full results
print(result)
Expand Down
282 changes: 282 additions & 0 deletions examples/testing.ipynb

Large diffs are not rendered by default.

27 changes: 23 additions & 4 deletions src/tailestim/estimators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,22 @@ def fit(self, data: np.ndarray) -> None:
self.results = self._estimate(ordered_data)

@abstractmethod
def get_parameters(self) -> TailEstimatorResult:
def get_params(self) -> Dict[str, Any]:
"""Get the parameters of the estimator.

Returns
-------
dict
Dictionary containing the parameters of the estimator.
"""
return {
"bootstrap": self.bootstrap,
"base_seed": self.base_seed,
**self.kwargs
}

@abstractmethod
def get_result(self) -> TailEstimatorResult:
"""Get the estimated parameters.

Returns
Expand All @@ -73,14 +88,18 @@ def get_parameters(self) -> TailEstimatorResult:
--------
>>> hill = HillEstimator()
>>> hill.fit(data)
>>> result = hill.get_parameters()
>>> gamma = result.gamma # Access the tail index
>>> xi = result.xi # Access the shape parameter (if available)
>>> result = hill.get_result()
>>> gamma = result.gamma_
>>> xi = result.xi_

"""
if self.results is None:
raise ValueError("Model not fitted yet. Call fit() first.")
return TailEstimatorResult()

def __repr__(self) -> str:
"""Return a string representation of the estimator."""
return f"{self.__class__.__name__}(bootstrap={self.bootstrap}, base_seed={self.base_seed}, kwargs={self.kwargs})"

def __str__(self) -> str:
"""Format estimation object as a string."""
Expand Down
Loading