1 year ago
#356225
Roosha
How to fix KeyError: 'alpha' while fitting data with fitter package?
I installed fitter
on my anaconda in order to use it for collective curve fitting of real data on many distributions simultanously and choose the best fitting. However, it seems that out of the box, it has some sort of bug. Can anyone let me know what it is and how to fix it?
File "c:\Users\username\Desktop\Project\PythonTool\calculator\graph-analyzer\my_script.py", line 253, in curve_finder
print(f.get_best(method='sumsquare_error'))
File "C:\ProgramData\Anaconda3\envs\tf\lib\site-packages\fitter\fitter.py", line 366, in get_best
params = self.fitted_param[name]
KeyError: 'alpha'
Per Mikuszefski's request, here is a MWE to reproduce the error message:
import pandas as pd
import seaborn as sns
from fitter import Fitter
from typing import List
#constants
data: List = [('A', 1, 'Company1', 10), ('B', 4, 'Company2', 20), ('C', 3, 'Company3', 5),
('D', 3, 'Company3', 1), ('E', 2, 'Company1', 2), ('F', 4, 'Company3', 9),
('G', 3, 'Company3', 7), ('H', 2, 'Company1', 1), ('I', 4, 'Company2', 15),
('J', 8, 'Company1', 1), ('K', 2, 'Company2', 3), ('L', 4, 'Company2', 6),
('M', 6, 'Company2', 3), ('N', 2, 'Company2', 10), ('O', 4, 'Company3', 10),
('P', 3, 'Company1', 1), ('Q', 2, 'Company2', 5), ('R', 4, 'Company1', 4)]
#Main driving function
def main() -> None:
dataset = pd.DataFrame(data, columns=['Label', 'Degree', 'Affiliation', 'Duration'])
degrees = dataset["Degree"].values
f = Fitter(degrees)
f.fit()
print(f.get_best(method='sumsquare_error'))
print(f.summary())
if __name__ == "__main__":
main()
python-3.x
scipy
curve-fitting
anaconda3
model-fitting
0 Answers
Your Answer