'how do i convert a .csv file to a .data file?

Does anyone know how to convert a .csv file to a .data or know how to use only half of a .data file like a csv file?

I'm trying to achieve a mean Average Position of the breast cancer database from scikit-Klearn and I already have it working, but it like to use only half or a quarter of the data set to see the impact but when I try to reduce the file it converts it into a csv file and I need the .data file for my program using x=data.data to use it on my models andgetting the ACC or mAP. So I need either a way to convert the .csv file to a .data file to insert it as is or to reduce the .data file or another alternative like using a different for to achieve the map

my code

from sklearn. model_selection import train_test_split
from sklearn. neighbors import KNeighborsClassifier
from numpy.ma.core import size
import numpy as np
from sklearn. model_selection import KFold
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
import pandas
from sklearn.svm import SVC
from sklearn.linear_model import SGDClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import AdaBoostClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.datasets import load_breast_cancer

data = load_breast_cancer()

X=data.data

Y=data.target

Models = {'kNN -3' : KNeighborsClassifier ( n_neighbors = 3),'kNN -5' : KNeighborsClassifier ( n_neighbors = 5), 'Linear SVM': SVC (kernel="linear", C=0.025),'Gaussian Naive Bayes':  GaussianNB(), 'Decision Tree':  DecisionTreeClassifier(max_depth=4),'AdaBoost':AdaBoostClassifier()};

TS = [0.25,0.5,0.75,0.8]
RS = [10,42,125,999]


ACC=[];
ARS=[];
ATS=[];
NM=[];
DF= pandas.DataFrame()


for name, model in Models.items():
  for rs in RS:
    for ts in TS:
      X_train , X_test , Y_train , Y_test = train_test_split (X, Y,test_size = ts , random_state = rs);
      model.fit(X_train,Y_train)
      y_hat=model.predict(X_test)
      acc= np.sum(y_hat==Y_test)/len(y_hat)

      ACC.append(acc);
      ARS.append(rs);
      ATS.append(ts);
      NM.append(name);

DF=DF.assign(NM=NM)
DF=DF.assign(RS=ARS)
DF=DF.assign(TS=ATS)
DF=DF.assign(mAp=ACC)

print(DF)

Df=DF.nlargest(20,['mAp'])

print(Df)
DF.to_csv('DF.csv')


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source