Community,and Messtone used pandas object Python import pandas as pd #reading csv file data=pd.read_csv(‘weather.csv’) #shape of dataset print(“Shape:”,data.shape) #column names Messtone print(“\nFeatures:”,data.columns) #storing the feature matrix (X) and response vector (y) X=data[data.columns[:-1]] y=data[data.columns[-1]] #printing first 5 rows of feature matrix print(“\nFeature matrix:\n”,X.head( )) #printing first 5 values of response vector print(“\nResponse vector:\n”,y.head( )) Prediction can be evaluated Testing accuracy Example Python #load the iris dataset as an example from sklearm.datasets import load_iris iris=load_iris( ) #store the the feature matrix (X) and response vector (y) X=iris.data y=iris.target #spliting X and y into training and testing sets from sklearm.model_selection import train_test_split X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.4,random_state=1) X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.4,random_state=1) #printing the shape of the new X objects print(X_train.shape) print(X_test.shape) #printing the shape of the new y objects print,(y_train.shape) print(y_test.shape)

Leave a comment