Beispiel #1
0
    def read_clients(self, clientsFile):
        """
        Read a file with clients into a collection.
        Requires:
            .clientsFile, str with the name of a text file with a list of clients.
        Ensures:
            .clientsList, a collection of clients
        """

        openFile = open(clientsFile, 'r')

        for i in range(7):  # skips the header
            openFile.readline()

        clientsList = []

        for line in openFile:
            lineList = line.strip().split(
                ', '
            )  # splits the line (1 client) and inserts a comma between every field
            clientsList.append(
                Clients(lineList[0], lineList[1], lineList[2], lineList[3],
                        float(lineList[4]), lineList[5], lineList[6],
                        lineList[7]))  #writes the experts field by field

        return clientsList
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans, AffinityPropagation
from sklearn.model_selection import train_test_split
import warnings
from Clients import Client, Clients
from Recommender import ColabRecommender, ContentRecommender

warnings.filterwarnings("ignore")

data          = pd.read_csv('./data/german_credit_data.csv')
numeric_data  = data.loc[:,["Age","Credit amount","Duration"]]
clients       = Clients(numeric_data)
indices = np.arange(1000)

#An'alisis de datos...
X = clients.getX()
y = clients.getY()


X_train, X_test, Y_train, y_test,indices_train,indices_test  = train_test_split(X,y,indices,test_size=0.2, random_state=1, stratify=y)
contentRecommender = ContentRecommender(X_train,Y_train)

# client             = Client(age=45,credit_amount=2000,duration=2)
# print(indices_test)