Skip to content

Commit

Permalink
bump version 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Der-Henning committed Aug 23, 2022
1 parent e61d10e commit c2e5c86
Show file tree
Hide file tree
Showing 13 changed files with 4,071 additions and 3,655 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,5 @@ dmypy.json
# Pyre type checker
.pyre/

.DS_Store
.DS_Store
insights.pkl
34 changes: 27 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ from tki.insights import OutstandingFirstInsight, OutstandingLastInsight, \
from tki.extractors import RankExtractor, DeltaPrevExtractor, \
DeltaMeanExtractor, ProportionExtractor
from tki.aggregators import SumAggregator
from tki.dimensions import TemporalDimension, OrdinalDimension, \
NominalDimension
from tki.dimensions import CardinalDimension, TemporalDimension, NominalDimension

data = [
['H', 2010, 40], ['T', 2010, 38], ['F', 2010, 13], ['B', 2010, 20],
Expand Down Expand Up @@ -56,29 +55,50 @@ insights = {
}
tki = TKI(
pd.DataFrame(data, columns=['Brand', 'year', 'Cars Sold']),
dimensions=[NominalDimension('Brand'), TemporalDimension('year')],
measurements=[OrdinalDimension('Cars Sold')],
dimensions=[
NominalDimension('Brand'),
TemporalDimension('year', date_format='%Y', freq='1Y')],
measurements=[CardinalDimension('Cars Sold')],
extractors=extractors,
aggregators=aggregators,
insights=insights,
depth=3,
result_size=21)
tki.run()

_, axes = plt.subplots(7, 3, figsize=(25, 40), dpi=80)
plt.subplots_adjust(hspace=0.3)
fig, axes = plt.subplots(7, 3, figsize=(25, 40), dpi=80)
for idx, i in enumerate(tki.heap.insights):
plt.axes(axes[int(idx/3)][idx % 3])
i.plot()
plt.title(
f"{idx + 1}) {type(i.insight).__name__} "
f"score: {i.impact:.2f} * {i.significance:.2f} = {i.score:.2f}\n"
f"{(i.sibling_group, i.composite_extractor)}")
x_index = i.data.index.get_level_values(i.data.index.names[-1])
plt.xticks(rotation=0)
if isinstance(x_index, pd.DatetimeIndex):
plt.xticks(
range(i.data.index.size),
x_index.to_series().dt.year)
fig.tight_layout()
plt.savefig('insights.svg')

tki.save('insights.pkl')
````

### Result

![Insights](./insights.svg)


## Web Application

The web application will provide a convenient interface for the tki package in the future.
At the moment it is possible to visualize saved insights in the browser.
Start the server with

````
python -m tki.app
````

The project will be accessible via `http://127.0.0.1:8050/` in your web browser.
To display your previously generated results open the `Result` tab and upload your `insights.pkl` file.
14 changes: 11 additions & 3 deletions car_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
}
tki = TKI(
pd.DataFrame(data, columns=['Brand', 'year', 'Cars Sold']),
dimensions=[NominalDimension('Brand'), TemporalDimension('year')],
dimensions=[
NominalDimension('Brand'),
TemporalDimension('year', date_format='%Y', freq='1Y')],
measurements=[CardinalDimension('Cars Sold')],
extractors=extractors,
aggregators=aggregators,
Expand All @@ -44,14 +46,20 @@
result_size=21)
tki.run()

_, axes = plt.subplots(7, 3, figsize=(25, 40), dpi=80)
plt.subplots_adjust(hspace=0.3)
fig, axes = plt.subplots(7, 3, figsize=(25, 40), dpi=80)
for idx, i in enumerate(tki.heap.insights):
plt.axes(axes[int(idx/3)][idx % 3])
i.plot()
plt.title(
f"{idx + 1}) {type(i.insight).__name__} "
f"score: {i.impact:.2f} * {i.significance:.2f} = {i.score:.2f}\n"
f"{(i.sibling_group, i.composite_extractor)}")
x_index = i.data.index.get_level_values(i.data.index.names[-1])
plt.xticks(rotation=0)
if isinstance(x_index, pd.DatetimeIndex):
plt.xticks(
range(i.data.index.size),
x_index.to_series().dt.year)
fig.tight_layout()
plt.savefig('insights.svg')
tki.save('insights.pkl')
Loading

0 comments on commit c2e5c86

Please # to comment.