草莓味的棉花糖|使用HOG对卫星图像中的船舶进行分类( 二 )


如果我们可视化hog_images对应于之前的图像 , 我们将得到这样的结果
#Extractthelabelsfromthedatasetlabels=np.array(dataset['labels']).reshape(len(dataset['labels']),1)#Createtheclassifierclf=svm.SVC()hog_features=np.array(hog_features)data_frame=np.hstack((hog_features,labels))#Shufflethedatasetnp.random.shuffle(data_frame)percentage=80partition=int(len(hog_features)*percentage/100)x_train=data_frame[:partition,:-1]x_test=data_frame[partition:,:-1]y_train=data_frame[:partition,-1:].ravel()y_test=data_frame[partition:,-1:].ravel()#Traintheclassifierwiththetrainingdataclf.fit(x_train,y_train)
y_pred=clf.predict(x_test)print("Accuracy:"+str(accuracy_score(y_test,y_pred)))print('n')print(classification_report(y_test,y_pred))


推荐阅读