Dear Experts,
I was wondered how can we arrange 2d Interpolation.
Input is 80, Output must be value between: 0.9 - 1.0
1.dyn (3.4 KB)
Dear Experts,
I was wondered how can we arrange 2d Interpolation.
Input is 80, Output must be value between: 0.9 - 1.0
1.dyn (3.4 KB)
Math.RemapRange where the low is the nearest number below your value, and the high is the nearest above your value.
To find the lowest, ask if each value in the mapping is less than your value (< node), then a List.FilterByBoolMask node to filter the list of mapping values by the booleans from the < node, then a List.LastItem node to pull the last of the in values.
To find the highest, ask if each value in the mapping is greater than or equal to your value (>= node), then use a List.FilterByBoolMask node to filter the list of mapping values by the boolean values from the >= node, and pull the first of the included values.
Give it a shot and see where you get.
Dear Jacob,
many thanks for prompt feedback. However, i am looking for alternative solution if possible.
Anything is possible, but we need your desired parameters for what type of solution would be valid and why those parameters are set to help find a solution that meets them.
Another option would be to use the top row of values as an X and the bottoms row of values as the Y, and create points which can be used to define a NurbsCurve or PolyCurve. From there you can get the YZ plane and translate it on thr X axis by your value, and intersect the translated plane with the curve. The resulting point’s Y value will be the interpolated value.
Definitely. Looking for nurb or poly curve version
Extract the X and Y values from your chart or otherwise type them in, build some points from those, and then use a NurbsCurve.ByPoints node as a start.
How?
I am totally noob on curves. Will be very greatfull if get screenshot or dyn file.
I shared dyn file for input value.
quote=“jacob.small, post:6, topic:96642, full:true”]
Extract the X and Y values from your chart or otherwise type them in, build some points from those, and then use a NurbsCurve.ByPoints node as a start.
[/quote]
Mr. Jacob must be far from a computer I think, here is
what he explained to you
cordially
christian.stan
Dear Christian,
sorry for late respond. Script was working create until i realized mistake on the one of the input value.
Input is 0.66. Output must be aprrx. 0.12. But giving three output and error.
Could you please check reason of error?
hi, I’m trying to provide an answer, even if it’s well beyond my skills
As you are looking for linear interpolations, choose more polycurve which produces line segments between points
(see red and green curve)
I think the curve (nurb) is so extended with few points defining it
the 3 points
1st point: intersection point
2 and 3 point: tangent on this interval
but nothing is certain
you would have a more scientific answer with Mr. Jacob or Mr. Durmus_Cesur
Sincerely
christian.stan
Result with scipy (python)
Although there wasn’t enough data, I tested it out of curiosity using deep learning (tensorflow + keras).
Hi, it is true that the numpy and scipy modules are safe bets to approach this topic,
as for the second part (I feel in the situation where I would have taken the license for an automatic car and I would be asked to drive a car with a clutch), in short I still have to work, as usual.
Thank you for the feedback.
cordially
christian.stan
Dear Poupin,
Can you share python code please, in order to test it?
Thanks.
Here is the code with scipy
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('Python.Included')
import Python.Included as pyInc
path_py3_lib = pyInc.Installer.EmbeddedPythonHome
sys.path.append(path_py3_lib + r'\Lib\site-packages')
import numpy as np
from scipy import interpolate
# x,y arrays
x = np.array(IN[0])
y = np.array(IN[1])
f = interpolate.interp1d(x, y)
ynew = f([IN[2]])
OUT = ynew
If you prefer to use .Net you can try MathNet.Numerics
Hey,
I just saw your post and wanted to see the predictions of different models using sklearn.regression with very little data.
PS: It should be noted that using ML with little data does not give very good results. Deeplearning is the best option for such situations. @c.poupin
#Copyright(c) 2023, Durmus Bayryam
# Gıthub : https://github.com/DurmusCesur/Shapely.git
import clr
import sys
import re
import System
clr.AddReference('Python.Included')
import Python.Included as pyInc
path_py3_lib = pyInc.Installer.EmbeddedPythonHome
sys.path.append(path_py3_lib + r'\Lib\site-packages')
import numpy as np
import pandas as pd
from io import StringIO
import tensorflow as tf
from tensorflow.python.client import device_lib
from sklearn.linear_model import LinearRegression
from sklearn.kernel_ridge import KernelRidge
from sklearn.tree import DecisionTreeRegressor
from sklearn.svm import SVR
# Input
column = IN[1]
data = pd.read_csv(IN[0],usecols=column)
X_train = data.drop(columns=["label"])
y_train = data["label"]
X_test = IN[2]
# Model
models = {
'Linear Regression': LinearRegression(),
'DecisionTree Regression': DecisionTreeRegressor(),
'Ridge Regression': KernelRidge(alpha=1.0),
'SVR Regression': SVR()
}
# Prediction
predictions = {}
for name, model in models.items():
model.fit(X_train, y_train)
y_test = model.predict(X_test)
predictions[name] = y_test
OUT = predictions
ML-Interpolation.dyn (28.2 KB)
Hi, thanks for your feedback
I still have to work a lot to fully understand it, even if I understand the overall idea (the more data there is, the better the prediction)
Sincerely
christian.stan