New: failed analytics

This commit is contained in:
L-Nafaryus 2021-10-06 00:58:37 +05:00
parent 2ea14a5770
commit 8c2953b3ec
No known key found for this signature in database
GPG Key ID: C76D8DCD2727DBB7
5 changed files with 1183 additions and 24 deletions

1
.gitignore vendored
View File

@ -18,3 +18,4 @@ env/
*.toc
*.out
*.egg-info
.ipynb_checkpoints/

708
playground/analytics.ipynb Normal file

File diff suppressed because one or more lines are too long

View File

@ -39,17 +39,25 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "86b8162b-ed07-4c65-9c31-3f18daafc915",
"id": "3bc80bca-03ce-416e-be2f-ab7ae2af95fa",
"metadata": {},
"outputs": [],
"source": [
"df_keys = [ key for key in df.keys() ]"
"df_numeric = df[[\n",
" col for col in df.columns \n",
" if not isinstance(df[col][0], str) \n",
" and not isinstance(df[col][0], numpy.bool_)\n",
" and not isinstance(df[col][0], dict)\n",
" and not isinstance(df[col][0], list)\n",
" and not df[col][0] is None\n",
" and not col[-3: ] == \"_id\"\n",
"]]"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "3bc80bca-03ce-416e-be2f-ab7ae2af95fa",
"execution_count": 5,
"id": "eab92bcc-8f1f-4490-8dc6-8ebf191d6cf2",
"metadata": {},
"outputs": [
{
@ -58,7 +66,7 @@
"<AxesSubplot:>"
]
},
"execution_count": 18,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
},
@ -74,21 +82,190 @@
}
],
"source": [
"df_numeric = df[[\n",
" col for col in df.columns \n",
" if not isinstance(df[col][0], str) \n",
" and not isinstance(df[col][0], numpy.bool_)\n",
" and not isinstance(df[col][0], dict)\n",
" and not col[-3: ] == \"_id\"\n",
"]]\n",
"seaborn.set(rc = { \"figure.figsize\": (30, 20) })\n",
"seaborn.heatmap(df_numeric.corr(), annot = True)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "7611c892-1e13-404e-849e-3cfa15d8dfca",
"metadata": {},
"outputs": [],
"source": [
"x = df_numeric[[\"theta\", \"r0\", \"L\", \"radius\"]] #.drop(columns = [\"flowRate\"])\n",
"y = df_numeric[\"flowRate\"]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "1a38aaa0-89fb-40f7-abce-e500ab696349",
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import train_test_split\n",
"xtr, xte, ytr, yte = train_test_split(x, y, test_size = 0.2, random_state = 100)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "1b7e9f62-35a9-4a1a-9ffa-a2a6e757ff46",
"metadata": {},
"outputs": [],
"source": [
"from sklearn import preprocessing\n",
"scaler = preprocessing.MinMaxScaler()\n",
"x_scaled = scaler.fit_transform(xtr)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "19bd2f52-a5bf-404c-93f7-0626bc35a915",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"DecisionTreeRegressor(random_state=500)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn.tree import DecisionTreeRegressor\n",
"neigh = DecisionTreeRegressor(random_state = 500)\n",
"neigh.fit(x_scaled, ytr)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "d063265f-2f06-4290-811e-b6b1753bcac9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2.664398739090909e-15"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn.metrics import mean_absolute_error\n",
"xte_scaled = scaler.transform(xte)\n",
"y_pred = neigh.predict(xte_scaled)\n",
"mean_absolute_error(yte, y_pred)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "762af50c-371a-4ba5-b5ab-763970ef2a37",
"metadata": {},
"outputs": [],
"source": [
"#df_numeric[[\"theta\", \"r0\", \"L\", \"radius\", \"flowRate\", \"volumeCell\", \"volume\"]]"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "7a951647-efa1-4231-b96d-f67bc0ed6c33",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>theta</th>\n",
" <th>r0</th>\n",
" <th>L</th>\n",
" <th>radius</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0.29</td>\n",
" <td>1.0</td>\n",
" <td>2.0</td>\n",
" <td>1.408451</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" theta r0 L radius\n",
"0 0.29 1.0 2.0 1.408451"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"test_df = DataFrame([{\n",
" \"theta\": 0.29,\n",
" \"r0\": 1.,\n",
" \"L\": 2.,\n",
" \"radius\": 1. / (1. - 0.29)\n",
"}]); test_df"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "bc9204db-bde4-4032-b4f5-313e99e25ab5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([4.53058768e-15])"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"neigh.predict(scaler.transform(test_df))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1fda6819-a8da-4751-be3d-d62320b799ae",
"id": "4b95277f-c49e-42b9-8d5f-3334d5ca7729",
"metadata": {},
"outputs": [],
"source": []
@ -96,15 +273,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f19311bb-e992-4592-83b2-0b003a6b78ae",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "7f06bc5b-80ba-4763-8fec-121c0623ccf2",
"id": "c56035b1-18d5-4c88-94b6-da4d7eccac9a",
"metadata": {},
"outputs": [],
"source": []
@ -112,7 +281,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@ -126,7 +295,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.6"
}
},
"nbformat": 4,

Binary file not shown.

View File

@ -0,0 +1,281 @@
# -*- coding: utf-8 -*-
# This file is part of anisotropy.
# License: GNU GPL version 3, see the file "LICENSE" for details.
[logger]
name = "anisotropy"
format = "[ %(levelname)s ] %(message)s"
[base]
simple = true
bodyCentered = true
faceCentered = true
[[structures]]
[structures.structure]
type = "simple"
# auto # from theta: list # theta: float
theta = [0.01, 0.28, 0.01] # [min, max, step]
# auto # from directions:list # direction: list
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
# r0 =
# L =
# radius =
filletsEnabled = true
# auto # fillets: float
[structures.mesh]
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.5
nbSegPerEdge = 2
nbSegPerRadius = 1
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
viscousLayers = false
thickness = [0.01, 0.005] # [min, max] # step is controlled by theta count
numberOfLayers = 1
stretchFactor = 1
isFacesToIgnore = true
facesToIgnore = ["inlet", "outlet"]
# auto # faces: list
extrusionMethod = "SURF_OFFSET_SMOOTH"
[[structures.submesh]]
name = "strips"
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.2
nbSegPerEdge = 2
nbSegPerRadius = 3
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
[structures.flowapproximation]
transportProperties.nu = 1e-6
pressure.boundaryField.inlet = { type = "fixedValue", value = 1e-3 }
pressure.boundaryField.outlet = { type = "fixedValue", value = 0.0 }
# multiplication velocity value with flow direction vector
velocity.boundaryField.inlet = { type = "fixedValue", value = 6e-5 }
velocity.boundaryField.outlet = { type = "zeroGradient", value = "None" }
[structures.flow]
scale = [ 1e-5, 1e-5, 1e-5 ]
transportProperties.nu = 1e-6
pressure.boundaryField.inlet = { type = "fixedValue", value = 1e-3 }
pressure.boundaryField.outlet = { type = "fixedValue", value = 0.0 }
velocity.boundaryField.inlet = { type = "pressureInletVelocity", value = 0.0 }
velocity.boundaryField.outlet = { type = "zeroGradient", value = "None" }
[[structures]]
[structures.structure]
type = "bodyCentered"
# auto # from theta: list # theta: float
theta = [0.01, 0.17, 0.01] # [min, max, step]
# auto # from directions:list # direction: list
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
# r0 =
# L =
# radius =
filletsEnabled = true
# auto # fillets: float
[structures.mesh]
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.5
nbSegPerEdge = 2
nbSegPerRadius = 1
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
viscousLayers = false
thickness = [0.005, 0.0005] # [min, max] # step is controlled by theta count
numberOfLayers = 1
stretchFactor = 1
isFacesToIgnore = true
facesToIgnore = ["inlet", "outlet"]
# auto # faces: list
extrusionMethod = "SURF_OFFSET_SMOOTH"
[[structures.submesh]]
name = "strips"
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.2
nbSegPerEdge = 2
nbSegPerRadius = 3
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
[structures.flowapproximation]
transportProperties.nu = 1e-6
pressure.boundaryField.inlet = { type = "fixedValue", value = 1e-3 }
pressure.boundaryField.outlet = { type = "fixedValue", value = 0.0 }
# multiplication velocity value with direction vector
velocity.boundaryField.inlet = { type = "fixedValue", value = 6e-5 }
velocity.boundaryField.outlet = { type = "zeroGradient", value = "None" }
[structures.flow]
scale = [ 1e-5, 1e-5, 1e-5 ]
transportProperties.nu = 1e-6
pressure.boundaryField.inlet = { type = "fixedValue", value = 1e-3 }
pressure.boundaryField.outlet = { type = "fixedValue", value = 0.0 }
velocity.boundaryField.inlet = { type = "pressureInletVelocity", value = 0.0 }
velocity.boundaryField.outlet = { type = "zeroGradient", value = "None" }
[[structures]]
[structures.structure]
type = "faceCentered"
# auto # from theta: list # theta: float
theta = [0.01, 0.12, 0.01] # [min, max, step]
# auto # from directions:list # direction: list
directions = [
[1, 0, 0],
[0, 0, 1],
[1, 1, 1]
]
# r0 =
# L =
# radius =
filletsEnabled = true
# auto # fillets: float
[structures.mesh]
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.5
nbSegPerEdge = 2
nbSegPerRadius = 1
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
viscousLayers = false
thickness = [0.001, 0.0005] # [min, max] # step is controlled by theta count
numberOfLayers = 1
stretchFactor = 1
isFacesToIgnore = true
facesToIgnore = ["inlet", "outlet"]
# auto # faces: list
extrusionMethod = "SURF_OFFSET_SMOOTH"
[[structures.submesh]]
name = "strips"
maxSize = 0.5
minSize = 0.05
fineness = 5
growthRate = 0.2
nbSegPerEdge = 2
nbSegPerRadius = 3
chordalErrorEnabled = true
chordalError = 0.25
secondOrder = false
optimize = true
quadAllowed = false
useSurfaceCurvature = true
fuseEdges = true
checkChartBoundary = false
[structures.flowapproximation]
transportProperties.nu = 1e-6
pressure.boundaryField.inlet = { type = "fixedValue", value = 1e-3 }
pressure.boundaryField.outlet = { type = "fixedValue", value = 0.0 }
# multiplication velocity value with direction vector
velocity.boundaryField.inlet = { type = "fixedValue", value = 6e-5 }
velocity.boundaryField.outlet = { type = "zeroGradient", value = "None" }
[structures.flow]
scale = [ 1e-5, 1e-5, 1e-5 ]
transportProperties.nu = 1e-6
pressure.boundaryField.inlet = { type = "fixedValue", value = 1e-3 }
pressure.boundaryField.outlet = { type = "fixedValue", value = 0.0 }
velocity.boundaryField.inlet = { type = "pressureInletVelocity", value = 0.0 }
velocity.boundaryField.outlet = { type = "zeroGradient", value = "None" }