I found a question on here (Multivariate (polynomial) best fit curve in python?) which I believe would answer my question but I cannot get multipolyfit installed fully. I have used 'pip install multipolyfit' which worked, but when I run this script I get a traceback saying
Traceback
"from core import multipolyfit, mk_model, mk_sympy_function
ModuleNotFoundError: No module named 'core'"
Code
import os
import csv
import pandas as pd
print('\n'*2)
import re
import matplotlib
import multipolyfit as mpf
from matplotlib.figure import Figure
from matplotlib import style
import numpy as np
import math
import matplotlib.pyplot as plt
from matplotlib.legend_handler import HandlerLine2D
from scipy.stats import linregress
x = [190,195,200,205,210,215,220,225,230,235,240,245,250,255,260,265,270,275,280,285,290]
av_50 = [5.045, 5.05, 5.115, 5.23, 5.355, 5.42, 5.59, 5.77, 5.855, 5.8, 5.745, 5.725, 5.795, 5.835, 5.81, 5.73, 5.675, 5.65, 5.63, 5.555, 5.405]
def min_max_values(num_list):
results_list = sorted(num_list)
return results_list[0], results_list[-1]
min_x, max_x = min_max_values(x)
# Plotting
plt.axis([min_x - 5, max_x + 5, 0, 8])
x = np.array(x)
y = np.array(av_50)
plt.plot(x, y, 'kx')
stacked_x = numpy.array([x,x+1,x-1])
coeffs = mpf(stacked_x, y, deg)
x2 = numpy.arange(min(x)-1, max(x)+1, .01) #use more points for a smoother plot
y2 = numpy.polyval(coeffs, x2) #Evaluates the polynomial for each x2 value
plt.plot(x2, y2, label="deg=3")
plt.show()
Try installing directly from the repo
git clone https://github.com/mrocklin/multipolyfit.git
cd multipolyfit
pip install -e .