Exemplo n.º 1
0
import Utils.Renders as rd  # NOQA
from DA import Prodotti
from Utils import Clust  # NOQA
from Utils import Constants
from Utils.ClAnalyzer import ClAnalyzer

from IPython import embed
# }}}

sns.set()
sns.set_palette(Constants.abc_l)
# plt.ion()

# {{{ Preparazione Dataset
df = Prodotti.get_df_group_prod(include_rare=True)
df_scaled = Prodotti.get_df_group_prod_proc(include_rare=True)
CA = ClAnalyzer(df)
CA.add_df(df_scaled, 'scaled')
feats = ['nAvSess', 'Recency', 'nUsers', 'Ratio', 'UserRatio']
feats3 = ['Recency', 'nUsers', 'Ratio']
CA.features = feats
# 1: molto consigliato
# 2: consigliato a nord
# 3: consigliato correttamente e numeroso
# samples = ['P0011AN', 'P0018AN', 'P0080AB']
samples = ['P0011AN']
CA.set_samples(samples, 'ProductId')

CA.print_relevance(df_name='scaled')
if 0:
Exemplo n.º 2
0
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial.distance import pdist, squareform
from sklearn.cluster import DBSCAN, KMeans
from sklearn.neighbors import NearestNeighbors
from sklearn.decomposition import PCA
import Utils.Renders as rd  # NOQA
import pandas as pd
from DA import Prodotti
from Utils import Clust # NOQA
from Utils.ClAnalyzer import ClAnalyzer
from IPython import embed
# }}}

# {{{ Preparazione Dataset
prod = Prodotti.get_df_group_prod()
prod_proc = Prodotti.get_df_group_prod_proc()
CA = ClAnalyzer(prod)
CA.add_df(prod_proc, 'scaled')
feats = ['nAvSess', 'Recency', 'nUsers', 'Ratio', 'UserRatio']
feats3 = ['Recency', 'nUsers', 'Ratio']
CA.features = feats
CA.print_relevance(df_name='scaled')

# 1: molto consigliato
# 2: consigliato a nord
# 3: consigliato correttamente e numeroso
samples = ['P0011AN', 'P0018AN', 'P0080AB']
CA.set_samples(samples, 'ProductId')
if 0:
    CA.print_outliers()