\

Transforming Business Education: Using GPT-4o to Make Python as Accessible as Excel

  • Jordi Torras
  • Blog

Introduction

Business users have historically avoided coding. They often rely on no-code tools, which, although helpful, lack the capabilities of modern programming languages. However, with the introduction of Generative AI, like GPT-4, the situation is changing. Business users can now utilize the power of complex programming languages such as Python and Java, opening up new possibilities for creating more advanced and effective solutions.

Excel Formulas

Microsoft Excel is a staple tool for many business users. Excel formulas allow users to perform a wide range of calculations and data manipulations. For example, a complex formula might look like this:

 =IF(B2 > 50000, B2 * 0.1, IF(B2 >= 30000, B2 * 0.075, B2 * 0.05)) +
  IF(C2 > 95, 500, IF(C2 >= 90, 250, 0)) *
  IF(D2 = "Excellent", 1.2, IF(D2 = "Good", 1.1, 1.0))

This formula calculates a bonus payout based on three factors: sales performance, attendance, and performance rating. Business users can often create intricate formulas that rival the complexity of code snippets developed by experience software engineers using a programming language.

That would be the equivalent of the same formula using Python:
 df['E'] = df.apply (
  lambda row:
      (row['B'] * 0.1 if row['B'] > 50000 else (row['B'] * 0.075
        if row['B'] >= 30000 else row['B'] * 0.05)) +
      ((500 if row['C'] > 95 else (250 if row['C'] >= 90 else 0)) *
      (1.2 if row['D'] == "Excellent" else (1.1 if row['D'] == "Good" else 1.0))),
  axis=1
)

That code snippet was generated by GPT-4 with the simple prompt "what would be the Python equivalent of this Excel formula". Despite this, Excel's capabilities are inherently limited compared to full programming languages.

SQL

SQL (Structured Query Language) was developed as a fourth-generation language designed for business users to manage and query relational databases. Despite its initial intention, SQL usage has predominantly remained within the realm of software engineers who use it alongside other languages like Python or PHP. SQL allows for powerful data manipulation and retrieval, such as:

 SELECT employee_name, SUM(sales)
FROM sales_data
GROUP BY employee_name;

This query retrieves the names of employees and the sum of their sales from the sales_data table, grouping the results by employee name. SQL's robustness and flexibility make it a critical tool in data-driven environments.

To generate this SQL query using GPT-4, we provided a simple prompt: "Write an SQL query to retrieve the total sales for each employee."

Google Colab

Google Colab, short for Google Colaboratory, is a free cloud-based platform provided by Google that allows users to write and execute Python code through a web browser. It is particularly popular for data science, machine learning, and deep learning projects due to its seamless integration with popular Python libraries like TensorFlow, Keras, and PyTorch. Colab provides free access to powerful computing resources, including GPUs and TPUs, making it an accessible and convenient tool for researchers, students, and professionals who require significant computational power for their projects.

My Experience with AI for Business Programs

As the Program Director of several AI as a Strategic Tool programs at business schools like EADA Business School or ADEN Business School, which are designed for students with a business background, I initially relied on no-code tools for teaching machine learning. While user-friendly, these tools proved to be quite limited.

Then, I thought that if business users can master complex formulas using Microsoft Excel, there is no reason they cannot learn machine learning using GPT-4 as the main code generation tool.

Therefore, I transitioned my students to using Google Colab notebooks, leveraging GPT-4 to generate necessary Python code and Kaggle to explore potential datasets.

I was concerned that business users would find these platforms too technical or unsuitable for their needs. However, reality proved otherwise. Students embraced the combination of Colab and GPT-4, using them to create comprehensive machine learning applications with linear regression, decision trees, and neural networks. They discovered how effectively GPT-4 could enhance their knowledge, produce visualizations, and troubleshoot issues.

The Power of Generative AI

Generative AI is bridging the gap between business users and software engineering. For those familiar with tools like Excel, the transition to using Python, DataFrames, and machine learning libraries is manageable. Generative AI tools like GPT-4, Claude, and Gemini enable business users to create sophisticated applications. The chart below illustrates this transformation:

Capabilities vs Difficulty Chart

Shortening the Proficiency Gap

The chart highlights the capabilities and difficulty levels of different tools. Initially, business users are proficient with Microsoft Excel formulas, which offer moderate capabilities with low difficulty. SQL, designed to be user-friendly, actually demands more technical expertise, thus fewer business users utilize it directly.

With the introduction of Generative AI, business users can leapfrog traditional barriers. Generative AI provides a path from Excel directly to complex programming languages, bypassing the steep learning curves associated with these tools. This leap is represented by the green arrows, indicating the significant reduction in difficulty when using AI tools to aid in programming.

Below is an example of code generated by GPT-4 that a non-technical person used to create a machine learning application. This application uses linear regression to determine when a loan should be marketed to potential customers.

 # Define the feature columns and the target variable
features = ['age', 'experience', 'income', 'family', 'ccavg', 'education',
  'mortgage', 'securities_account', 'cd_account', 'online',
  'creditcard', 'average_income', 'income_imputed',
  'income_diff_percentage', 'has_mortgage']
target = 'personal_loan'

# Split the data into training and testing sets
X = data[features]
y = data[target]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Create the linear regression model
model = LinearRegression()

# Train the model
model.fit(X_train, y_train)

# Predict using the test set
y_pred = model.predict(X_test)

# Evaluate the model
mse = mean_squared_error(y_test, y_pred)
r2 = r2_score(y_test, y_pred)

print(f'Mean Squared Error: {mse}')
print(f'R-squared: {r2}')

Future Collaboration

Experienced software engineers will undoubtedly continue to collaborate with business users to develop innovative applications. However, the ability of business users to utilize machine learning libraries as seamlessly as they use Excel today will usher in a new era of innovation and disruption.

I am thrilled to witness and contribute to this transformative time in business education. Instead of fearing that GPT-4 and similar tools make tasks "too easy" for students, I encourage them to push the boundaries of what Generative AI can achieve, empowering them to reach new heights in their capabilities.

Google Colab, GPT-4, and Kaggle have become indispensable tools in my teaching, allowing students without a computer science background to explore, analyze, and model data effectively. The combination of these platforms offers unprecedented opportunities for business users to create value and drive innovation.

Make AI work for you

Empower your vision with our expertise. Me and my team specialize in turning concepts into reality, delivering tailored solutions that redefine what's possible. Let's unlock the full potential of AI. Effectively.

Contact us