Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I'm following this tutorial in youtube (https://www.youtube.com/watch?v=CPuDfovUuTs) to create a polynomial regresssion in Power BI. I have the same exact script but I'm getting this error:
Error Message:
Þγτћŏл §сґĩρţ ęѓгŏř.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 41, in <module>
y_pred_p = model.predict(poly_feat.fit_transform(param_val))
File "C:\Users\Nabila\miniconda3\envs\std_env\lib\site-packages\sklearn\base.py", line 690, in fit_transform
return self.fit(X, **fit_params).transform(X)
File "C:\Users\Nabila\miniconda3\envs\std_env\lib\site-packages\sklearn\preprocessing\_data.py", line 1513, in fit
X, accept_sparse=True).shape
File "C:\Users\Nabila\miniconda3\envs\std_env\lib\site-packages\sklearn\base.py", line 420, in _validate_data
X = check_array(X, **check_params)
File "C:\Users\Nabila\miniconda3\envs\std_env\lib\site-packages\sklearn\utils\validation.py", line 73, in inner_f
return f(**kwargs)
File "C:\Users\Nabila\miniconda3\envs\std_env\lib\site-packages\sklearn\utils\validation.py", line 617, in check_array
"if it contains a single sample.".format(array))
ValueError: Expected 2D array, got scalar array instead:
array=5.
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
Note: I'm using Python with Miniconda so the file path I have specified in Power BI is C\Nabila\miniconda3\envs\std_env
and I have all the packages numpy, sklearn, pandas and matplotlib installed. It's worthy to emntion that I created the environment using Python 3.6 following this tutorial (https://medium.com/@pbabbott/how-to-connect-power-bi-and-python-on-windows-10-b131a36f4b44)
I tried many things but cant get it working , please help
Hi @nabitti ,
Please refer to the following links that have similar issues to yours:
https://stackoverflow.com/questions/54296377/valueerror-expected-2d-array-got-scalar-array-instead
https://datascience.stackexchange.com/questions/53048/expected-2d-array-got-scalar-array-instead
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Hello @v-deddai1-msft , thank you for your reply.
I followed the links you mentioned and modified my script but now I have this other error that I do not know how to correct.
This is my script:
Error Message:
Þγτћŏл §сґĩρţ ęѓгŏř.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 50, in <module>
plt.plot(X_line,model.predict(poly_feat.fit_transofrm(X_line)),color='green')
AttributeError: 'PolynomialFeatures' object has no attribute 'fit_transofrm'
I dont know how to correct it. Hope someone can help. Thank you so much.
Hi @nabitti ,
Your issue is more related to python. I suggest you open a thread in python forumn in SO. People there will help you well. Please also refer to the similar post: https://stackoverflow.com/questions/56201362/polynomialfeatures-object-has-no-attribute-predict
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.