首页 > 解决方案 > How to insert the values instated of csv file?

问题描述

I have this block of code, how can I replace large amount of values instated of csv file? Is that csv file values can be placed without using the csv dataset?

v= pandas.read_csv('baltic.csv',header=None); # Load the sensor and measurement data file
v=v.values
y=v[:,:3]; #define metrology or measurement matrix

x=v[:, 3:30]; #obtain process sensor data matrix

##Normalize input and output data
X = normal(x); #get z score for input data
Y = normal(y); #get z score for input data
##Mean and stdev of y
y_mean = np.mean(y,axis=0);           # mean of output y
y_std = np.std(y,ddof=1,axis=0);             # standard deviation of output y

T,P,Q,B,R2X,R2Y = pls (X,Y,7); #choose 7 PCs.

X_reconstructed=T.dot(P.T); #This is for testing of re-construct of input data.
Y_reconstructed=X.dot(P.dot(B.dot(Q.T))); #This is for testing of y prediction.

## Simulation of prediction. The sample data is x, in future we need to pull 
## some new data from FD
x_new=X; #to be changed to new data set.
m1,n1=y.shape;
m,n=x_new.shape;
    Y_predicted=np.zeros((m,n1))
for i in range(m):
    xi=x_new[i,:]; 
    t_new=xi.dot(P); #Calculate new score.
    u_new=t_new.dot(B);
    Y_predicted[i,:n1]=u_new.dot(Q.T);
 
y_predicted=Y_predicted*y_std+y_mean;

PredictionCoefficients=P.dot(B.dot(Q.T));

标签: csv

解决方案


推荐阅读