Friday, November 4, 2022

Histogram report and binning on Sales data

Layoffs and Reduction of Infrastructure Cost at Musk's Twitter (Nov 2022)

Musk Orders Twitter To Reduce Infrastructure Costs By $1 Billion: Sources

Elon Musk has directed Twitter Inc’s teams to find up to $1 billion in annual infrastructure cost savings, according to two sources familiar with the matter and an internal Slack message reviewed by Reuters, raising concerns that Twitter could go down during high-traffic events like the U.S. midterm elections. The company is aiming to find between $1.5 million and $3 million a day in savings from servers and cloud services, said the Slack message, which referred to the project as “Deep Cuts Plan." Twitter is currently losing about $3 million a day “with all spending and revenue considered," according to an internal document reviewed by Reuters. Twitter did not immediately respond to a request for comment.

'If On Way To Office, Return Home': Twitter To All Employees As Layoffs Begin

Elon Musk-owned Twitter is going ahead with a massive firing plan globally. Twitter has literally shut its offices and suspended the badges of all employees until a decision is made as to whether an employee is fired or retained. The scale is so massive that employees who are not fired will get “a notification via their Twitter email”. And those who are fired will get an email on their personal email ID. The decision will be made by Friday and all employees will get an email by “9AM PST on Friday Nov. 4th.” Elon Musk is said to be working with close colleagues at Tesla and SpaceX to structure the layoff plans. 3,738 Twitter employees could be laid off. Employees at Twitter were notified in an email seen by The New York Times that layoffs would start on Friday and instructed not to come into work on that day. The overall number of layoffs the corporation was contemplating was not mentioned in the email. Here’s the full letter that was to sent to Twitter employees: Team, In an effort to place Twitter on a healthy path, we will go through the difficult process of reducing our global workforce on Friday. We recognize that this will impact a number of individuals who have made valuable contributions to Twitter, but this action is unfortunately necessary to ensure the company’s success moving forward. Given the nature of our distributed workforce and our desire to inform impacted individuals as quickly as possible, communications for this process will take place via email. By 9AM PST on Friday Nov. 4th, everyone will receive an individual email with the subject line: Your Role at Twitter. Please check your email, including your spam folder. If your employment is not impacted, you will receive a notification via your Twitter email. • If your employment is impacted, you will receive a notification with next steps via your personal email. • If you do not receive an email from twitter-hr@ by 5PM PST on Friday Nov. 4th, please email peoplequestions@twitter.com. To help ensure the safety of each employee as well as Twitter systems and customer data, our offices will be temporarily closed and all badge access will be suspended. If you are in an office or on your way to an office, please return home. We acknowledge this is an incredibly challenging experience to go through, whether or not you are impacted. Thank you for continuing to adhere to Twitter policies that prohibit you from discussing confidential company information on social media, with the press or elsewhere. We are grateful for your contributions to Twitter and for your patience as we move through this process. Thank you. Twitter
Tags: Investment,Management,

Thursday, November 3, 2022

Stratified sampling and fixed size sampling plus visualization using pie plot (Nov 2022)

Download Code And Data

1. Stratified Sampling Using Pandas

import pandas as pd import numpy as np import matplotlib.pyplot as plt complete_data = pd.read_csv('sales_data_sample.csv') colslist = ['COUNTRY', 'PRODUCTLINE'] train_size = 0.33 data_sample = complete_data.groupby(colslist, group_keys=False).apply( lambda x: x.sample( int(train_size*len(x)), random_state=1 ) ) complete_data.head()
complete_data.shape (2823, 25) data_sample.shape (865, 25) def plot_pie(labels, sizes, title = ""): colors = ['#f47961', '#f0c419', '#255c61', '#78909c', '#6ad4cf', '#17aee8', '#5c6bc0', '#444b6e', '#ef4c60', '#744593', '#ee5691', '#9ccc65', '#708b75', '#d1cb65', '#0d8de1', '#a4554b', '#694f5d', '#45adb3', '#26a69a', '#bdc7cc', ] colors = colors[0:len(labels)] explode = (0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) # explode 1st slice explode = explode[0:len(labels)] # Plot plt.figure(num=None, figsize=(9, 7), dpi=80, facecolor='w', edgecolor='k') plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=140) plt.title(title) plt.axis('equal') plt.show() pie_plot_data = complete_data.groupby('COUNTRY', as_index=False)['COUNTRY'].value_counts() pie_plot_data.sort_values(by=['count'], inplace = True) pie_plot_data.head()
plot_pie(pie_plot_data.COUNTRY.values, pie_plot_data['count'].values, 'Countries Before Sampling')
pie_plot_data = data_sample.groupby('COUNTRY', as_index=False)['COUNTRY'].value_counts() pie_plot_data.sort_values(by=['count'], inplace = True) pie_plot_data.head()
plot_pie(pie_plot_data.COUNTRY.values, pie_plot_data['count'].values, 'Countries After Sampling')

2. Fixed Size Sampling With Equal Representation When Number of Records is Too Large

data_sample = complete_data.groupby(colslist, group_keys=False).apply( lambda x: x.sample(n = 1, random_state=1) ).reset_index(drop=True) pie_plot_data = data_sample.groupby('COUNTRY', as_index=False)['COUNTRY'].value_counts() pie_plot_data.sort_values(by=['count'], inplace = True) pie_plot_data.head()
pie_plot_data.tail()
plot_pie(pie_plot_data.COUNTRY.values, pie_plot_data['count'].values, 'Countries After Sampling')
data_sample[data_sample['COUNTRY'] == 'USA'][colslist]
Tags: Technology,Data Visualization,Machine Learning,