Customer purchase prediction - LLM written on Python:
https://github.com/cholakovit/customer_purchase_prediction
This Python code builds, trains, and evaluates a simple neural network using TensorFlow for binary classification. It starts by importing necessary libraries for data handling, preprocessing, and building neural networks. A small fictional dataset is created with features like age, salary, years of membership, and interest in a product, along with a target variable indicating if a purchase was made. The dataset is split into training and testing sets, and the features are normalized to improve neural network performance. The neural network is defined with one hidden layer of 8 neurons using a ReLU activation function and an output layer with a single neuron using a sigmoid activation function to predict whether a purchase will be made (binary classification). The model is compiled with the Adam optimizer, binary cross-entropy loss function, and accuracy as the metric. It is trained over 50 epochs with a batch size of 2. After training, the model is evaluated on the test set, and its accuracy is printed. Finally, the model predicts purchase probabilities for the test set, converts these probabilities into binary outputs (0 or 1), and compares them with the actual test values, printing the results.
How to Build and Run a Neural Network with TensorFlow - Complete Tutorial based on this project
Features:
- Data Preprocessing: The code handles a small, fictional dataset using Pandas. The dataset includes features like age, salary, years of membership, and interest in a product, with the target variable being whether a purchase was made.
- Training and Evaluation: The model is trained using the Adam optimizer, which is a widely-used optimization algorithm for deep learning, combined with the binary cross-entropy loss function, which is ideal for binary classification tasks.
- Prediction and Comparison: After training, the model predicts the probability of a purchase for each test instance.
- Logging Suppression: The line os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' is used to suppress TensorFlow's logging output, ensuring that only critical errors are shown, which makes the output cleaner during training and evaluation.
Main Technologies:
- TensorFlow is an open-source machine learning framework developed by Google. It's primarily used for building and training deep learning models, such as neural networks.
- Pandas is a powerful data manipulation and analysis library for Python. It is commonly used for working with structured data like tables (DataFrames).
- Scikit-learn is a comprehensive machine learning library that provides simple and efficient tools for data mining, data analysis, and machine learning.
- Neural networks are a class of machine learning algorithms modeled after the human brain. They are particularly useful for complex pattern recognition tasks like classification and regression.
- Python is a high-level programming language that is widely used for machine learning and data science due to its rich ecosystem of libraries like TensorFlow, Pandas, and Scikit-learn.
These technologies work together to create a complete machine learning pipeline that involves data handling, preprocessing, neural network creation, training, and evaluation.