From 547d8ddf691c9bac6dafde6737e9b8900f4b7556 Mon Sep 17 00:00:00 2001 From: Steinmann Victor <victor.steinmann@arcor.de> Date: Sun, 24 Nov 2024 20:40:58 +0100 Subject: [PATCH] added regression of condesed .csv's --- Kennlinien_und_Fitting.ipynb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Kennlinien_und_Fitting.ipynb b/Kennlinien_und_Fitting.ipynb index f29b100..7f6082b 100644 --- a/Kennlinien_und_Fitting.ipynb +++ b/Kennlinien_und_Fitting.ipynb @@ -103,7 +103,7 @@ }, { "cell_type": "code", - "execution_count": 90, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -118,6 +118,8 @@ " array = df.loc[:,['Q','n_rel','H']].to_numpy(float)\n", " array = np.append(array,df_P.loc[:,['P']].to_numpy(float),axis=1)\n", " continue\n", + " #abschneiden der datanpaare, die keine korrespondierenden werte für H oder P haben\n", + " #vielleicht dumm \n", " if len(df.index)<len(df_P.index):\n", " for i in range(len(df_P.index)-len(df.index)):\n", " df_P.drop(len(df.index)+i,inplace=True)\n", @@ -189,7 +191,7 @@ }, { "cell_type": "code", - "execution_count": 110, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -214,7 +216,19 @@ } ], "source": [ + "import pandas as pd\n", + "import numpy as np\n", + "from sklearn.linear_model import LinearRegression\n", + "\n", "df = pd.DataFrame(combine_csvs(),columns=['Q','n','H','P'])\n", + "X = np.empty((0,3),float)\n", + "for i in df.index:\n", + " Q_temp=df.loc['Q'].get(i)\n", + " n_temp=df.loc['n'].get(i)\n", + " X = np.append(X,[[Q_temp**2,Q_temp*n_temp,n_temp**2], df.loc],axis=0)\n", + "\n", + "LR_H = LinearRegression(fit_intercept=False).fit(X , df.loc['H'].to_numpy(float))\n", + "\n", "print(df)" ] }, -- GitLab